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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayyy-vue-table-components",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "Vue 3 + Element Plus 表格組件庫",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
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
- // 嘗試取得外部專案的 i18n(支援 Composition API 模式)
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
- // 如果存在外部 i18n,優先使用外部的,否則使用內部的
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
- // 嘗試取得外部專案的 i18n(支援 Composition API 模式)
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
- // 如果存在外部 i18n,優先使用外部的,否則使用內部的
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
  }