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:
parent
ef6a3f0da2
commit
975e331dd5
@ -73,6 +73,9 @@ pub fn ImageViewer(
|
|||||||
// 计算 aspect-ratio:SSR 时读图片真实尺寸。WASM 端不读(--ar 已在 SSR 写入 HTML)。
|
// 计算 aspect-ratio:SSR 时读图片真实尺寸。WASM 端不读(--ar 已在 SSR 写入 HTML)。
|
||||||
// 非 /uploads/ 的外链图或读不到尺寸时不设 --ar。
|
// 非 /uploads/ 的外链图或读不到尺寸时不设 --ar。
|
||||||
let ar_style = {
|
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();
|
let mut s = String::new();
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
{
|
{
|
||||||
|
|||||||
@ -78,11 +78,11 @@ fn write_editor(post_id: Option<i32>) -> Element {
|
|||||||
let mut editor: Signal<Option<EditorHandle>> = use_signal(|| None);
|
let mut editor: Signal<Option<EditorHandle>> = use_signal(|| None);
|
||||||
// WASM 前端:编辑器就绪标志(onReady 回调驱动,替代 __tiptap_ready 轮询)。
|
// WASM 前端:编辑器就绪标志(onReady 回调驱动,替代 __tiptap_ready 轮询)。
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[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 uploads_in_flight = use_signal(UploadsInFlight::default);
|
||||||
let mut upload_errors: Signal<Vec<UploadErrorEntry>> = use_signal(Vec::new);
|
let upload_errors: Signal<Vec<UploadErrorEntry>> = use_signal(Vec::new);
|
||||||
|
|
||||||
// 编辑模式:文章数据加载完成后,将字段回填到表单信号。
|
// 编辑模式:文章数据加载完成后,将字段回填到表单信号。
|
||||||
use_effect(move || {
|
use_effect(move || {
|
||||||
@ -261,7 +261,7 @@ fn write_editor(post_id: Option<i32>) -> Element {
|
|||||||
// 将逗号分隔的标签字符串转换为列表。
|
// 将逗号分隔的标签字符串转换为列表。
|
||||||
// 同时支持半角/全角逗号与分号,避免中文输入法下的全角标点被误并入单个标签。
|
// 同时支持半角/全角逗号与分号,避免中文输入法下的全角标点被误并入单个标签。
|
||||||
let tags_list: Vec<String> = tags()
|
let tags_list: Vec<String> = tags()
|
||||||
.split(|c| matches!(c, ',' | ',' | ';' | ';'))
|
.split(|c| matches!(c, ',' | ',' | ';' | ';'))
|
||||||
.map(|t| t.trim().to_string())
|
.map(|t| t.trim().to_string())
|
||||||
.filter(|t| !t.is_empty())
|
.filter(|t| !t.is_empty())
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
@ -29,8 +29,8 @@ pub struct UploadErrorEntry {
|
|||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
pub mod wasm {
|
pub mod wasm {
|
||||||
use super::{UploadErrorEntry, UploadsInFlight};
|
use super::{UploadErrorEntry, UploadsInFlight};
|
||||||
// WritableExt 提供 .write();Writable 提供 .set()。Signal 方法需 trait 在作用域内。
|
// WritableExt 提供 .write()(Signal 在 Copy 语义下不需要 mut 绑定)。
|
||||||
use dioxus::prelude::{Readable, Writable, WritableExt};
|
use dioxus::prelude::WritableExt;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
@ -251,10 +251,11 @@ pub mod wasm {
|
|||||||
.map_err(|_| js_sys::Error::new("无法附加文件"))?;
|
.map_err(|_| js_sys::Error::new("无法附加文件"))?;
|
||||||
|
|
||||||
// 构造 POST 请求,credentials same-origin 携带 session cookie
|
// 构造 POST 请求,credentials same-origin 携带 session cookie
|
||||||
let mut init = web_sys::RequestInit::new();
|
let init = web_sys::RequestInit::new();
|
||||||
init.method("POST");
|
init.set_method("POST");
|
||||||
init.body(Some(&form));
|
// set_body 接收 &JsValue(非 Option);FormData: AsRef<JsValue>。
|
||||||
init.credentials(web_sys::RequestCredentials::SameOrigin);
|
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)
|
let request = web_sys::Request::new_with_str_and_init("/api/upload", &init)
|
||||||
.map_err(|_| js_sys::Error::new("无法构造上传请求"))?;
|
.map_err(|_| js_sys::Error::new("无法构造上传请求"))?;
|
||||||
@ -300,6 +301,6 @@ pub mod wasm {
|
|||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
pub use wasm::{
|
pub use wasm::{
|
||||||
consume_upload_event, make_upload_closure, EditorHandle, EditorInstance, EditorOptions,
|
consume_upload_event, make_upload_closure, EditorHandle, EditorOptions, UploadEventJs,
|
||||||
TiptapEditorModule, UploadEventJs, get_module,
|
get_module,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user