rayyy-vue-table-components 1.3.32 → 1.4.1
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.es.js +10402 -15109
- package/dist/index.umd.js +20 -41
- package/dist/rayyy-vue-table-components.css +1 -1
- package/dist/src/components/form/BaseMultipleInput.vue.d.ts +549 -0
- package/dist/src/components/index.d.ts +3 -2
- package/dist/src/components/items/BaseDialog.vue.d.ts +1 -0
- package/dist/src/components/items/BaseWaringDialog.vue.d.ts +4 -1
- package/dist/src/components/items/SearchBar.vue.d.ts +2 -0
- package/dist/src/components/layout/SearchableListPanel.vue.d.ts +4 -1
- package/dist/src/const/tableConst.d.ts +51 -0
- package/dist/src/index.d.ts +1 -12
- package/dist/src/router/constants.d.ts +2 -2
- package/dist/src/types/components.d.ts +6 -47
- package/dist/src/{components/LanguageSwitcher.vue.d.ts → views/demo/BaseMultipleInputDemo.vue.d.ts} +1 -1
- package/package.json +2 -6
- package/src/components/form/BaseMultipleInput.vue +112 -0
- package/src/components/form/BaseSelector.vue +62 -0
- package/src/components/index.ts +3 -2
- package/src/components/items/BaseDialog.vue +12 -11
- package/src/components/items/BaseWaringDialog.vue +13 -10
- package/src/components/items/SearchBar.vue +6 -4
- package/src/components/layout/DetailLayout.vue +4 -7
- package/src/components/layout/FilterLayout.vue +2 -5
- package/src/components/layout/FunctionHeader.vue +0 -1
- package/src/components/layout/SearchableListPanel.vue +16 -10
- package/src/components/tables/BaseTable.vue +3 -6
- package/src/components/tables/SortTable.vue +3 -2
- package/src/components/tables/TitleTable.vue +2 -1
- package/src/types/components.d.ts +6 -47
- package/dist/src/locales/en-US.json.d.ts +0 -39
- package/dist/src/locales/zh-TW.json.d.ts +0 -39
- package/dist/src/plugins/i18n.d.ts +0 -504
- package/dist/src/utils/languageSwitcher.d.ts +0 -49
- package/dist/src/views/demo/I18nDemo.vue.d.ts +0 -2
- package/src/components/LanguageSwitcher.vue +0 -53
- package/src/utils/languageSwitcher.ts +0 -145
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 語言切換工具
|
|
3
|
-
* 參考 Element Plus 的 i18n 處理方式
|
|
4
|
-
* 供外部專案使用的語言切換功能
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// 預設語言列表
|
|
8
|
-
const defaultLocales = [
|
|
9
|
-
{ value: 'zh-TW', label: '繁體中文' },
|
|
10
|
-
{ value: 'en-US', label: 'English' },
|
|
11
|
-
] as const
|
|
12
|
-
|
|
13
|
-
export type LocaleCode = typeof defaultLocales[number]['value']
|
|
14
|
-
|
|
15
|
-
// 語言配置接口(參考 Element Plus 的 locale 配置)
|
|
16
|
-
export interface LocaleConfig {
|
|
17
|
-
name: string
|
|
18
|
-
messages: Record<string, any>
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// 外部 i18n 切換函數接口
|
|
22
|
-
export interface ExternalI18nHandler {
|
|
23
|
-
switchLanguage: (locale: string) => void
|
|
24
|
-
getCurrentLocale: () => string
|
|
25
|
-
availableLocales: () => Array<{ value: string; label: string }>
|
|
26
|
-
getLanguageName?: (locale: string) => string
|
|
27
|
-
getLocaleConfig?: (locale: string) => LocaleConfig
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 語言配置接口
|
|
31
|
-
export interface LanguageConfig {
|
|
32
|
-
locales: Array<{ value: string; label: string }>
|
|
33
|
-
defaultLocale: string
|
|
34
|
-
storageKey?: string
|
|
35
|
-
externalHandler?: ExternalI18nHandler
|
|
36
|
-
// 新增:語言配置映射
|
|
37
|
-
localeConfigs?: Record<string, LocaleConfig>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 全域語言配置
|
|
41
|
-
let languageConfig: LanguageConfig = {
|
|
42
|
-
locales: [...defaultLocales],
|
|
43
|
-
defaultLocale: 'zh-TW',
|
|
44
|
-
storageKey: 'locale'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 可用的語言列表(動態)
|
|
48
|
-
export const availableLocales = () => {
|
|
49
|
-
// 如果有外部處理器,使用外部處理器
|
|
50
|
-
if (languageConfig.externalHandler) {
|
|
51
|
-
return languageConfig.externalHandler.availableLocales()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return languageConfig.locales
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 配置語言切換器
|
|
58
|
-
export const configureLanguageSwitcher = (config: Partial<LanguageConfig>) => {
|
|
59
|
-
languageConfig = {
|
|
60
|
-
...languageConfig,
|
|
61
|
-
...config
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 語言切換功能
|
|
66
|
-
export const switchLanguage = (locale: string) => {
|
|
67
|
-
// 如果有外部處理器,使用外部處理器
|
|
68
|
-
if (languageConfig.externalHandler) {
|
|
69
|
-
languageConfig.externalHandler.switchLanguage(locale)
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 檢查語言是否在配置中
|
|
74
|
-
if (!languageConfig.locales.some(l => l.value === locale)) {
|
|
75
|
-
console.warn(`Language ${locale} is not configured`)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 保存到 localStorage
|
|
80
|
-
localStorage.setItem(languageConfig.storageKey!, locale)
|
|
81
|
-
|
|
82
|
-
// 觸發自定義事件,讓外部專案監聽
|
|
83
|
-
window.dispatchEvent(new CustomEvent('languageChanged', {
|
|
84
|
-
detail: {
|
|
85
|
-
locale,
|
|
86
|
-
localeConfig: languageConfig.localeConfigs?.[locale]
|
|
87
|
-
}
|
|
88
|
-
}))
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 獲取當前語言
|
|
92
|
-
export const getCurrentLocale = (): string => {
|
|
93
|
-
// 如果有外部處理器,使用外部處理器
|
|
94
|
-
if (languageConfig.externalHandler) {
|
|
95
|
-
return languageConfig.externalHandler.getCurrentLocale()
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const savedLocale = localStorage.getItem(languageConfig.storageKey!)
|
|
99
|
-
return savedLocale && languageConfig.locales.some(l => l.value === savedLocale)
|
|
100
|
-
? savedLocale
|
|
101
|
-
: languageConfig.defaultLocale
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// 獲取語言顯示名稱
|
|
105
|
-
export const getLanguageName = (locale: string): string => {
|
|
106
|
-
// 如果有外部處理器且提供此功能
|
|
107
|
-
if (languageConfig.externalHandler?.getLanguageName) {
|
|
108
|
-
return languageConfig.externalHandler.getLanguageName(locale)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const language = languageConfig.locales.find(l => l.value === locale)
|
|
112
|
-
return language?.label || languageConfig.locales[0]?.label || 'Unknown'
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// 獲取語言配置(參考 Element Plus 的 locale 配置方式)
|
|
116
|
-
export const getLocaleConfig = (locale: string): LocaleConfig | undefined => {
|
|
117
|
-
// 如果有外部處理器且提供此功能
|
|
118
|
-
if (languageConfig.externalHandler?.getLocaleConfig) {
|
|
119
|
-
return languageConfig.externalHandler.getLocaleConfig(locale)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return languageConfig.localeConfigs?.[locale]
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// 獲取當前語言配置
|
|
126
|
-
export const getCurrentLocaleConfig = (): LocaleConfig | undefined => {
|
|
127
|
-
const currentLocale = getCurrentLocale()
|
|
128
|
-
return getLocaleConfig(currentLocale)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 初始化語言設定(供外部專案調用)
|
|
132
|
-
export const initLanguageSwitcher = () => {
|
|
133
|
-
const currentLocale = getCurrentLocale()
|
|
134
|
-
const localeConfig = getCurrentLocaleConfig()
|
|
135
|
-
|
|
136
|
-
// 觸發初始化事件
|
|
137
|
-
window.dispatchEvent(new CustomEvent('languageInitialized', {
|
|
138
|
-
detail: {
|
|
139
|
-
locale: currentLocale,
|
|
140
|
-
localeConfig
|
|
141
|
-
}
|
|
142
|
-
}))
|
|
143
|
-
|
|
144
|
-
return currentLocale
|
|
145
|
-
}
|