refactor(canvas): 替换自定义ID生成函数为nanoid并优化配置逻辑

- 移除自定义createId函数,统一使用nanoid库生成唯一标识符
- 将useEffectiveAiConfig Hook替换为resolveEffectiveConfig工具函数
- 直接从config store获取publicSettings避免额外的Hook依赖
- 更新所有组件中的ID生成调用以使用nanoid
- 简化buildApiUrl函数中的基础URL规范化逻辑
This commit is contained in:
HouYunFei
2026-05-21 13:50:32 +08:00
parent 6f1e0d347b
commit 22d34a0c99
9 changed files with 53 additions and 67 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
import { create } from "zustand";
import { persist, type PersistStorage, type StorageValue } from "zustand/middleware";
import { createId } from "@/lib/id";
import { nanoid } from "nanoid";
import { localForageStorage } from "@/lib/localforage-storage";
import { cleanupUnusedImages, resolveImageUrl, uploadImage } from "@/services/image-storage";
@@ -63,7 +63,7 @@ export const useAssetStore = create<AssetStore>()(
assets: [],
addAsset: (asset) => {
const now = new Date().toISOString();
const id = createId();
const id = nanoid();
set((state) => ({ assets: [{ ...asset, id, createdAt: now, updatedAt: now } as Asset, ...state.assets] }));
return id;
},