🐛 Fix(custom): fix i18n issue in cloud page

This commit is contained in:
Kuingsmile
2026-05-08 17:52:16 +08:00
parent c1b86a1dfe
commit a038969526
7 changed files with 1071 additions and 1072 deletions

View File

@@ -17,6 +17,7 @@
### 🐛 问题修复 ### 🐛 问题修复
- 修复了云端页面部分文字没有跟随语言设置进行改变的问题
- 修复了单图床重命名设置项在更新时,配置文件设置的值未正确更新的问题 - 修复了单图床重命名设置项在更新时,配置文件设置的值未正确更新的问题
- 修复了某些情况下重命名未生效的问题 - 修复了某些情况下重命名未生效的问题
- 修复了部分情况下,忽略软件更新选项未正确保存的问题 - 修复了部分情况下,忽略软件更新选项未正确保存的问题

View File

@@ -17,6 +17,7 @@
### 🐛 Bug Fixes ### 🐛 Bug Fixes
- Fixed an issue where some text on the cloud page did not change according to the language settings.
- Fixed an issue where the value set in the configuration file for the single image bed renaming setting was not correctly updated during updates. - Fixed an issue where the value set in the configuration file for the single image bed renaming setting was not correctly updated during updates.
- Fixed an issue where renaming did not take effect in certain cases. - Fixed an issue where renaming did not take effect in certain cases.
- Fixed an issue where the option to ignore software updates was not correctly saved in some cases. - Fixed an issue where the option to ignore software updates was not correctly saved in some cases.

View File

@@ -281,7 +281,7 @@ import useMessage from '@/hooks/useMessage'
import ManageEditPage from '@/manage/pages/ManageEditPage.vue' import ManageEditPage from '@/manage/pages/ManageEditPage.vue'
import { useManageStore } from '@/manage/store/manageStore' import { useManageStore } from '@/manage/store/manageStore'
import { formObjToTableData } from '@/manage/utils/common' import { formObjToTableData } from '@/manage/utils/common'
import { supportedPicBedList } from '@/manage/utils/constants' import { getSupportedPicBedList } from '@/manage/utils/constants'
import { getConfig, removeConfig, saveConfig } from '@/manage/utils/dataSender' import { getConfig, removeConfig, saveConfig } from '@/manage/utils/dataSender'
import { formatEndpoint } from '@/utils/common' import { formatEndpoint } from '@/utils/common'
import { configPaths } from '@/utils/configPaths' import { configPaths } from '@/utils/configPaths'
@@ -289,6 +289,7 @@ import { getConfig as getPicListConfig } from '@/utils/dataSender'
import { II18nLanguage, IRPCActionType } from '@/utils/enum' import { II18nLanguage, IRPCActionType } from '@/utils/enum'
const { t } = useI18n() const { t } = useI18n()
const supportedPicBedList = computed(() => getSupportedPicBedList(t))
const manageStore = useManageStore() const manageStore = useManageStore()
const router = useRouter() const router = useRouter()
const message = useMessage() const message = useMessage()
@@ -331,7 +332,7 @@ const tabItems = computed(() => {
iconComponent: FolderIcon, iconComponent: FolderIcon,
} }
const dynamicItems = Object.values(supportedPicBedList).map((item: any) => ({ const dynamicItems = Object.values(supportedPicBedList.value).map((item: any) => ({
key: item.icon, key: item.icon,
name: item.name, name: item.name,
icon: item.icon, icon: item.icon,

View File

@@ -159,7 +159,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { DownloadIcon, InfoIcon, LinkIcon, RotateCcwIcon, SaveIcon, XIcon } from 'lucide-vue-next' import { DownloadIcon, InfoIcon, LinkIcon, RotateCcwIcon, SaveIcon, XIcon } from 'lucide-vue-next'
import { onMounted, ref, watch } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import CustomButton from '@/components/common/CustomButton.vue' import CustomButton from '@/components/common/CustomButton.vue'
@@ -170,7 +170,7 @@ import SettingCard from '@/components/common/SettingCard.vue'
import SingleSelect from '@/components/common/SingleSelect.vue' import SingleSelect from '@/components/common/SingleSelect.vue'
import useMessage from '@/hooks/useMessage' import useMessage from '@/hooks/useMessage'
import { useManageStore } from '@/manage/store/manageStore' import { useManageStore } from '@/manage/store/manageStore'
import { supportedPicBedList } from '@/manage/utils/constants' import { getSupportedPicBedList } from '@/manage/utils/constants'
import { getConfig, saveConfig } from '@/manage/utils/dataSender' import { getConfig, saveConfig } from '@/manage/utils/dataSender'
import { formatEndpoint } from '@/utils/common' import { formatEndpoint } from '@/utils/common'
import { IRPCActionType } from '@/utils/enum' import { IRPCActionType } from '@/utils/enum'
@@ -184,6 +184,7 @@ const { aliasName, platformName } = defineProps<{
}>() }>()
const { t } = useI18n() const { t } = useI18n()
const supportedPicBedList = computed(() => getSupportedPicBedList(t))
const manageStore = useManageStore() const manageStore = useManageStore()
const message = useMessage() const message = useMessage()
const formErrors = ref<IStringKeyMap>({}) const formErrors = ref<IStringKeyMap>({})
@@ -201,7 +202,7 @@ watch(selectedAlias, newAlias => {
const handleReferenceClick = (url: string) => window.electron.sendRPC(IRPCActionType.OPEN_URL, url) const handleReferenceClick = (url: string) => window.electron.sendRPC(IRPCActionType.OPEN_URL, url)
const validateField = (picBedName: string, optionKey: string) => { const validateField = (picBedName: string, optionKey: string) => {
const configOption = supportedPicBedList[picBedName]?.configOptions?.[optionKey] const configOption = supportedPicBedList.value[picBedName]?.configOptions?.[optionKey]
const value = configResult.value[optionKey] const value = configResult.value[optionKey]
if (!configOption) return if (!configOption) return
@@ -263,7 +264,7 @@ async function handleConfigChange() {
} }
const aliasList = Object.values(existingConfiguration.value).map(item => item.alias) const aliasList = Object.values(existingConfiguration.value).map(item => item.alias)
const allKeys = Object.keys(supportedPicBedList[platformName].configOptions) const allKeys = Object.keys(supportedPicBedList.value[platformName].configOptions)
const resultMap: IStringKeyMap = {} const resultMap: IStringKeyMap = {}
if (aliasList.includes(configResult.value.alias) && aliasName !== configResult.value.alias) { if (aliasList.includes(configResult.value.alias) && aliasName !== configResult.value.alias) {
notifyUser(t('pages.manage.login.aliasExistMsg'), 'error') notifyUser(t('pages.manage.login.aliasExistMsg'), 'error')
@@ -277,11 +278,14 @@ async function handleConfigChange() {
} }
} }
if (supportedPicBedList[platformName].configOptions[key].default !== undefined && configResult.value[key] === '') { if (
resultMap[key] = supportedPicBedList[platformName].configOptions[key].default supportedPicBedList.value[platformName].configOptions[key].default !== undefined &&
configResult.value[key] === ''
) {
resultMap[key] = supportedPicBedList.value[platformName].configOptions[key].default
} else if (configResult.value[key] === undefined) { } else if (configResult.value[key] === undefined) {
if (supportedPicBedList[platformName].configOptions[key].default !== undefined) { if (supportedPicBedList.value[platformName].configOptions[key].default !== undefined) {
resultMap[key] = supportedPicBedList[platformName].configOptions[key].default resultMap[key] = supportedPicBedList.value[platformName].configOptions[key].default
} else { } else {
resultMap[key] = '' resultMap[key] = ''
} }
@@ -346,8 +350,8 @@ async function getExistingConfig(name: string) {
function handleConfigImport(alias: string) { function handleConfigImport(alias: string) {
if (alias === '') { if (alias === '') {
supportedPicBedList[platformName].options.forEach((option: any) => { supportedPicBedList.value[platformName].options.forEach((option: any) => {
const defaultValue = supportedPicBedList[platformName].configOptions[option].default const defaultValue = supportedPicBedList.value[platformName].configOptions[option].default
if (defaultValue !== undefined && option !== 'alias') { if (defaultValue !== undefined && option !== 'alias') {
configResult.value[option] = defaultValue configResult.value[option] = defaultValue
} }
@@ -357,7 +361,7 @@ function handleConfigImport(alias: string) {
const selectedConfig = existingConfiguration.value[alias] const selectedConfig = existingConfiguration.value[alias]
if (!selectedConfig) return if (!selectedConfig) return
supportedPicBedList[selectedConfig.picBedName].options.forEach((option: any) => { supportedPicBedList.value[selectedConfig.picBedName].options.forEach((option: any) => {
if (selectedConfig[option] !== undefined) { if (selectedConfig[option] !== undefined) {
configResult.value[option] = selectedConfig[option] configResult.value[option] = selectedConfig[option]
} }
@@ -365,7 +369,7 @@ function handleConfigImport(alias: string) {
} }
const validateAllFields = (picBedName: string): boolean => { const validateAllFields = (picBedName: string): boolean => {
const options = supportedPicBedList[picBedName]?.options || [] const options = supportedPicBedList.value[picBedName]?.options || []
let isValid = true let isValid = true
for (const option of options) { for (const option of options) {
@@ -393,11 +397,11 @@ const handleConfigReset = () => {
} }
const initializeDefaultValues = () => { const initializeDefaultValues = () => {
if (!supportedPicBedList[platformName]) return if (!supportedPicBedList.value[platformName]) return
const options = supportedPicBedList[platformName].options || [] const options = supportedPicBedList.value[platformName].options || []
for (const option of options) { for (const option of options) {
const configOption = supportedPicBedList[platformName].configOptions[option] const configOption = supportedPicBedList.value[platformName].configOptions[option]
if (configResult.value[option] === undefined || configResult.value[option] === '') { if (configResult.value[option] === undefined || configResult.value[option] === '') {
if (configOption.default !== undefined) { if (configOption.default !== undefined) {

View File

@@ -287,11 +287,12 @@ import BucketPage from '@/manage/pages/BucketPage.vue'
import EmptyPage from '@/manage/pages/EmptyPage.vue' import EmptyPage from '@/manage/pages/EmptyPage.vue'
import ManageSetting from '@/manage/pages/ManageSetting.vue' import ManageSetting from '@/manage/pages/ManageSetting.vue'
import { useManageStore } from '@/manage/store/manageStore' import { useManageStore } from '@/manage/store/manageStore'
import { supportedPicBedList } from '@/manage/utils/constants' import { getSupportedPicBedList } from '@/manage/utils/constants'
import { newBucketConfig } from '@/manage/utils/newBucketConfig' import { newBucketConfig } from '@/manage/utils/newBucketConfig'
import { IRPCActionType } from '@/utils/enum' import { IRPCActionType } from '@/utils/enum'
const { t } = useI18n() const { t } = useI18n()
const supportedPicBedList = computed(() => getSupportedPicBedList(t))
const manageStore = useManageStore() as any const manageStore = useManageStore() as any
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()

View File

@@ -1,23 +1,5 @@
import { createI18n } from 'vue-i18n' export function getSupportedPicBedList(t: (key: string, values?: Record<string, unknown>) => string): IStringKeyMap {
const defaultBaseRule = (name: string) => {
import en from '@/i18n/locales/en.json'
import zhCN from '@/i18n/locales/zh-CN.json'
import zhTW from '@/i18n/locales/zh-TW.json'
type MessageSchema = typeof en
const i18n = createI18n<MessageSchema, 'en' | 'zh-CN' | 'zh-TW'>({
legacy: false,
locale: localStorage.getItem('currentLanguage') || 'zh-CN',
fallbackLocale: 'zh-CN',
messages: {
en,
'zh-CN': zhCN,
'zh-TW': zhTW,
},
})
const { t } = i18n.global
const defaultBaseRule = (name: string) => {
return [ return [
{ {
required: true, required: true,
@@ -25,9 +7,9 @@ const defaultBaseRule = (name: string) => {
trigger: 'blur', trigger: 'blur',
}, },
] ]
} }
const itemsPerPageRule = [ const itemsPerPageRule = [
{ {
required: true, required: true,
message: t('pages.manage.constant.inputItemsPerPage'), message: t('pages.manage.constant.inputItemsPerPage'),
@@ -48,9 +30,9 @@ const itemsPerPageRule = [
}, },
trigger: 'change', trigger: 'change',
}, },
] ]
const aliasRule = [ const aliasRule = [
{ {
required: true, required: true,
message: t('pages.manage.constant.inputAlias'), message: t('pages.manage.constant.inputAlias'),
@@ -67,16 +49,16 @@ const aliasRule = [
}, },
trigger: 'change', trigger: 'change',
}, },
] ]
const aliasTooltip = t('pages.manage.constant.aliasTip') const aliasTooltip = t('pages.manage.constant.aliasTip')
const itemsPerPageTooltip = t('pages.manage.constant.itemsPPTip') const itemsPerPageTooltip = t('pages.manage.constant.itemsPPTip')
const pagingTooltip = t('pages.manage.constant.pagingTip') const pagingTooltip = t('pages.manage.constant.pagingTip')
const bucketNameTooltip = t('pages.manage.constant.bucketNameTip') const bucketNameTooltip = t('pages.manage.constant.bucketNameTip')
const baseDirTooltip = t('pages.manage.constant.baseDirTip') const baseDirTooltip = t('pages.manage.constant.baseDirTip')
const isAutoCustomUrlTooltip = t('pages.manage.constant.isAutoCustomUrlTip') const isAutoCustomUrlTooltip = t('pages.manage.constant.isAutoCustomUrlTip')
export const supportedPicBedList: IStringKeyMap = { return {
smms: { smms: {
name: 'S.EE', name: 'S.EE',
icon: 'smms', icon: 'smms',
@@ -176,7 +158,16 @@ export const supportedPicBedList: IStringKeyMap = {
}, },
}, },
explain: t('pages.manage.constant.explain'), explain: t('pages.manage.constant.explain'),
options: ['alias', 'accessKey', 'secretKey', 'bucketName', 'baseDir', 'isAutoCustomUrl', 'paging', 'itemsPerPage'], options: [
'alias',
'accessKey',
'secretKey',
'bucketName',
'baseDir',
'isAutoCustomUrl',
'paging',
'itemsPerPage',
],
refLink: 'https://piclist.cn/manage.html#%E4%B8%83%E7%89%9B%E4%BA%91', refLink: 'https://piclist.cn/manage.html#%E4%B8%83%E7%89%9B%E4%BA%91',
referenceText: t('pages.manage.constant.referText'), referenceText: t('pages.manage.constant.referText'),
}, },
@@ -1094,4 +1085,5 @@ export const supportedPicBedList: IStringKeyMap = {
refLink: 'https://piclist.cn/manage.html#sftp', refLink: 'https://piclist.cn/manage.html#sftp',
referenceText: t('pages.manage.constant.referText'), referenceText: t('pages.manage.constant.referText'),
}, },
}
} }

View File

@@ -320,7 +320,6 @@ interface IQiniuConfig {
interface ISMMSConfig { interface ISMMSConfig {
token: string token: string
backupDomain?: string
} }
interface ITcYunConfig { interface ITcYunConfig {