mirror of
https://github.com/keven1024/015.git
synced 2026-06-04 11:29:36 +00:00
feat(front): enhance app configuration fetching and add localization support for "powered by" text
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
const useMyAppConfig = () => {
|
||||
const { data } = useFetch("/config");
|
||||
return data;
|
||||
};
|
||||
const { data } = useFetch<{
|
||||
data: {
|
||||
site_title: Record<string, string>
|
||||
site_desc: Record<string, string>
|
||||
site_url: string
|
||||
site_icon: string
|
||||
site_bg_url: string
|
||||
}
|
||||
}>('/api/config')
|
||||
return computed(() => data?.value?.data)
|
||||
}
|
||||
|
||||
export default useMyAppConfig;
|
||||
export default useMyAppConfig
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
"copySuccess": "Copy Success"
|
||||
},
|
||||
"about": {
|
||||
"powerBy": "Power by {0} as a open source temporary file sharing platform",
|
||||
"file": "File",
|
||||
"task": "Task",
|
||||
"admin": "Admin",
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
"copySuccess": "复制成功"
|
||||
},
|
||||
"about": {
|
||||
"powerBy": "由 {0} 驱动的开源自托管临时文件分享平台",
|
||||
"file": "文件",
|
||||
"task": "任务",
|
||||
"admin": "站长",
|
||||
|
||||
19
front/lib/renderI18n.ts
Normal file
19
front/lib/renderI18n.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const renderI18n = (json: Record<string, string>, defaultKey: string, locale?: string) => {
|
||||
const { locale: _locale } = useI18n()
|
||||
if (!json) return ''
|
||||
if (!locale) {
|
||||
locale = _locale.value
|
||||
}
|
||||
if (!json?.[locale]) {
|
||||
const [baseLocaleKey, subLocaleKey] = locale?.split('-') || []
|
||||
if (!baseLocaleKey || !subLocaleKey) {
|
||||
return json?.[defaultKey]
|
||||
}
|
||||
return renderI18n(json, defaultKey, baseLocaleKey)
|
||||
}
|
||||
return json?.[locale]
|
||||
}
|
||||
|
||||
export default renderI18n
|
||||
Reference in New Issue
Block a user