rayyy-vue-table-components 1.3.21 → 1.3.23
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 +9708 -9679
- package/dist/index.umd.js +29 -29
- package/dist/rayyy-vue-table-components.css +1 -1
- package/dist/src/components/items/BaseWaringDialog.vue.d.ts +1 -4
- package/dist/src/index.d.ts +1 -1
- package/dist/src/plugins/i18n.d.ts +166 -0
- package/dist/src/utils/languageSwitcher.d.ts +9 -0
- package/package.json +1 -1
- package/src/components/items/BaseWaringDialog.vue +10 -13
- package/src/components/items/SearchBar.vue +4 -1
- package/src/components/layout/DetailLayout.vue +6 -3
- package/src/components/layout/FilterLayout.vue +5 -2
- package/src/components/tables/BaseTable.vue +6 -3
- package/src/utils/languageSwitcher.ts +35 -2
|
@@ -20,10 +20,7 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
|
|
|
20
20
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
21
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
22
22
|
"onUpdate:submit"?: (() => any) | undefined;
|
|
23
|
-
}>, {
|
|
24
|
-
waringText: string;
|
|
25
|
-
titleText: string;
|
|
26
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
27
24
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
28
25
|
export default _default;
|
|
29
26
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { default as TitleTable } from './components/tables/TitleTable.vue';
|
|
|
8
8
|
import { default as SearchBar } from './components/items/SearchBar.vue';
|
|
9
9
|
export * from './types';
|
|
10
10
|
export * from './utils/tableHelper';
|
|
11
|
-
export { switchLanguage, getCurrentLocale, availableLocales, getLanguageName, initLanguageSwitcher, configureLanguageSwitcher, type LocaleCode, type LanguageConfig, type ExternalI18nHandler } from './utils/languageSwitcher';
|
|
11
|
+
export { switchLanguage, getCurrentLocale, availableLocales, getLanguageName, getLocaleConfig, getCurrentLocaleConfig, initLanguageSwitcher, configureLanguageSwitcher, type LocaleCode, type LocaleConfig, type LanguageConfig, type ExternalI18nHandler } from './utils/languageSwitcher';
|
|
12
12
|
export { BaseTable, BaseBtn, BaseInput, BaseDialog, SortTable, TitleTable, SearchBar };
|
|
13
13
|
export type { BaseTableProps, BaseTableEmits, BaseTableInstance, BaseBtnProps, BaseBtnEmits, BaseBtnInstance, BaseDialogProps, BaseDialogEmits, BaseDialogInstance, PluginOptions, VueTableComponentsPlugin, } from './types/components';
|
|
14
14
|
export * from './components';
|
|
@@ -1,3 +1,85 @@
|
|
|
1
|
+
export declare const localeConfig: {
|
|
2
|
+
'zh-TW': {
|
|
3
|
+
name: string;
|
|
4
|
+
messages: {
|
|
5
|
+
"common.select": string;
|
|
6
|
+
"common.confirm": string;
|
|
7
|
+
"common.cancel": string;
|
|
8
|
+
"dialog.confirmRemoveUser": string;
|
|
9
|
+
"common.warning": string;
|
|
10
|
+
"search.placeholder": string;
|
|
11
|
+
"common.execute": string;
|
|
12
|
+
"common.reset": string;
|
|
13
|
+
"common.loading": string;
|
|
14
|
+
"common.view": string;
|
|
15
|
+
"common.edit": string;
|
|
16
|
+
"common.column": string;
|
|
17
|
+
"common.back": string;
|
|
18
|
+
"demo.componentDemo": string;
|
|
19
|
+
"button.title": string;
|
|
20
|
+
"button.primary ": string;
|
|
21
|
+
"button.default": string;
|
|
22
|
+
"button.danger": string;
|
|
23
|
+
"button.success": string;
|
|
24
|
+
"button.warning": string;
|
|
25
|
+
"button.info": string;
|
|
26
|
+
"button.style": string;
|
|
27
|
+
"button.size": string;
|
|
28
|
+
"button.small": string;
|
|
29
|
+
"button.medium": string;
|
|
30
|
+
"button.large ": string;
|
|
31
|
+
"status.title": string;
|
|
32
|
+
"status.normal ": string;
|
|
33
|
+
"status.loading": string;
|
|
34
|
+
"status.disabled": string;
|
|
35
|
+
"button.withIcon ": string;
|
|
36
|
+
"button.add": string;
|
|
37
|
+
"button.delete": string;
|
|
38
|
+
"common.save": string;
|
|
39
|
+
"common.discard": string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
'en-US': {
|
|
43
|
+
name: string;
|
|
44
|
+
messages: {
|
|
45
|
+
"common.select": string;
|
|
46
|
+
"common.confirm": string;
|
|
47
|
+
"common.cancel": string;
|
|
48
|
+
"dialog.confirmRemoveUser": string;
|
|
49
|
+
"common.warning": string;
|
|
50
|
+
"search.placeholder": string;
|
|
51
|
+
"common.execute": string;
|
|
52
|
+
"common.reset": string;
|
|
53
|
+
"common.loading": string;
|
|
54
|
+
"common.view": string;
|
|
55
|
+
"common.edit": string;
|
|
56
|
+
"common.column": string;
|
|
57
|
+
"common.back": string;
|
|
58
|
+
"demo.componentDemo": string;
|
|
59
|
+
"button.title": string;
|
|
60
|
+
"button.primary ": string;
|
|
61
|
+
"button.default": string;
|
|
62
|
+
"button.danger": string;
|
|
63
|
+
"button.success": string;
|
|
64
|
+
"button.warning": string;
|
|
65
|
+
"button.info": string;
|
|
66
|
+
"button.style": string;
|
|
67
|
+
"button.size": string;
|
|
68
|
+
"button.small": string;
|
|
69
|
+
"button.medium": string;
|
|
70
|
+
"button.large ": string;
|
|
71
|
+
"status.title": string;
|
|
72
|
+
"status.normal ": string;
|
|
73
|
+
"status.loading": string;
|
|
74
|
+
"status.disabled": string;
|
|
75
|
+
"button.withIcon ": string;
|
|
76
|
+
"button.add": string;
|
|
77
|
+
"button.delete": string;
|
|
78
|
+
"common.save": string;
|
|
79
|
+
"common.discard": string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
1
83
|
export declare const i18n: import('vue-i18n').I18n<{
|
|
2
84
|
'zh-TW': {
|
|
3
85
|
"common.select": string;
|
|
@@ -33,6 +115,8 @@ export declare const i18n: import('vue-i18n').I18n<{
|
|
|
33
115
|
"button.withIcon ": string;
|
|
34
116
|
"button.add": string;
|
|
35
117
|
"button.delete": string;
|
|
118
|
+
"common.save": string;
|
|
119
|
+
"common.discard": string;
|
|
36
120
|
};
|
|
37
121
|
'en-US': {
|
|
38
122
|
"common.select": string;
|
|
@@ -68,12 +152,94 @@ export declare const i18n: import('vue-i18n').I18n<{
|
|
|
68
152
|
"button.withIcon ": string;
|
|
69
153
|
"button.add": string;
|
|
70
154
|
"button.delete": string;
|
|
155
|
+
"common.save": string;
|
|
156
|
+
"common.discard": string;
|
|
71
157
|
};
|
|
72
158
|
}, {}, {}, string, false>;
|
|
73
159
|
export declare const switchLanguage: (locale: "zh-TW" | "en-US") => void;
|
|
74
160
|
export declare const getCurrentLocale: () => "zh-TW" | "en-US";
|
|
161
|
+
export declare const getCurrentLocaleConfig: () => {
|
|
162
|
+
name: string;
|
|
163
|
+
messages: {
|
|
164
|
+
"common.select": string;
|
|
165
|
+
"common.confirm": string;
|
|
166
|
+
"common.cancel": string;
|
|
167
|
+
"dialog.confirmRemoveUser": string;
|
|
168
|
+
"common.warning": string;
|
|
169
|
+
"search.placeholder": string;
|
|
170
|
+
"common.execute": string;
|
|
171
|
+
"common.reset": string;
|
|
172
|
+
"common.loading": string;
|
|
173
|
+
"common.view": string;
|
|
174
|
+
"common.edit": string;
|
|
175
|
+
"common.column": string;
|
|
176
|
+
"common.back": string;
|
|
177
|
+
"demo.componentDemo": string;
|
|
178
|
+
"button.title": string;
|
|
179
|
+
"button.primary ": string;
|
|
180
|
+
"button.default": string;
|
|
181
|
+
"button.danger": string;
|
|
182
|
+
"button.success": string;
|
|
183
|
+
"button.warning": string;
|
|
184
|
+
"button.info": string;
|
|
185
|
+
"button.style": string;
|
|
186
|
+
"button.size": string;
|
|
187
|
+
"button.small": string;
|
|
188
|
+
"button.medium": string;
|
|
189
|
+
"button.large ": string;
|
|
190
|
+
"status.title": string;
|
|
191
|
+
"status.normal ": string;
|
|
192
|
+
"status.loading": string;
|
|
193
|
+
"status.disabled": string;
|
|
194
|
+
"button.withIcon ": string;
|
|
195
|
+
"button.add": string;
|
|
196
|
+
"button.delete": string;
|
|
197
|
+
"common.save": string;
|
|
198
|
+
"common.discard": string;
|
|
199
|
+
};
|
|
200
|
+
} | {
|
|
201
|
+
name: string;
|
|
202
|
+
messages: {
|
|
203
|
+
"common.select": string;
|
|
204
|
+
"common.confirm": string;
|
|
205
|
+
"common.cancel": string;
|
|
206
|
+
"dialog.confirmRemoveUser": string;
|
|
207
|
+
"common.warning": string;
|
|
208
|
+
"search.placeholder": string;
|
|
209
|
+
"common.execute": string;
|
|
210
|
+
"common.reset": string;
|
|
211
|
+
"common.loading": string;
|
|
212
|
+
"common.view": string;
|
|
213
|
+
"common.edit": string;
|
|
214
|
+
"common.column": string;
|
|
215
|
+
"common.back": string;
|
|
216
|
+
"demo.componentDemo": string;
|
|
217
|
+
"button.title": string;
|
|
218
|
+
"button.primary ": string;
|
|
219
|
+
"button.default": string;
|
|
220
|
+
"button.danger": string;
|
|
221
|
+
"button.success": string;
|
|
222
|
+
"button.warning": string;
|
|
223
|
+
"button.info": string;
|
|
224
|
+
"button.style": string;
|
|
225
|
+
"button.size": string;
|
|
226
|
+
"button.small": string;
|
|
227
|
+
"button.medium": string;
|
|
228
|
+
"button.large ": string;
|
|
229
|
+
"status.title": string;
|
|
230
|
+
"status.normal ": string;
|
|
231
|
+
"status.loading": string;
|
|
232
|
+
"status.disabled": string;
|
|
233
|
+
"button.withIcon ": string;
|
|
234
|
+
"button.add": string;
|
|
235
|
+
"button.delete": string;
|
|
236
|
+
"common.save": string;
|
|
237
|
+
"common.discard": string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
75
240
|
export declare const availableLocales: {
|
|
76
241
|
value: string;
|
|
77
242
|
label: string;
|
|
78
243
|
}[];
|
|
244
|
+
export declare const getLanguageName: (locale: string) => string;
|
|
79
245
|
export declare const initLocale: () => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 語言切換工具
|
|
3
|
+
* 參考 Element Plus 的 i18n 處理方式
|
|
3
4
|
* 供外部專案使用的語言切換功能
|
|
4
5
|
*/
|
|
5
6
|
declare const defaultLocales: readonly [{
|
|
@@ -10,6 +11,10 @@ declare const defaultLocales: readonly [{
|
|
|
10
11
|
readonly label: "English";
|
|
11
12
|
}];
|
|
12
13
|
export type LocaleCode = typeof defaultLocales[number]['value'];
|
|
14
|
+
export interface LocaleConfig {
|
|
15
|
+
name: string;
|
|
16
|
+
messages: Record<string, any>;
|
|
17
|
+
}
|
|
13
18
|
export interface ExternalI18nHandler {
|
|
14
19
|
switchLanguage: (locale: string) => void;
|
|
15
20
|
getCurrentLocale: () => string;
|
|
@@ -18,6 +23,7 @@ export interface ExternalI18nHandler {
|
|
|
18
23
|
label: string;
|
|
19
24
|
}>;
|
|
20
25
|
getLanguageName?: (locale: string) => string;
|
|
26
|
+
getLocaleConfig?: (locale: string) => LocaleConfig;
|
|
21
27
|
}
|
|
22
28
|
export interface LanguageConfig {
|
|
23
29
|
locales: Array<{
|
|
@@ -27,6 +33,7 @@ export interface LanguageConfig {
|
|
|
27
33
|
defaultLocale: string;
|
|
28
34
|
storageKey?: string;
|
|
29
35
|
externalHandler?: ExternalI18nHandler;
|
|
36
|
+
localeConfigs?: Record<string, LocaleConfig>;
|
|
30
37
|
}
|
|
31
38
|
export declare const availableLocales: () => {
|
|
32
39
|
value: string;
|
|
@@ -36,5 +43,7 @@ export declare const configureLanguageSwitcher: (config: Partial<LanguageConfig>
|
|
|
36
43
|
export declare const switchLanguage: (locale: string) => void;
|
|
37
44
|
export declare const getCurrentLocale: () => string;
|
|
38
45
|
export declare const getLanguageName: (locale: string) => string;
|
|
46
|
+
export declare const getLocaleConfig: (locale: string) => LocaleConfig | undefined;
|
|
47
|
+
export declare const getCurrentLocaleConfig: () => LocaleConfig | undefined;
|
|
39
48
|
export declare const initLanguageSwitcher: () => string;
|
|
40
49
|
export {};
|
package/package.json
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
3
4
|
import BaseDialog from './BaseDialog.vue'
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
waringText: '請問是否確認移除該使用者',
|
|
15
|
-
titleText: '警告',
|
|
16
|
-
},
|
|
17
|
-
)
|
|
6
|
+
const { t } = useI18n()
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
modelValue: boolean
|
|
10
|
+
waringText?: string
|
|
11
|
+
subWaringText?: string
|
|
12
|
+
titleText?: string
|
|
13
|
+
modalWidth?: string
|
|
14
|
+
}>()
|
|
18
15
|
|
|
19
16
|
const emit = defineEmits<{
|
|
20
17
|
(e: 'update:modelValue', value: boolean): void
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { ref, useAttrs } from 'vue'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
3
4
|
import BaseInput from '../form/BaseInput.vue'
|
|
4
5
|
|
|
6
|
+
const { t } = useI18n()
|
|
7
|
+
|
|
5
8
|
defineProps<{
|
|
6
9
|
showSearch?: boolean
|
|
7
10
|
}>()
|
|
@@ -38,7 +41,7 @@ const resetFilter = () => {
|
|
|
38
41
|
<div v-if="showSearch" class="search-input">
|
|
39
42
|
<base-input
|
|
40
43
|
v-model="keyword"
|
|
41
|
-
placeholder="
|
|
44
|
+
:placeholder="t('search.placeholder')"
|
|
42
45
|
:show-word-limit="true"
|
|
43
46
|
@keydown.enter="doSearch"
|
|
44
47
|
@update:clearValue="clearableClick"
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
3
|
+
import { MainPanel, BaseBtn } from '@/components'
|
|
4
|
+
|
|
5
|
+
const { t } = useI18n()
|
|
3
6
|
|
|
4
7
|
defineProps<{
|
|
5
8
|
title: string
|
|
@@ -39,8 +42,8 @@ const handleBackClick = () => {
|
|
|
39
42
|
|
|
40
43
|
<template #footer>
|
|
41
44
|
<div class="border-t pt-4 w-full flex items-center justify-end" v-if="isEditable">
|
|
42
|
-
<BaseBtn text="
|
|
43
|
-
<BaseBtn text="
|
|
45
|
+
<BaseBtn :text="t('common.save')" type="primary" is-fill @click="saveDetailEdit" />
|
|
46
|
+
<BaseBtn :text="t('common.discard')" type="primary" @click="cancelDetailEdit" />
|
|
44
47
|
</div>
|
|
45
48
|
</template>
|
|
46
49
|
</MainPanel>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
2
3
|
import { MainPanel, BaseBtn } from '@/components'
|
|
3
4
|
|
|
5
|
+
const { t } = useI18n()
|
|
6
|
+
|
|
4
7
|
defineProps<{
|
|
5
8
|
mainTitle: string
|
|
6
9
|
showBack?: boolean | string | object
|
|
@@ -36,8 +39,8 @@ const handleBackClick = () => {
|
|
|
36
39
|
</template>
|
|
37
40
|
<template #footer>
|
|
38
41
|
<div class="submit-row">
|
|
39
|
-
<base-btn text="
|
|
40
|
-
<base-btn text="
|
|
42
|
+
<base-btn :text="t('common.execute')" is-fill type="primary" @click="doFilter" />
|
|
43
|
+
<base-btn :text="t('common.reset')" type="primary" @click="resetFilter" />
|
|
41
44
|
</div>
|
|
42
45
|
</template>
|
|
43
46
|
</MainPanel>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts" generic="T extends Record<string, unknown> = Record<string, unknown>">
|
|
2
2
|
import type { VNode } from 'vue'
|
|
3
3
|
import { computed } from 'vue'
|
|
4
|
+
import { useI18n } from 'vue-i18n'
|
|
4
5
|
import type { TableColumnCtx } from 'element-plus'
|
|
5
6
|
import type { SortChangValue, TableColumn } from '@/types'
|
|
6
7
|
|
|
8
|
+
const { t } = useI18n()
|
|
9
|
+
|
|
7
10
|
type Props<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
8
11
|
loading?: boolean
|
|
9
12
|
data: T[]
|
|
@@ -79,7 +82,7 @@ const operatorWidth = computed(() => {
|
|
|
79
82
|
<template>
|
|
80
83
|
<el-table
|
|
81
84
|
v-loading="loading"
|
|
82
|
-
element-loading-text="
|
|
85
|
+
:element-loading-text="t('common.loading')"
|
|
83
86
|
:data="data"
|
|
84
87
|
border
|
|
85
88
|
:show-summary="showSummary"
|
|
@@ -127,7 +130,7 @@ const operatorWidth = computed(() => {
|
|
|
127
130
|
@click="handleOperateClick(row, 'check')"
|
|
128
131
|
v-if="showCheckBtn"
|
|
129
132
|
>
|
|
130
|
-
|
|
133
|
+
{{ t('common.view') }}
|
|
131
134
|
</p>
|
|
132
135
|
<el-divider direction="vertical" class="!mx-2" v-if="showCheckBtn && showEditBtn" />
|
|
133
136
|
<p
|
|
@@ -135,7 +138,7 @@ const operatorWidth = computed(() => {
|
|
|
135
138
|
@click="handleOperateClick(row, 'edit')"
|
|
136
139
|
v-if="showEditBtn"
|
|
137
140
|
>
|
|
138
|
-
|
|
141
|
+
{{ t('common.edit') }}
|
|
139
142
|
</p>
|
|
140
143
|
</div>
|
|
141
144
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 語言切換工具
|
|
3
|
+
* 參考 Element Plus 的 i18n 處理方式
|
|
3
4
|
* 供外部專案使用的語言切換功能
|
|
4
5
|
*/
|
|
5
6
|
|
|
@@ -11,12 +12,19 @@ const defaultLocales = [
|
|
|
11
12
|
|
|
12
13
|
export type LocaleCode = typeof defaultLocales[number]['value']
|
|
13
14
|
|
|
15
|
+
// 語言配置接口(參考 Element Plus 的 locale 配置)
|
|
16
|
+
export interface LocaleConfig {
|
|
17
|
+
name: string
|
|
18
|
+
messages: Record<string, any>
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
// 外部 i18n 切換函數接口
|
|
15
22
|
export interface ExternalI18nHandler {
|
|
16
23
|
switchLanguage: (locale: string) => void
|
|
17
24
|
getCurrentLocale: () => string
|
|
18
25
|
availableLocales: () => Array<{ value: string; label: string }>
|
|
19
26
|
getLanguageName?: (locale: string) => string
|
|
27
|
+
getLocaleConfig?: (locale: string) => LocaleConfig
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
// 語言配置接口
|
|
@@ -25,6 +33,8 @@ export interface LanguageConfig {
|
|
|
25
33
|
defaultLocale: string
|
|
26
34
|
storageKey?: string
|
|
27
35
|
externalHandler?: ExternalI18nHandler
|
|
36
|
+
// 新增:語言配置映射
|
|
37
|
+
localeConfigs?: Record<string, LocaleConfig>
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
// 全域語言配置
|
|
@@ -71,7 +81,10 @@ export const switchLanguage = (locale: string) => {
|
|
|
71
81
|
|
|
72
82
|
// 觸發自定義事件,讓外部專案監聽
|
|
73
83
|
window.dispatchEvent(new CustomEvent('languageChanged', {
|
|
74
|
-
detail: {
|
|
84
|
+
detail: {
|
|
85
|
+
locale,
|
|
86
|
+
localeConfig: languageConfig.localeConfigs?.[locale]
|
|
87
|
+
}
|
|
75
88
|
}))
|
|
76
89
|
}
|
|
77
90
|
|
|
@@ -99,13 +112,33 @@ export const getLanguageName = (locale: string): string => {
|
|
|
99
112
|
return language?.label || languageConfig.locales[0]?.label || 'Unknown'
|
|
100
113
|
}
|
|
101
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
|
+
|
|
102
131
|
// 初始化語言設定(供外部專案調用)
|
|
103
132
|
export const initLanguageSwitcher = () => {
|
|
104
133
|
const currentLocale = getCurrentLocale()
|
|
134
|
+
const localeConfig = getCurrentLocaleConfig()
|
|
105
135
|
|
|
106
136
|
// 觸發初始化事件
|
|
107
137
|
window.dispatchEvent(new CustomEvent('languageInitialized', {
|
|
108
|
-
detail: {
|
|
138
|
+
detail: {
|
|
139
|
+
locale: currentLocale,
|
|
140
|
+
localeConfig
|
|
141
|
+
}
|
|
109
142
|
}))
|
|
110
143
|
|
|
111
144
|
return currentLocale
|