@4399ywkf/core 5.0.11 → 5.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +61 -15
- package/dist/index.js +638 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -229,28 +229,36 @@ interface I18nPluginOptions {
|
|
|
229
229
|
*/
|
|
230
230
|
locales?: string[];
|
|
231
231
|
/**
|
|
232
|
-
*
|
|
232
|
+
* 翻译 JSON 文件目录(相对于项目根目录)
|
|
233
|
+
* 非默认语言的 JSON 翻译文件存放位置
|
|
233
234
|
* @default "locales"
|
|
234
235
|
*/
|
|
235
236
|
localesDir?: string;
|
|
237
|
+
/**
|
|
238
|
+
* 默认语言 TS 源文件目录(相对于项目根目录)
|
|
239
|
+
* 开发者在此编写 TypeScript 翻译源文件,作为 i18n 的 single source of truth
|
|
240
|
+
* @default "src/locales/default"
|
|
241
|
+
*/
|
|
242
|
+
sourceDir?: string;
|
|
236
243
|
/**
|
|
237
244
|
* 默认命名空间
|
|
238
245
|
* @default ["common"]
|
|
239
246
|
*/
|
|
240
247
|
defaultNS?: string[];
|
|
241
248
|
/**
|
|
242
|
-
*
|
|
249
|
+
* 是否自动生成初始脚手架文件
|
|
243
250
|
* @default true
|
|
244
251
|
*/
|
|
245
252
|
autoScaffold?: boolean;
|
|
246
253
|
}
|
|
247
254
|
/**
|
|
248
|
-
*
|
|
255
|
+
* 国际化插件(TS-first 工作流)
|
|
249
256
|
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* -
|
|
257
|
+
* 开发流程:
|
|
258
|
+
* 1. 开发者在 src/locales/default/ 中编写 TypeScript 翻译源文件(有类型推导 + IDE 补全)
|
|
259
|
+
* 2. 运行 `pnpm i18n:gen` 将 TS 源文件转换为 locales/{defaultLocale}/*.json
|
|
260
|
+
* 3. 运行 `pnpm i18n` 使用 @lobehub/i18n-cli 将默认语言 JSON 翻译为其他语言
|
|
261
|
+
* 4. 运行时:开发模式下默认语言直接 import TS,其他场景懒加载 JSON
|
|
254
262
|
*
|
|
255
263
|
* @example
|
|
256
264
|
* ```ts
|
|
@@ -275,15 +283,20 @@ interface ThemePluginOptions {
|
|
|
275
283
|
*/
|
|
276
284
|
darkMode?: boolean;
|
|
277
285
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
286
|
+
* 默认主题模式(作为 store 的初始值,运行时可通过 useThemeStore 动态切换)
|
|
287
|
+
* 参考 lobe-ui 默认暗色风格
|
|
288
|
+
* @default "dark"
|
|
280
289
|
*/
|
|
281
290
|
defaultAppearance?: "light" | "dark" | "auto";
|
|
282
291
|
/**
|
|
283
|
-
*
|
|
284
|
-
* @default "
|
|
292
|
+
* 主色调(作为 store 的初始值,运行时可通过 useThemeStore 动态切换)
|
|
293
|
+
* @default "#1677ff"
|
|
285
294
|
*/
|
|
286
295
|
primaryColor?: string;
|
|
296
|
+
/**
|
|
297
|
+
* 中性色(作为 store 的初始值)
|
|
298
|
+
*/
|
|
299
|
+
neutralColor?: string;
|
|
287
300
|
/**
|
|
288
301
|
* antd 前缀
|
|
289
302
|
* @default "ant"
|
|
@@ -299,14 +312,34 @@ interface ThemePluginOptions {
|
|
|
299
312
|
* @default true
|
|
300
313
|
*/
|
|
301
314
|
globalReset?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* 是否启用外部主题注入(微前端场景)
|
|
317
|
+
*
|
|
318
|
+
* 启用后:
|
|
319
|
+
* - 应用启动时读取 window.__YWKF_THEME__ 作为初始覆盖
|
|
320
|
+
* - 监听 ywkf:theme-change 自定义事件,实现运行时主题同步
|
|
321
|
+
*
|
|
322
|
+
* 主应用注入示例:
|
|
323
|
+
* ```ts
|
|
324
|
+
* window.__YWKF_THEME__ = { primaryColor: "#ff4d4f", appearance: "dark" };
|
|
325
|
+
* window.dispatchEvent(new CustomEvent("ywkf:theme-change", {
|
|
326
|
+
* detail: { primaryColor: "#52c41a" },
|
|
327
|
+
* }));
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @default false
|
|
331
|
+
*/
|
|
332
|
+
externalTheme?: boolean;
|
|
302
333
|
}
|
|
303
334
|
/**
|
|
304
|
-
*
|
|
335
|
+
* 响应式主题系统插件
|
|
305
336
|
*
|
|
306
|
-
* 基于 antd-style
|
|
337
|
+
* 基于 antd-style + Zustand 提供运行时可变的主题管理能力:
|
|
307
338
|
* - 生成 ThemeProvider 包裹组件到 .ywkf/theme.tsx
|
|
339
|
+
* - 生成 useThemeStore / useTheme 等 hooks 供业务消费
|
|
308
340
|
* - 注入 ThemeProvider 到 bootstrap
|
|
309
|
-
* -
|
|
341
|
+
* - 支持亮/暗色/跟随系统自动切换
|
|
342
|
+
* - 支持微前端场景下主应用注入主题
|
|
310
343
|
*
|
|
311
344
|
* @example
|
|
312
345
|
* ```ts
|
|
@@ -317,11 +350,24 @@ interface ThemePluginOptions {
|
|
|
317
350
|
* themePlugin({
|
|
318
351
|
* darkMode: true,
|
|
319
352
|
* defaultAppearance: "auto",
|
|
320
|
-
* primaryColor: "
|
|
353
|
+
* primaryColor: "#1677ff",
|
|
354
|
+
* externalTheme: true,
|
|
321
355
|
* }),
|
|
322
356
|
* ],
|
|
323
357
|
* });
|
|
324
358
|
* ```
|
|
359
|
+
*
|
|
360
|
+
* 业务组件中使用:
|
|
361
|
+
* ```tsx
|
|
362
|
+
* import { useThemeStore, useTheme } from "@/.ywkf/theme";
|
|
363
|
+
*
|
|
364
|
+
* function ThemeSwitch() {
|
|
365
|
+
* const { appearance, setAppearance } = useThemeStore(
|
|
366
|
+
* (s) => ({ appearance: s.appearance, setAppearance: s.setAppearance }),
|
|
367
|
+
* );
|
|
368
|
+
* return <Switch checked={appearance === "dark"} onChange={(v) => setAppearance(v ? "dark" : "light")} />;
|
|
369
|
+
* }
|
|
370
|
+
* ```
|
|
325
371
|
*/
|
|
326
372
|
declare const themePlugin: (options?: ThemePluginOptions | undefined) => YwkfPlugin;
|
|
327
373
|
|