From 1012e9879d22f32fa460fa2f52d0628e0109d87a Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Wed, 23 Aug 2023 11:24:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E7=99=BB=E5=BD=95=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=87=8D=E6=96=B0=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.vue | 13 +++++++++++- frontend/src/locale/en-US/sys.ts | 1 + frontend/src/locale/zh-CN/sys.ts | 1 + frontend/src/store/modules/user/index.ts | 21 ++++++++++++++++++- .../components/addProjectModal.vue | 3 ++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index c7e967ffbf..5e02fe1dbb 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -6,7 +6,7 @@ diff --git a/frontend/src/locale/en-US/sys.ts b/frontend/src/locale/en-US/sys.ts index 7b51da253d..fc969a1c96 100644 --- a/frontend/src/locale/en-US/sys.ts +++ b/frontend/src/locale/en-US/sys.ts @@ -2,6 +2,7 @@ export default { // 消息提醒相关 'message.errorTip': 'Error Tip', 'message.logouting': 'Logging out...', + 'message.loginExpired': 'Login expired, please login again!', 'message.logoutSuccess': 'Logout success', 'message.loadingDefaultTip': 'Loading...', 'message.menuLoading': 'Loading the menu...', diff --git a/frontend/src/locale/zh-CN/sys.ts b/frontend/src/locale/zh-CN/sys.ts index 08859168b3..f2cf80442f 100644 --- a/frontend/src/locale/zh-CN/sys.ts +++ b/frontend/src/locale/zh-CN/sys.ts @@ -2,6 +2,7 @@ export default { // 消息提醒相关 'message.errorTip': '错误提示', 'message.logouting': '正在退出登录...', + 'message.loginExpired': '登录过期,请重新登录!', 'message.logoutSuccess': '登出成功', 'message.loadingDefaultTip': '加载中...', 'message.menuLoading': '菜单加载中...', diff --git a/frontend/src/store/modules/user/index.ts b/frontend/src/store/modules/user/index.ts index 012dafb9f3..4cd7d87268 100644 --- a/frontend/src/store/modules/user/index.ts +++ b/frontend/src/store/modules/user/index.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { login as userLogin, logout as userLogout } from '@/api/modules/user'; +import { login as userLogin, logout as userLogout, isLogin as userIsLogin } from '@/api/modules/user'; import { setToken, clearToken } from '@/utils/auth'; import { removeRouteListener } from '@/utils/route-listener'; import useAppStore from '../app'; @@ -8,6 +8,7 @@ import { useI18n } from '@/hooks/useI18n'; import type { LoginData } from '@/models/user'; import type { UserState } from './types'; +import { Message } from '@arco-design/web-vue'; const useUserStore = defineStore('user', { // 开启数据持久化 @@ -92,6 +93,24 @@ const useUserStore = defineStore('user', { this.logoutCallBack(); } }, + // 是否已经登录 + async isLogin() { + try { + const res = await userIsLogin(); + const appStore = useAppStore(); + setToken(res.sessionId, res.csrfToken); + this.setInfo(res); + if (appStore.currentOrgId === '') { + appStore.setCurrentOrgId(res.lastOrganizationId || ''); + } + return true; + } catch (err) { + const { t } = useI18n(); + Message.error(t('message.loginExpired')); + this.logoutCallBack(); + return false; + } + }, }, }); diff --git a/frontend/src/views/setting/system/organizationAndProject/components/addProjectModal.vue b/frontend/src/views/setting/system/organizationAndProject/components/addProjectModal.vue index 64a5f7fd03..ba00cb6ceb 100644 --- a/frontend/src/views/setting/system/organizationAndProject/components/addProjectModal.vue +++ b/frontend/src/views/setting/system/organizationAndProject/components/addProjectModal.vue @@ -37,6 +37,7 @@ :disabled="!isXpack" allow-search :options="affiliatedOrgOption" + :default-value="isXpack ? '' : 'default_organization'" :placeholder="t('system.project.affiliatedOrgPlaceholder')" :field-names="{ label: 'name', value: 'id' }" > @@ -103,7 +104,7 @@ const affiliatedOrgOption = ref([]); const licenseStore = useLicenseStore(); const moduleOption = [ - { label: 'menu.workplace', value: 'workstation' }, + { label: 'menu.workbench', value: 'workstation' }, { label: 'menu.testPlan', value: 'testPlan' }, { label: 'menu.bugManagement', value: 'bugManagement' }, { label: 'menu.featureTest', value: 'caseManagement' },