rayyy-vue-table-components 2.0.21 → 2.0.22

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.
@@ -6,7 +6,7 @@ export declare function setLocale(locale: string): void;
6
6
  /**
7
7
  * 全域 i18n 實例(用於非組件環境)
8
8
  */
9
- export declare function useI18n(): Composer<{}, {}, {}, string, never, string>;
9
+ export declare function useI18n(): Composer;
10
10
  /**
11
11
  * 組件庫內部使用的 Element Plus locale composable
12
12
  * 專門用於組件庫內部的 Element Plus 組件
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayyy-vue-table-components",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "description": "Vue 3 + Element Plus 表格組件庫",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { toRefs, computed, watch } from 'vue'
2
+ import { toRefs, computed } from 'vue'
3
3
  import type { Pager } from '@/types'
4
4
  import { MainPanel, SearchBar } from '@/components'
5
5
  import { useComponentElementLocale } from '@/utils/i18n'
@@ -58,26 +58,14 @@ const showPager = computed(() => {
58
58
  // 在 computed 外部調用,保持引用穩定
59
59
  const fallbackLocale = useComponentElementLocale()
60
60
 
61
- // 監聽 fallbackLocale 的變化
62
- watch(fallbackLocale, (newLocale, oldLocale) => {
63
- console.log('🔄 [SearchableListPanel] fallbackLocale 變化:', {
64
- old: oldLocale?.name,
65
- new: newLocale?.name
66
- })
67
- }, { immediate: true })
68
-
69
61
  // 優先使用 prop,沒有 prop 則使用 composable
70
62
  const elementLocale = computed(() => {
71
- console.log('🔍 [SearchableListPanel] elementLocale computed 執行')
72
-
73
63
  // 檢查 props.locale 是否為真正的 Language 對象(不是預設值)
74
64
  if (props.locale && typeof props.locale === 'object' && 'name' in props.locale) {
75
- console.log('🔍 [SearchableListPanel] 使用 props.locale:', props.locale.name)
76
65
  return props.locale
77
66
  }
78
67
 
79
- console.log('🔍 [SearchableListPanel] 使用 fallbackLocale:', fallbackLocale.value.name)
80
- // 現在能正確追蹤響應式
68
+ // 使用 fallbackLocale
81
69
  return fallbackLocale.value
82
70
  })
83
71
  </script>
package/src/utils/i18n.ts CHANGED
@@ -41,11 +41,8 @@ export function setLocale(locale: string): void {
41
41
  * 全域 i18n 實例(用於非組件環境)
42
42
  */
43
43
  export function useI18n() {
44
- console.log('🔍 [useI18n] 開始執行')
45
44
  const i18n = getInternalI18n()
46
- const global = i18n.global as Composer
47
- console.log('🔍 [useI18n] 返回內部 i18n,locale:', global.locale.value)
48
- return global
45
+ return i18n.global as Composer
49
46
  }
50
47
 
51
48
  /**
@@ -53,42 +50,8 @@ export function useI18n() {
53
50
  * 專門用於組件庫內部的 Element Plus 組件
54
51
  */
55
52
  export function useComponentElementLocale() {
56
- console.log('🔍 [useComponentElementLocale] 開始執行')
57
-
58
- return computed(() => {
59
- console.log('🔍 [useComponentElementLocale] computed 開始執行')
60
-
61
- // 在 computed 內部嘗試獲取外部 i18n(確保響應式)
62
- const instance = getCurrentInstance()
63
- let externalLocale: any = undefined
64
-
65
- try {
66
- console.log('🔍 [useComponentElementLocale] 嘗試獲取外部 i18n')
67
- const globalProperties = instance?.appContext.config.globalProperties
68
- const externalI18nInstance = globalProperties?.$i18n as I18n | undefined
69
-
70
- if (externalI18nInstance && 'global' in externalI18nInstance) {
71
- externalLocale = externalI18nInstance.global.locale
72
- console.log('🔍 [useComponentElementLocale] 成功獲取外部 locale:', externalLocale.value)
73
- } else {
74
- console.log('🔍 [useComponentElementLocale] 外部 i18n 不存在')
75
- }
76
- } catch (e) {
77
- console.log('❌ [useComponentElementLocale] 獲取外部 i18n 失敗:', e)
78
- }
79
-
80
- // 獲取內部 i18n(回退)
81
- const { locale: internalLocale } = useI18n()
82
- console.log('🔍 [useComponentElementLocale] 內部 locale:', internalLocale.value)
83
-
84
- // 決定使用哪個 locale
85
- const currentLocale = externalLocale || internalLocale
86
- console.log('🔍 [useComponentElementLocale] 最終使用 locale:', currentLocale.value)
87
-
88
- const result = currentLocale.value === 'zh-TW' ? zhTw : enUs
89
- console.log('🔍 [useComponentElementLocale] 返回結果:', result.name)
90
- return result
91
- })
53
+ // 直接返回預設中文
54
+ return computed(() => zhTw)
92
55
  }
93
56
 
94
57
  // 導出類型