fix(write): split tags on fullwidth punctuation

The tag splitter matched ASCII ',' and ';' twice instead of the
fullwidth ',' (U+FF0C) / ';' (U+FF1B) the comment intended, so tags
separated by fullwidth punctuation (common under Chinese IMEs)
collapsed into a single tag.

Also resolves the compiler warnings surfaced in the same build:
- tiptap_bridge: drop unused Readable/Writable imports and
  EditorInstance/TiptapEditorModule re-exports
- tiptap_bridge: migrate deprecated RequestInit::method/body/
  credentials builders to set_method/set_body/set_credentials
- write: remove redundant `mut` on Dioxus signals that are only
  read/set, never reassigned
- image_viewer: gate the server-only `mut` reassignment so the WASM
  build (which strips the cfg block) doesn't warn
This commit is contained in:
xfy 2026-06-23 14:44:18 +08:00
parent ef6a3f0da2
commit 975e331dd5
3 changed files with 16 additions and 12 deletions

View File

@ -73,6 +73,9 @@ pub fn ImageViewer(
// 计算 aspect-ratioSSR 时读图片真实尺寸。WASM 端不读(--ar 已在 SSR 写入 HTML
// 非 /uploads/ 的外链图或读不到尺寸时不设 --ar。
let ar_style = {
// `mut` 仅 server 构建需要WASM 构建剥离 #[cfg(feature = "server")] 块后,
// s 从未被重新赋值,故对 WASM 抑制 unused_mut。
#[cfg_attr(not(feature = "server"), allow(unused_mut))]
let mut s = String::new();
#[cfg(feature = "server")]
{

View File

@ -78,11 +78,11 @@ fn write_editor(post_id: Option<i32>) -> Element {
let mut editor: Signal<Option<EditorHandle>> = use_signal(|| None);
// WASM 前端编辑器就绪标志onReady 回调驱动,替代 __tiptap_ready 轮询)。
#[cfg(target_arch = "wasm32")]
let mut ready = use_signal(|| false);
let ready = use_signal(|| false);
// 上传状态:当前进行中计数(保存拦截)+ 顶部失败提示堆叠(用户手动关闭)
let mut uploads_in_flight = use_signal(UploadsInFlight::default);
let mut upload_errors: Signal<Vec<UploadErrorEntry>> = use_signal(Vec::new);
let uploads_in_flight = use_signal(UploadsInFlight::default);
let upload_errors: Signal<Vec<UploadErrorEntry>> = use_signal(Vec::new);
// 编辑模式:文章数据加载完成后,将字段回填到表单信号。
use_effect(move || {
@ -261,7 +261,7 @@ fn write_editor(post_id: Option<i32>) -> Element {
// 将逗号分隔的标签字符串转换为列表。
// 同时支持半角/全角逗号与分号,避免中文输入法下的全角标点被误并入单个标签。
let tags_list: Vec<String> = tags()
.split(|c| matches!(c, ',' | ',' | ';' | ';'))
.split(|c| matches!(c, ',' | '' | ';' | ''))
.map(|t| t.trim().to_string())
.filter(|t| !t.is_empty())
.collect();

View File

@ -29,8 +29,8 @@ pub struct UploadErrorEntry {
#[cfg(target_arch = "wasm32")]
pub mod wasm {
use super::{UploadErrorEntry, UploadsInFlight};
// WritableExt 提供 .write()Writable 提供 .set()。Signal 方法需 trait 在作用域内
use dioxus::prelude::{Readable, Writable, WritableExt};
// WritableExt 提供 .write()Signal 在 Copy 语义下不需要 mut 绑定)
use dioxus::prelude::WritableExt;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
@ -251,10 +251,11 @@ pub mod wasm {
.map_err(|_| js_sys::Error::new("无法附加文件"))?;
// 构造 POST 请求credentials same-origin 携带 session cookie
let mut init = web_sys::RequestInit::new();
init.method("POST");
init.body(Some(&form));
init.credentials(web_sys::RequestCredentials::SameOrigin);
let init = web_sys::RequestInit::new();
init.set_method("POST");
// set_body 接收 &JsValue非 OptionFormData: AsRef<JsValue>。
init.set_body(form.as_ref());
init.set_credentials(web_sys::RequestCredentials::SameOrigin);
let request = web_sys::Request::new_with_str_and_init("/api/upload", &init)
.map_err(|_| js_sys::Error::new("无法构造上传请求"))?;
@ -300,6 +301,6 @@ pub mod wasm {
#[cfg(target_arch = "wasm32")]
pub use wasm::{
consume_upload_event, make_upload_closure, EditorHandle, EditorInstance, EditorOptions,
TiptapEditorModule, UploadEventJs, get_module,
consume_upload_event, make_upload_closure, EditorHandle, EditorOptions, UploadEventJs,
get_module,
};