Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 65c6716

Browse files
committed
feat: uniform change of unsupported languages to English
1 parent 30c5c8c commit 65c6716

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

.eslintrc-auto-import.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
"DEFAULT_SHORTCUT_KEY": true,
88
"EffectScope": true,
99
"HOST_URL": true,
10-
"ImageCost": true,
10+
"IMAGE_COST": true,
1111
"InjectionKey": true,
1212
"Message": true,
1313
"NOOP": true,
1414
"OPEN_AI_MODEL": true,
1515
"PropType": true,
1616
"Ref": true,
17+
"SUPPORT_LANGUAGE": true,
1718
"VNode": true,
1819
"acceptHMRUpdate": true,
1920
"computed": true,

src/components/Function/components/TokenUsage.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const tokenExceed = computed(
1414
1515
watchEffect(async () => {
1616
if (currentSession.value?.type === 'image') {
17-
const size = imageParams.value.size as keyof typeof ImageCost
18-
const cost = ImageCost[size] * imageParams.value.number
17+
const size = imageParams.value.size as keyof typeof IMAGE_COST
18+
const cost = IMAGE_COST[size] * imageParams.value.number
1919
2020
tokenUsage.value =
2121
tokenUnit.value === 'TK' ? cost : Number((cost * 0.0002).toFixed(3))

src/components/Session/components/SessionAvatar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const calcToken = (data: SessionData) => {
6969
// // TODO 通过base64获得图片的大小
7070
// const size = calcImageSize(message.content[0].b64_json)
7171
// if (!size) return '0TK'
72-
// return `${num * ImageCost[size]}TK`
72+
// return `${num * IMAGE_COST[size]}TK`
7373
}
7474
}
7575
</script>

src/constants/shared.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export enum HOST_URL {
1212
GITHUB = 'https://api.github.com'
1313
}
1414

15-
export enum ImageCost {
15+
export enum IMAGE_COST {
1616
'256x256' = 8000,
1717
'512x512' = 9000,
1818
'1024x1024' = 10000
1919
}
20+
21+
export const SUPPORT_LANGUAGE = ['zh', 'en'] as const

src/stores/settings.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { register, unregisterAll } from '@tauri-apps/api/globalShortcut'
22
import { appWindow } from '@tauri-apps/api/window'
33
import { enable, disable } from 'tauri-plugin-autostart-api'
4+
import { invoke } from '@tauri-apps/api/tauri'
45
import { nanoid } from 'nanoid'
56
import type { ThemeMode, TokenUnit, Locales } from '@/types'
6-
import { invoke } from '@tauri-apps/api/tauri'
77

88
export const useSettingsStore = defineStore(
99
'settingsStore',
@@ -53,7 +53,7 @@ export const useSettingsStore = defineStore(
5353
const showTime = ref(false)
5454

5555
// 当前显示语言
56-
const currentLang = ref<string | undefined>()
56+
const currentLang = ref<Locales>()
5757
const { locale } = useI18n({ useScope: 'global' })
5858

5959
// 绑定快捷键
@@ -86,9 +86,13 @@ export const useSettingsStore = defineStore(
8686

8787
// 语言切换
8888
const setLanguage = async (lang?: Locales) => {
89-
const systemLang = ((await invoke('get_user_language')) as string).split(
89+
let systemLang = ((await invoke('get_user_language')) as string).split(
9090
'-'
91-
)[0] as string
91+
)[0] as Locales
92+
93+
if (!SUPPORT_LANGUAGE.includes(systemLang)) {
94+
systemLang = 'en'
95+
}
9296

9397
locale.value = lang || currentLang.value || systemLang
9498
}
@@ -137,7 +141,7 @@ export const useSettingsStore = defineStore(
137141

138142
// 监听语言更改
139143
watch(locale, (val) => {
140-
currentLang.value = val as string
144+
currentLang.value = val as Locales
141145
})
142146

143147
return {

src/types/shared.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export type SaveType = 'system' | 'image' | 'markdown'
66

77
export type TokenUnit = 'TK' | '¢'
88

9-
export type Locales = 'zh' | 'en'
9+
export type Locales = (typeof SUPPORT_LANGUAGE)[number]

0 commit comments

Comments
 (0)