rayyy-vue-table-components 2.0.13 → 2.0.15
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/package.json +1 -1
- package/src/utils/i18n.ts +8 -8
package/package.json
CHANGED
package/src/utils/i18n.ts
CHANGED
|
@@ -93,7 +93,7 @@ export function useI18n() {
|
|
|
93
93
|
export function useElementLocale() {
|
|
94
94
|
const instance = getCurrentInstance()
|
|
95
95
|
|
|
96
|
-
//
|
|
96
|
+
// 在 computed 外部一次性獲取 i18n 引用
|
|
97
97
|
let externalI18n: Composer | undefined
|
|
98
98
|
try {
|
|
99
99
|
const globalProperties = instance?.appContext.config.globalProperties
|
|
@@ -112,12 +112,13 @@ export function useElementLocale() {
|
|
|
112
112
|
const internalI18nInstance = getInternalI18n()
|
|
113
113
|
const internalGlobal = internalI18nInstance.global as Composer
|
|
114
114
|
|
|
115
|
-
//
|
|
115
|
+
// 決定使用哪個 i18n(在 computed 外部決定)
|
|
116
116
|
const currentI18n = externalI18n || internalGlobal
|
|
117
117
|
|
|
118
118
|
// 返回響應式的 Element Plus locale
|
|
119
|
+
// 現在 Vue 可以正確追蹤 currentI18n.locale.value 的變化
|
|
119
120
|
return computed(() => {
|
|
120
|
-
const locale = currentI18n.locale.value
|
|
121
|
+
const locale = currentI18n.locale.value // ✅ Vue 可以追蹤!
|
|
121
122
|
return locale === 'zh-TW' ? zhTw : enUs
|
|
122
123
|
})
|
|
123
124
|
}
|
|
@@ -129,18 +130,16 @@ export function useElementLocale() {
|
|
|
129
130
|
export function useComponentElementLocale() {
|
|
130
131
|
const instance = getCurrentInstance()
|
|
131
132
|
|
|
132
|
-
//
|
|
133
|
+
// 在 computed 外部一次性獲取 i18n 引用
|
|
133
134
|
let externalI18n: Composer | undefined
|
|
134
135
|
try {
|
|
135
136
|
const globalProperties = instance?.appContext.config.globalProperties
|
|
136
137
|
const externalI18nInstance = globalProperties?.$i18n as I18n | undefined
|
|
137
138
|
|
|
138
|
-
// 如果是 I18n 實例,取得其 global 屬性
|
|
139
139
|
if (externalI18nInstance && 'global' in externalI18nInstance) {
|
|
140
140
|
externalI18n = externalI18nInstance.global as Composer
|
|
141
141
|
}
|
|
142
142
|
} catch (e) {
|
|
143
|
-
// 如果取得失敗,繼續使用內部 i18n
|
|
144
143
|
externalI18n = undefined
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -148,12 +147,13 @@ export function useComponentElementLocale() {
|
|
|
148
147
|
const internalI18nInstance = getInternalI18n()
|
|
149
148
|
const internalGlobal = internalI18nInstance.global as Composer
|
|
150
149
|
|
|
151
|
-
//
|
|
150
|
+
// 決定使用哪個 i18n(在 computed 外部決定)
|
|
152
151
|
const currentI18n = externalI18n || internalGlobal
|
|
153
152
|
|
|
154
153
|
// 返回響應式的 Element Plus locale
|
|
154
|
+
// 現在 Vue 可以正確追蹤 currentI18n.locale.value 的變化
|
|
155
155
|
return computed(() => {
|
|
156
|
-
const locale = currentI18n.locale.value
|
|
156
|
+
const locale = currentI18n.locale.value // ✅ Vue 可以追蹤!
|
|
157
157
|
return locale === 'zh-TW' ? zhTw : enUs
|
|
158
158
|
})
|
|
159
159
|
}
|