From 0b388aa26a45834a8108b82a4002adbb61147b1f Mon Sep 17 00:00:00 2001 From: GuoHao Date: Sun, 16 Jun 2024 13:06:44 +0800 Subject: [PATCH] feat: add About.vue (#572) --- CHANGELOG.MD | 1 + .../upload/AttachmentPondUpload.vue | 6 +- console/src/components/upload/UppyUpload.vue | 2 +- console/src/locales/en.yaml | 3 + console/src/locales/zh-CN.yaml | 3 + .../subject/SubjectRelationPostDialog.vue | 11 +- .../content/subject/SubjectSelectDrawer.vue | 6 +- console/src/modules/index.ts | 2 + console/src/modules/system/about/About.vue | 161 ++++++++++++++++++ console/src/modules/system/about/module.ts | 28 +++ console/src/modules/user/Login.vue | 2 - console/src/router/guards/auth-check.ts | 1 - console/src/stores/user.ts | 22 +-- console/src/utils/api-client.ts | 6 +- .../src/main/resources/application-dev.yaml | 4 +- 15 files changed, 232 insertions(+), 26 deletions(-) create mode 100644 console/src/modules/system/about/About.vue create mode 100644 console/src/modules/system/about/module.ts diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 3dbeb06d9..00686af8e 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -10,6 +10,7 @@ - 完善多语言翻译 #548 - 添加匹配移除条目剧集附件绑定 #554 - JWT令牌认证支持 #560 +- 后台添加关于页展示应用信息 #552 ## 插件 diff --git a/console/src/components/upload/AttachmentPondUpload.vue b/console/src/components/upload/AttachmentPondUpload.vue index 4b65a5f1b..5f0cf8893 100644 --- a/console/src/components/upload/AttachmentPondUpload.vue +++ b/console/src/components/upload/AttachmentPondUpload.vue @@ -82,20 +82,20 @@ const server = computed({ process: { url: './api/v1alpha1/attachment/fragment/unique', withCredentials: true, - headers: {'Authorization':'Bearer ' + userStore.jwtToken}, + headers: {Authorization: 'Bearer ' + userStore.jwtToken}, }, patch: { url: './api/v1alpha1/attachment/fragment/patch/', withCredentials: true, headers: { 'PARENT-ID': reqHeaderParendId.value, - 'Authorization':'Bearer ' + userStore.jwtToken + Authorization: 'Bearer ' + userStore.jwtToken, }, }, revert: { url: './api/v1alpha1/attachment/fragment/revert', withCredentials: true, - headers: {'Authorization':'Bearer ' + userStore.jwtToken}, + headers: {Authorization: 'Bearer ' + userStore.jwtToken}, }, }; }, diff --git a/console/src/components/upload/UppyUpload.vue b/console/src/components/upload/UppyUpload.vue index 2bb6d0046..4f86549e6 100644 --- a/console/src/components/upload/UppyUpload.vue +++ b/console/src/components/upload/UppyUpload.vue @@ -66,7 +66,7 @@ const uppy = computed(() => { }).use(XHRUpload, { endpoint: `${import.meta.env.VITE_API_URL}${props.endpoint}`, allowedMetaFields: props.allowedMetaFields, - headers: {'Authorization':'Bearer ' + userStore.jwtToken}, + headers: {Authorization: 'Bearer ' + userStore.jwtToken}, withCredentials: true, formData: true, fieldName: props.name, diff --git a/console/src/locales/en.yaml b/console/src/locales/en.yaml index 5b119324b..56e53dea9 100644 --- a/console/src/locales/en.yaml +++ b/console/src/locales/en.yaml @@ -947,6 +947,9 @@ module: password: SMTP Password alias: SMTP Account Alias receive-address: Recive Mail Address + about: + title: About + sidebar: About login: operations: submit: diff --git a/console/src/locales/zh-CN.yaml b/console/src/locales/zh-CN.yaml index fb9116846..e8ad3f86c 100644 --- a/console/src/locales/zh-CN.yaml +++ b/console/src/locales/zh-CN.yaml @@ -910,6 +910,9 @@ module: required: 请输入邮件服务密码 mail-receive-address: required: 请输入收件方邮件地址 + about: + title: 关于 + sidebar: 关于 login: operations: submit: diff --git a/console/src/modules/content/subject/SubjectRelationPostDialog.vue b/console/src/modules/content/subject/SubjectRelationPostDialog.vue index 392e81962..ae9f7728e 100644 --- a/console/src/modules/content/subject/SubjectRelationPostDialog.vue +++ b/console/src/modules/content/subject/SubjectRelationPostDialog.vue @@ -1,6 +1,15 @@ + + diff --git a/console/src/modules/system/about/module.ts b/console/src/modules/system/about/module.ts new file mode 100644 index 000000000..36b963da0 --- /dev/null +++ b/console/src/modules/system/about/module.ts @@ -0,0 +1,28 @@ +import {definePlugin} from '@runikaros/shared'; +import {markRaw} from 'vue'; +import {Ship} from '@element-plus/icons-vue'; +import About from './About.vue'; + +export default definePlugin({ + name: 'SystemAbout', + components: {}, + routes: [ + { + parentName: 'Root', + route: { + path: '/about', + name: 'About', + component: About, + meta: { + title: 'module.about.title', + menu: { + name: 'module.about.sidebar', + group: 'system', + icon: markRaw(Ship), + priority: 0, + }, + }, + }, + }, + ], +}); diff --git a/console/src/modules/user/Login.vue b/console/src/modules/user/Login.vue index 93d9ee6f3..a88c6b359 100644 --- a/console/src/modules/user/Login.vue +++ b/console/src/modules/user/Login.vue @@ -58,7 +58,6 @@ const handleLogin = async () => { await userStore.applyJwtToken(form.value.username, form.value.password); - // Reload page // if (route.query.redirect_uri) { // window.location.reload(); @@ -68,7 +67,6 @@ const handleLogin = async () => { if (!userStore.isAnonymous) { window.location.reload(); } - } catch (e: unknown) { console.error('Failed to login', e); diff --git a/console/src/router/guards/auth-check.ts b/console/src/router/guards/auth-check.ts index 3ed430198..f15f59fa4 100644 --- a/console/src/router/guards/auth-check.ts +++ b/console/src/router/guards/auth-check.ts @@ -19,7 +19,6 @@ export function setupAuthCheckGuard(router: Router) { next(); return; } - next({ name: 'Login', diff --git a/console/src/stores/user.ts b/console/src/stores/user.ts index aec28e35f..0d6e33bb4 100644 --- a/console/src/stores/user.ts +++ b/console/src/stores/user.ts @@ -1,14 +1,14 @@ import { defineStore } from 'pinia'; import type { User } from '@runikaros/api-client'; -import {JwtApplyParamAuthTypeEnum} from '@runikaros/api-client' +import {JwtApplyParamAuthTypeEnum} from '@runikaros/api-client'; import { apiClient, setApiClientJwtToken } from '@/utils/api-client'; interface UserStoreState { - authType: JwtApplyParamAuthTypeEnum, + authType: JwtApplyParamAuthTypeEnum; currentUser?: User; isAnonymous: boolean; - jwtToken?:string; + jwtToken?: string; } export const useUserStore = defineStore('user', { @@ -32,29 +32,29 @@ export const useUserStore = defineStore('user', { } else { this.jwtToken = undefined; this.isAnonymous = true; - } + } } catch (e) { console.error('Failed to fetch current user', e); this.isAnonymous = true; this.jwtToken = undefined; } }, - async applyJwtToken(username:string, password:string) { + async applyJwtToken(username: string, password: string) { try { - const {data, status} = await apiClient.security.applyJwtToken({ + const {data, status} = await apiClient.security.applyJwtToken({ jwtApplyParam: { authType: 'USERNAME_PASSWORD', username: username, - password: password - } - }) + password: password, + }, + }); if (status === 200) { this.jwtToken = data; this.isAnonymous = false; } else { this.jwtToken = undefined; this.isAnonymous = true; - } + } } catch (e) { console.error('Failed to apply jwt token', e); this.isAnonymous = true; @@ -64,7 +64,7 @@ export const useUserStore = defineStore('user', { this.jwtToken = undefined; this.isAnonymous = true; this.currentUser = undefined; - } + }, }, persist: { enabled: true, diff --git a/console/src/utils/api-client.ts b/console/src/utils/api-client.ts index c33607bc5..d762ae4fb 100644 --- a/console/src/utils/api-client.ts +++ b/console/src/utils/api-client.ts @@ -200,10 +200,10 @@ function setupApiClient(axios: AxiosInstance) { }; } -const setApiClientJwtToken = (token:string) => { +const setApiClientJwtToken = (token: string) => { // console.debug('setJwtToken', token) if (!token) return; axiosInstance.defaults.headers.common['Authorization'] = 'Bearer ' + token; -} +}; -export { apiClient,setApiClientJwtToken}; +export {apiClient, setApiClientJwtToken}; diff --git a/server/src/main/resources/application-dev.yaml b/server/src/main/resources/application-dev.yaml index b856163d3..35fb510fe 100644 --- a/server/src/main/resources/application-dev.yaml +++ b/server/src/main/resources/application-dev.yaml @@ -3,8 +3,8 @@ ikaros: plugin: runtime-mode: development fixed-plugin-path: -# - C:\Users\li-guohao\GitRepo\ikaros-dev\plugin-alist -# - C:\Users\li-guohao\GitRepo\ikaros-dev\plugin-bgmtv + # - C:\Users\li-guohao\GitRepo\ikaros-dev\plugin-alist + # - C:\Users\li-guohao\GitRepo\ikaros-dev\plugin-bgmtv # - C:\Develop\GitRepos\ikaros-dev\plugins\plugin-local-files-import # - C:\Develop\GitRepos\ikaros-dev\plugins\plugin-jellyfin # - C:\Develop\GitRepos\ikaros-dev\plugins\plugin-mikan