From ddaa02da3df148f06ce6ce73d0488495bca3f8b7 Mon Sep 17 00:00:00 2001 From: minglipro Date: Mon, 30 Jun 2025 10:10:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=AD=E8=A8=80=20language?= =?UTF-8?q?Schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- languageSchema.json | 43 ++++++++++++++++++++++++++++++++++ package.json | 1 + web-src/App.vue | 13 +++++++++- web-src/index.html | 2 +- web-src/language/index.json | 15 ++++++++++++ web-src/layout/Head.vue | 30 +++++++++++++++++++++--- web-src/layout/Router.vue | 15 +++++------- web-src/layout/index.vue | 14 ++++------- web-src/plugin/i18n/index.ts | 12 ++++++++++ web-src/plugin/index.ts | 6 +++++ web-src/plugin/router/index.ts | 27 +++++++++++++++++++++ web-src/plugin/stores/auth.ts | 5 +++- web-src/views/FileView.vue | 9 +++++++ web-src/views/HomeView.vue | 5 ++-- web-src/views/RegisterView.vue | 3 +++ web-src/views/UserView.vue | 19 +++++++++++++++ web-src/views/loginView.vue | 25 ++++++++++++++++++++ 17 files changed, 218 insertions(+), 26 deletions(-) create mode 100644 languageSchema.json create mode 100644 web-src/language/index.json create mode 100644 web-src/plugin/i18n/index.ts create mode 100644 web-src/views/FileView.vue create mode 100644 web-src/views/RegisterView.vue create mode 100644 web-src/views/UserView.vue create mode 100644 web-src/views/loginView.vue diff --git a/languageSchema.json b/languageSchema.json new file mode 100644 index 0000000..e9fbb25 --- /dev/null +++ b/languageSchema.json @@ -0,0 +1,43 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/language-config.schema.json", + "title": "Language Configuration", + "description": "Schema for validating language configuration files", + "type": "object", + "properties": { + "languages": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Display name of the language", + "pattern": "^[\\w\\s-]+$" + }, + "id": { + "type": "string", + "description": "Language identifier in locale format", + "pattern": "^[a-z]{2}-[a-z]{2}$" + }, + "file": { + "type": "string", + "description": "Language file name", + "pattern": "^[A-Z]{2}_[A-Z]{2}\\.json$" + } + }, + "required": [ + "title", + "id", + "file" + ], + "additionalProperties": false + } + } + }, + "required": [ + "languages" + ], + "additionalProperties": false +} diff --git a/package.json b/package.json index 6d98cd2..65b97bf 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "unplugin-auto-import": "^19.3.0", "unplugin-vue-components": "^28.8.0", "vue": "^3.5.17", + "vue-i18n": "12.0.0-alpha.2", "vue-router": "^4.5.1" }, "devDependencies": { diff --git a/web-src/App.vue b/web-src/App.vue index b221b97..5308a0f 100644 --- a/web-src/App.vue +++ b/web-src/App.vue @@ -1,7 +1,18 @@ diff --git a/web-src/index.html b/web-src/index.html index c36dbf2..36f74db 100644 --- a/web-src/index.html +++ b/web-src/index.html @@ -4,7 +4,7 @@ - Vite App + pan-disk
diff --git a/web-src/language/index.json b/web-src/language/index.json new file mode 100644 index 0000000..3bd57f5 --- /dev/null +++ b/web-src/language/index.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://git.mingliqiye.com/mingliqiye/pan-disk/raw/branch/master/languageSchema.json", + "languages": [ + { + "title": "中国-汉语", + "id": "zh-cn", + "file": "ZH_CN.json" + }, + { + "title": "US-English", + "id": "en-us", + "file": "EN_US.json" + } + ] +} diff --git a/web-src/layout/Head.vue b/web-src/layout/Head.vue index a3090cc..8e86e6c 100644 --- a/web-src/layout/Head.vue +++ b/web-src/layout/Head.vue @@ -19,12 +19,22 @@ 主页
-
+
文件
-
+
用户
@@ -68,7 +78,7 @@ diff --git a/web-src/layout/index.vue b/web-src/layout/index.vue index 05bc89d..9ad6965 100644 --- a/web-src/layout/index.vue +++ b/web-src/layout/index.vue @@ -1,15 +1,11 @@ diff --git a/web-src/plugin/i18n/index.ts b/web-src/plugin/i18n/index.ts new file mode 100644 index 0000000..7fbf85f --- /dev/null +++ b/web-src/plugin/i18n/index.ts @@ -0,0 +1,12 @@ +import { createI18n } from 'vue-i18n'; + +export type languageType = { [key: string]: string | languageType }; +const messages: languageType | any = {}; + +const i18n = createI18n({ + legacy: false, // 使用 Composition API + locale: 'zh', // 默认语言 + messages, +}); + +export default i18n; diff --git a/web-src/plugin/index.ts b/web-src/plugin/index.ts index 34433bc..1c8cedd 100644 --- a/web-src/plugin/index.ts +++ b/web-src/plugin/index.ts @@ -1,11 +1,17 @@ import type { MessageApiInjection } from 'naive-ui/es/message/src/MessageProvider'; +import type { LoadingBarApiInjection } from 'naive-ui/es/loading-bar/src/LoadingBarProvider'; export * from './router'; export * from './stores'; export * from './alova'; export let message: MessageApiInjection; +export let loadingBar: LoadingBarApiInjection; export function setMessage(messages: MessageApiInjection) { message = messages; } + +export function setLoadingBar(loadingBars: LoadingBarApiInjection) { + loadingBar = loadingBars; +} diff --git a/web-src/plugin/router/index.ts b/web-src/plugin/router/index.ts index b76a0d5..f408da5 100644 --- a/web-src/plugin/router/index.ts +++ b/web-src/plugin/router/index.ts @@ -1,4 +1,5 @@ import { createRouter, createWebHistory } from 'vue-router'; +import { loadingBar } from '@/plugin'; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -12,6 +13,26 @@ const router = createRouter({ name: 'home', component: () => import('@/views/HomeView.vue'), }, + { + path: '/file/:pathMatch(.*)*', + name: 'file', + component: () => import('@/views/FileView.vue'), + }, + { + path: '/user', + name: 'user', + component: () => import('@/views/UserView.vue'), + }, + { + path: '/login', + name: 'login', + component: () => import('@/views/loginView.vue'), + }, + { + path: '/register', + name: 'register', + component: () => import('@/views/RegisterView.vue'), + }, { path: '/swagger', name: 'api', @@ -22,4 +43,10 @@ const router = createRouter({ ], }); +router.beforeEach((to, from, next) => { + loadingBar.start(); + next(); + setTimeout(() => loadingBar.finish(), 100); +}); + export { router }; diff --git a/web-src/plugin/stores/auth.ts b/web-src/plugin/stores/auth.ts index 3001f24..3f0b015 100644 --- a/web-src/plugin/stores/auth.ts +++ b/web-src/plugin/stores/auth.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { login, woIsMe } from '@/api'; +import { login, logout, woIsMe } from '@/api'; import { LocalStorageApi } from '@/util'; export const UseAuthStore = defineStore('auth', { @@ -39,6 +39,9 @@ export const UseAuthStore = defineStore('auth', { }) .catch(() => this.$reset()); }, + logout() { + logout().then(() => this.$reset()); + }, }, persist: { storage: LocalStorageApi.StorageApi, diff --git a/web-src/views/FileView.vue b/web-src/views/FileView.vue new file mode 100644 index 0000000..e873f66 --- /dev/null +++ b/web-src/views/FileView.vue @@ -0,0 +1,9 @@ + + + diff --git a/web-src/views/HomeView.vue b/web-src/views/HomeView.vue index 886f3a1..9398b44 100644 --- a/web-src/views/HomeView.vue +++ b/web-src/views/HomeView.vue @@ -1,10 +1,11 @@ diff --git a/web-src/views/RegisterView.vue b/web-src/views/RegisterView.vue new file mode 100644 index 0000000..e6535e3 --- /dev/null +++ b/web-src/views/RegisterView.vue @@ -0,0 +1,3 @@ + + + diff --git a/web-src/views/UserView.vue b/web-src/views/UserView.vue new file mode 100644 index 0000000..67eefb7 --- /dev/null +++ b/web-src/views/UserView.vue @@ -0,0 +1,19 @@ + + + diff --git a/web-src/views/loginView.vue b/web-src/views/loginView.vue new file mode 100644 index 0000000..91d67c6 --- /dev/null +++ b/web-src/views/loginView.vue @@ -0,0 +1,25 @@ + + +