@complex-suite/plugin
Advanced tools
| import type { LocalePack } from '@complex-suite/utils' | ||
| import type { PluginMessages } from './zh' | ||
| /** plugin 包英文消息 */ | ||
| export const enMessages: PluginMessages = { | ||
| 'notice.timeout': | ||
| 'Notice timeout is not defined, please confirm notice is initialized!', | ||
| 'notice.debugConfirm': 'Debug mode operation confirmation', | ||
| 'notice.devConfirm': 'Development mode operation confirmation', | ||
| 'layout.moduleNotFound': (params) => | ||
| `Triggered module "${params.prop}" does not exist, please check!` | ||
| } | ||
| const en: LocalePack<PluginMessages> = { | ||
| lang: 'en-US', | ||
| messages: enMessages | ||
| } | ||
| export default en |
| import { Locale } from '@complex-suite/utils' | ||
| import zh from './zh' | ||
| import type { PluginMessages } from './zh' | ||
| /** | ||
| * plugin 包的 pluginLocale 单例(以 PluginMessages 为类型基准,zh 包直接传入构造函数完成注册+设置)。 | ||
| * plugin 包内部各模块可直接使用此单例。 | ||
| * | ||
| * 【语言包按需加载/注册】构造时默认仅注册中文包。 | ||
| * 英文包 en 作为独立子路径导出(./locale/en),主入口不加载它,避免无谓的模块求值开销。 | ||
| * 需要英文时显式导入并注册: | ||
| * import en from '@complex-suite/plugin/locale/en' | ||
| * pluginLocale.registerLocale(en) | ||
| */ | ||
| const pluginLocale = new Locale<PluginMessages>({ pack: zh, name: 'plugin' }) | ||
| export { | ||
| pluginLocale, | ||
| zh | ||
| } | ||
| export type { | ||
| PluginMessages | ||
| } |
| import type { LocalePack } from '@complex-suite/utils' | ||
| /** | ||
| * plugin 包中文消息(铺平格式,key 使用 dot-notation)。 | ||
| * 本文件是 plugin 包消息 schema 的【唯一类型来源】。 | ||
| */ | ||
| export const zhMessages = { | ||
| 'notice.timeout': 'notice超时未定义,请确认是否初始化notice!', | ||
| 'notice.debugConfirm': '调试模式操作确认', | ||
| 'notice.devConfirm': '开发模式操作确认', | ||
| 'layout.moduleNotFound': (params: { prop: string }) => `触发的${params.prop}模块不存在,请检查!` | ||
| } | ||
| /** plugin 包消息 schema 类型,基于 zhMessages 推导 */ | ||
| export type PluginMessages = typeof zhMessages | ||
| const zh: LocalePack<PluginMessages> = { | ||
| lang: 'zh-CN', | ||
| messages: zhMessages | ||
| } | ||
| export default zh |
+2
-0
| import date, { type parseType, type PluginDateInitOption, PluginDate } from "./src/date" | ||
| import notice, { type noticeOption, type messageType, type debugConfirmOption, type noticeType } from "./src/notice" | ||
| import PluginLayout, { PluginLayoutData, type PluginLayoutDataInitOption } from "./src/layout" | ||
| import { pluginLocale } from "./src/locale" | ||
@@ -34,4 +35,5 @@ export type optionsType = { | ||
| type PluginLayoutDataInitOption, | ||
| pluginLocale, | ||
| install | ||
| } | ||
+6
-2
| { | ||
| "name": "@complex-suite/plugin", | ||
| "version": "5.0.5", | ||
| "version": "5.0.6", | ||
| "description": "a complex plugin", | ||
| "type": "module", | ||
| "main": "index.ts", | ||
| "exports": { | ||
| ".": "./index.ts", | ||
| "./locale/en": "./src/locale/en.ts" | ||
| }, | ||
| "repository": { | ||
@@ -12,3 +16,3 @@ "type": "git", | ||
| "dependencies": { | ||
| "@complex-suite/utils": "3.0.5" | ||
| "@complex-suite/utils": "3.0.6" | ||
| }, | ||
@@ -15,0 +19,0 @@ "devDependencies": { |
+2
-1
| import { _Data, Life, throttle } from "@complex-suite/utils" | ||
| import type { DataWithLife } from "@complex-suite/utils" | ||
| import { pluginLocale } from './locale' | ||
@@ -189,3 +190,3 @@ class DefaultLayout extends _Data implements DataWithLife { | ||
| } else { | ||
| this.$exportMsg(`触发的${prop}模块不存在,请检查!`, 'error') | ||
| this.$exportMsg(pluginLocale.t('layout.moduleNotFound', { prop }), 'error') | ||
| } | ||
@@ -192,0 +193,0 @@ } |
+3
-2
| import { Wait } from "@complex-suite/utils" | ||
| import { pluginLocale } from "./locale" | ||
@@ -31,3 +32,3 @@ export type messageType = 'success' | 'error' | 'info' | 'warn' | ||
| notice: { | ||
| message: 'notice超时未定义,请确认是否初始化notice!', | ||
| message: pluginLocale.t('notice.timeout'), | ||
| offset: 5000 | ||
@@ -62,3 +63,3 @@ } | ||
| }, option.offset || 5000) | ||
| notice.confirm(option.content, debugLevel > targetDebugLevel ? '调试模式操作确认' : '开发模式操作确认', (act) => { | ||
| notice.confirm(option.content, debugLevel > targetDebugLevel ? pluginLocale.t('notice.debugConfirm') : pluginLocale.t('notice.devConfirm'), (act) => { | ||
| if (!isTimeout) { | ||
@@ -65,0 +66,0 @@ // 未超时则操作后取消定时器 |
21885
12.53%13
30%526
12.63%+ Added
- Removed
Updated