wui-components-v2 1.1.34 → 1.1.35
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/api/sys.ts +2 -2
- package/components/wui-menus1/components/quick-panel.vue +3 -2
- package/components/wui-menus1/components/section-menus.vue +3 -2
- package/components/wui-menus1/wui-menus.vue +6 -5
- package/components/wui-notify-info/wui-notify-info.vue +7 -6
- package/components/wui-system-settings/wui-system-settings.vue +1 -1
- package/composables/useLocale.ts +6 -7
- package/index.ts +2 -3
- package/package.json +1 -1
- package/store/language.ts +19 -16
package/api/sys.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { computed, defineOptions } from 'vue'
|
|
3
3
|
import { RainbowColorGenerator } from '../../../utils'
|
|
4
4
|
import { useSectionMenus } from '../../../composables/useSectionMenus'
|
|
5
|
-
import {useLanguageStore} from '../../../store/language'
|
|
5
|
+
import { useLanguageStore } from '../../../store/language'
|
|
6
|
+
|
|
6
7
|
defineOptions({
|
|
7
8
|
name: 'QuickPanel',
|
|
8
9
|
})
|
|
@@ -40,7 +41,7 @@ const cstatistics = computed(() => {
|
|
|
40
41
|
{{ item.count }}
|
|
41
42
|
</view>
|
|
42
43
|
<view class="text-size-3 color-gray">
|
|
43
|
-
{{
|
|
44
|
+
{{ languageStore.t(item.title) }}
|
|
44
45
|
</view>
|
|
45
46
|
</view>
|
|
46
47
|
</view>
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { computed, defineOptions } from 'vue'
|
|
3
3
|
import { useMenus } from '../../../composables/useMenus'
|
|
4
4
|
import { RainbowColorGenerator } from '../../../utils/index'
|
|
5
|
-
import {useLanguageStore} from '../../../store/language'
|
|
5
|
+
import { useLanguageStore } from '../../../store/language'
|
|
6
|
+
|
|
6
7
|
defineOptions({
|
|
7
8
|
name: 'SectionMenus',
|
|
8
9
|
})
|
|
@@ -50,7 +51,7 @@ const sectionmenuColor = computed(() => {
|
|
|
50
51
|
<text class="i-carbon:grid text-lg .dark:text-white .light:text-#FFF" />
|
|
51
52
|
</view>
|
|
52
53
|
<text class="recent-label .dark:text-white .light:text-#4b5563">
|
|
53
|
-
{{languageStore.t(
|
|
54
|
+
{{ languageStore.t(i.title) }}
|
|
54
55
|
</text>
|
|
55
56
|
</view>
|
|
56
57
|
</view>
|
|
@@ -5,12 +5,13 @@ import DemoCard from '../demo-card/demo-card.vue'
|
|
|
5
5
|
import { useMenus } from '../../composables/useMenus'
|
|
6
6
|
import type { Icon } from '../../composables/useMenus'
|
|
7
7
|
import wuiNotifyInfo from '../wui-notify-info/wui-notify-info.vue'
|
|
8
|
+
import { useLanguageStore } from '../../store/language'
|
|
8
9
|
import sectionMenus from './components/section-menus.vue'
|
|
9
10
|
import navbar from './components/navbar.vue'
|
|
10
11
|
import quickPanel from './components/quick-panel.vue'
|
|
11
12
|
import bannerCarousel from './components/banner-carousel.vue'
|
|
12
|
-
import searchBar from './components/search-bar.vue'
|
|
13
|
-
|
|
13
|
+
import searchBar from './components/search-bar.vue'
|
|
14
|
+
|
|
14
15
|
defineOptions({
|
|
15
16
|
name: 'WuiMenus1',
|
|
16
17
|
})
|
|
@@ -72,12 +73,12 @@ const {
|
|
|
72
73
|
<text class="i-carbon:apps text-sm" />
|
|
73
74
|
</view> -->
|
|
74
75
|
<text class="section-title .dark:text-white .light:color-#1f2937">
|
|
75
|
-
{{languageStore.t('全部功能')}}
|
|
76
|
+
{{ languageStore.t('全部功能') }}
|
|
76
77
|
</text>
|
|
77
78
|
</view>
|
|
78
79
|
<view class="section-tag">
|
|
79
80
|
<text class="tag-text">
|
|
80
|
-
{{ filtermenu.length }} {{languageStore.t('个分类')}}
|
|
81
|
+
{{ filtermenu.length }} {{ languageStore.t('个分类') }}
|
|
81
82
|
</text>
|
|
82
83
|
</view>
|
|
83
84
|
</view>
|
|
@@ -106,7 +107,7 @@ const {
|
|
|
106
107
|
<template #text>
|
|
107
108
|
<view class="menu-text-wrapper">
|
|
108
109
|
<view class="menu-title .dark:text-white .light:color-#1f2937">
|
|
109
|
-
{{languageStore.t(
|
|
110
|
+
{{ languageStore.t(subItem.title) }}
|
|
110
111
|
</view>
|
|
111
112
|
<!-- <view class="menu-badge" v-if="subIndex === 0">
|
|
112
113
|
<text class="badge-dot" />
|
|
@@ -5,7 +5,8 @@ import { listData, pageConfig, pageKey } from '../../api/page'
|
|
|
5
5
|
import { useSectionMenus } from '../../composables/useSectionMenus'
|
|
6
6
|
import { formatItemData } from '../../utils'
|
|
7
7
|
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
8
|
-
import {useLanguageStore} from '../../store/language'
|
|
8
|
+
import { useLanguageStore } from '../../store/language'
|
|
9
|
+
|
|
9
10
|
defineOptions({
|
|
10
11
|
name: 'WuiNotifyInfo',
|
|
11
12
|
})
|
|
@@ -141,9 +142,9 @@ function gotoDetailPage(item: any) {
|
|
|
141
142
|
|
|
142
143
|
<view v-for="notification in notifications" :key="notification.id" class="space-y-3">
|
|
143
144
|
<view class="mt-2 flex justify-between text-size-3 color-gray .dark:text-white">
|
|
144
|
-
<view>{{languageStore.t(notification.title)
|
|
145
|
+
<view>{{ languageStore.t(notification.title) }}</view>
|
|
145
146
|
<view @click="() => { gotoPage(notification) }">
|
|
146
|
-
{{
|
|
147
|
+
{{ languageStore.t('查看全部') }}
|
|
147
148
|
</view>
|
|
148
149
|
</view>
|
|
149
150
|
<button
|
|
@@ -163,13 +164,13 @@ function gotoDetailPage(item: any) {
|
|
|
163
164
|
<view class="min-w-0 flex-1">
|
|
164
165
|
<view class="flex justify-between gap-1">
|
|
165
166
|
<span class="text-sm text-slate-800 font-medium .dark:text-white">{{ formatItemData(item.primaryColumn, ControlTypeSupportor.getControlType(item.primaryColumnConfig)) }}</span>
|
|
166
|
-
<span class="text-xs text-slate-400 .dark:text-white
|
|
167
|
+
<span class="whitespace-nowrap text-xs text-slate-400 .dark:text-white">{{ formatItemData(item.primaryColumnLabel, ControlTypeSupportor.getControlType(item.primaryColumnLabelConfig)) }}</span>
|
|
167
168
|
</view>
|
|
168
169
|
<p class="line-clamp-2 mt-1 text-sm text-slate-500 .dark:text-white">
|
|
169
170
|
<text class="mr-1">
|
|
170
|
-
{{ formatItemData(item.secondColumn, ControlTypeSupportor.getControlType(item.secondColumnConfig||{})) }}
|
|
171
|
+
{{ formatItemData(item.secondColumn, ControlTypeSupportor.getControlType(item.secondColumnConfig || {})) }}
|
|
171
172
|
</text>
|
|
172
|
-
<text> {{ formatItemData(item.secondColumnLabel, ControlTypeSupportor.getControlType(item.secondColumnLabelConfig||{})) }}</text>
|
|
173
|
+
<text> {{ formatItemData(item.secondColumnLabel, ControlTypeSupportor.getControlType(item.secondColumnLabelConfig || {})) }}</text>
|
|
173
174
|
</p>
|
|
174
175
|
</view>
|
|
175
176
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, defineOptions } from 'vue'
|
|
3
3
|
import { useManualTheme } from '../../composables/useManualTheme'
|
|
4
|
-
import {useLanguageStore} from '../../store/language'
|
|
4
|
+
import { useLanguageStore } from '../../store/language'
|
|
5
5
|
import type { LocaleOption, ThemeColorOption } from '../../composables/useManualTheme'
|
|
6
6
|
import demoBlock from '../demo-block/demo-block.vue'
|
|
7
7
|
|
package/composables/useLocale.ts
CHANGED
|
@@ -8,7 +8,7 @@ import zhCN from 'wot-design-uni/locale/lang/zh-CN'
|
|
|
8
8
|
import arSA from 'wot-design-uni/locale/lang/ar-SA'
|
|
9
9
|
import { useManualThemeStore } from '../store/manualThemeStore'
|
|
10
10
|
|
|
11
|
-
import {useLanguageStore} from '../store/language'
|
|
11
|
+
import { useLanguageStore } from '../store/language'
|
|
12
12
|
/**
|
|
13
13
|
* 简化版系统语言切换组合式API
|
|
14
14
|
*
|
|
@@ -16,15 +16,14 @@ import {useLanguageStore} from '../store/language'
|
|
|
16
16
|
export function useLocale() {
|
|
17
17
|
const store = useManualThemeStore()
|
|
18
18
|
const languageStore = useLanguageStore()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
// 获取语言包
|
|
21
|
+
async function getLanguagePack(lang: string) {
|
|
22
22
|
await languageStore.loadLanguage(lang)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// 系统语言切换
|
|
26
|
-
function changeSystemLocale() {
|
|
27
|
-
|
|
26
|
+
function changeSystemLocale() {
|
|
28
27
|
switch (store.Locale.value) {
|
|
29
28
|
case 'en-US':
|
|
30
29
|
Locale.use('en-US', enUS)
|
|
@@ -32,7 +31,7 @@ export function useLocale() {
|
|
|
32
31
|
break
|
|
33
32
|
case 'ar-SA':
|
|
34
33
|
Locale.use('ar-SA', arSA)
|
|
35
|
-
|
|
34
|
+
|
|
36
35
|
break
|
|
37
36
|
default:
|
|
38
37
|
Locale.use('zh-CN', zhCN)
|
package/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { useManualTheme } from './composables/useManualTheme'
|
|
|
11
11
|
import { useGlobalLoading } from './composables/useGlobalLoading'
|
|
12
12
|
import { useGlobalMessage } from './composables/useGlobalMessage'
|
|
13
13
|
import { useGlobalToast } from './composables/useGlobalToast'
|
|
14
|
-
import {useLanguageStore} from './store/language'
|
|
14
|
+
import { useLanguageStore } from './store/language'
|
|
15
15
|
import { useUser } from './composables/useUser'
|
|
16
16
|
import { req } from './api/index'
|
|
17
17
|
import { useTabbar } from './composables/useTabbar'
|
|
@@ -27,7 +27,6 @@ import WuiAutoUpdateComponent from './components/wui-auto-update-component/wui-a
|
|
|
27
27
|
import iData from './utils/idata-scan'// PAD扫描
|
|
28
28
|
import wuiSearchHistoryBabbar from './components/wui-search-history-babbar/wui-search-history-babbar.vue'
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
// 组件列表
|
|
32
31
|
const coms: Array<{ name: string }> = [
|
|
33
32
|
WuiSystemSettings,
|
|
@@ -73,7 +72,7 @@ export {
|
|
|
73
72
|
persistPlugin,
|
|
74
73
|
iData, // PAD扫描
|
|
75
74
|
// nfc, // nfc读取
|
|
76
|
-
useLanguageStore
|
|
75
|
+
useLanguageStore, // 语言
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
export default install
|
package/package.json
CHANGED
package/store/language.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/core-components/store/language.ts
|
|
2
2
|
import { defineStore } from 'pinia'
|
|
3
|
-
import {
|
|
4
|
-
import {language} from '../api/sys'
|
|
3
|
+
import { computed, ref } from 'vue'
|
|
4
|
+
import { language } from '../api/sys'
|
|
5
5
|
// 定义语言包类型
|
|
6
6
|
type LanguagePackage = Record<string, string>
|
|
7
7
|
|
|
@@ -11,12 +11,12 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
11
11
|
const languagePackages = ref<Record<string, LanguagePackage>>({})
|
|
12
12
|
const loading = ref<boolean>(false)
|
|
13
13
|
const loadedLanguages = ref<string[]>([])
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
// 计算属性:当前语言包
|
|
16
16
|
const currentLangPack = computed<LanguagePackage>(() => {
|
|
17
17
|
return languagePackages.value[currentLanguage.value] || {}
|
|
18
18
|
})
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
// 计算属性:是否已加载当前语言
|
|
21
21
|
const isCurrentLanguageLoaded = computed<boolean>(() => {
|
|
22
22
|
return loadedLanguages.value.includes(currentLanguage.value)
|
|
@@ -28,15 +28,16 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
28
28
|
const loadLanguageFromNetwork = async (lang: string): Promise<LanguagePackage> => {
|
|
29
29
|
try {
|
|
30
30
|
// 调用API获取语言包,可根据实际API调整URL
|
|
31
|
-
const response= await language(lang)
|
|
32
|
-
|
|
33
|
-
if (response.status!==
|
|
31
|
+
const response = await language(lang)
|
|
32
|
+
|
|
33
|
+
if (response.status !== 'success') {
|
|
34
34
|
throw new Error(`Failed to fetch language package: ${response.status} ${response.statusText}`)
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
const data: LanguagePackage = response.value
|
|
38
38
|
return data
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
40
41
|
console.error(`Error loading language package for ${lang}:`, error)
|
|
41
42
|
// 返回空对象,避免程序崩溃
|
|
42
43
|
return {}
|
|
@@ -57,15 +58,16 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
57
58
|
loading.value = true
|
|
58
59
|
try {
|
|
59
60
|
const langPack = await loadLanguageFromNetwork(lang)
|
|
60
|
-
|
|
61
|
+
|
|
61
62
|
// 更新语言包数据
|
|
62
63
|
languagePackages.value[lang] = langPack
|
|
63
64
|
|
|
64
65
|
// loadedLanguages.value.push(lang)
|
|
65
|
-
|
|
66
|
+
|
|
66
67
|
// 设置当前语言
|
|
67
68
|
currentLanguage.value = lang
|
|
68
|
-
}
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
69
71
|
loading.value = false
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -84,7 +86,7 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
84
86
|
const preloadLanguages = async (languages: string[]): Promise<void> => {
|
|
85
87
|
const promises = languages.map(lang => loadLanguageFromNetwork(lang))
|
|
86
88
|
const results = await Promise.allSettled(promises)
|
|
87
|
-
|
|
89
|
+
|
|
88
90
|
results.forEach((result, index) => {
|
|
89
91
|
if (result.status === 'fulfilled') {
|
|
90
92
|
const lang = languages[index]
|
|
@@ -92,7 +94,8 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
92
94
|
if (!loadedLanguages.value.includes(lang)) {
|
|
93
95
|
loadedLanguages.value.push(lang)
|
|
94
96
|
}
|
|
95
|
-
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
96
99
|
console.error(`Failed to preload language ${languages[index]}:`, result.reason)
|
|
97
100
|
}
|
|
98
101
|
})
|
|
@@ -138,7 +141,7 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
138
141
|
loadedLanguages,
|
|
139
142
|
currentLangPack,
|
|
140
143
|
isCurrentLanguageLoaded,
|
|
141
|
-
|
|
144
|
+
|
|
142
145
|
// 方法
|
|
143
146
|
loadLanguage,
|
|
144
147
|
switchLanguage,
|
|
@@ -146,6 +149,6 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
146
149
|
preloadLanguages,
|
|
147
150
|
addLocalLanguage,
|
|
148
151
|
getLoadedLanguages,
|
|
149
|
-
getCurrentLanguage
|
|
152
|
+
getCurrentLanguage,
|
|
150
153
|
}
|
|
151
154
|
})
|