From 28525002f6df8092089e0802947d694757bbeb8b Mon Sep 17 00:00:00 2001 From: baiqi Date: Tue, 27 Jun 2023 09:58:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B6=E9=83=A8=E8=8F=9C=E5=8D=95&?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=80=89=E6=8B=A9=E5=99=A8&=E5=8F=B3?= =?UTF-8?q?=E4=B8=8A=E8=A7=92=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/modules/system/project.ts | 9 + frontend/src/api/modules/system/user.ts | 2 +- frontend/src/api/modules/system/usergroup.ts | 2 +- frontend/src/api/requrls/system/project.ts | 3 + .../api/requrls/{system.ts => system/user.ts} | 0 .../src/api/requrls/{ => system}/usergroup.ts | 0 .../src/components/pure/ms-top-menu/index.vue | 8 +- frontend/src/components/pure/navbar/index.vue | 243 ++++++++++++++---- frontend/src/locale/en-US/settings.ts | 9 +- frontend/src/locale/zh-CN/settings.ts | 7 + frontend/src/mock/index.ts | 1 + frontend/src/mock/system/project.ts | 60 +++++ frontend/src/models/system/project.ts | 16 ++ frontend/src/router/constants.ts | 9 + .../src/router/routes/modules/api-test.ts | 3 +- frontend/src/store/modules/app/index.ts | 30 ++- frontend/src/store/modules/app/types.ts | 2 + frontend/src/store/modules/user/index.ts | 6 +- 18 files changed, 347 insertions(+), 63 deletions(-) create mode 100644 frontend/src/api/modules/system/project.ts create mode 100644 frontend/src/api/requrls/system/project.ts rename frontend/src/api/requrls/{system.ts => system/user.ts} (100%) rename frontend/src/api/requrls/{ => system}/usergroup.ts (100%) create mode 100644 frontend/src/mock/system/project.ts create mode 100644 frontend/src/models/system/project.ts diff --git a/frontend/src/api/modules/system/project.ts b/frontend/src/api/modules/system/project.ts new file mode 100644 index 0000000000..31ee94fd2c --- /dev/null +++ b/frontend/src/api/modules/system/project.ts @@ -0,0 +1,9 @@ +import MSR from '@/api/http/index'; +import { ProjectListUrl } from '@/api/requrls/system/project'; +import type { ProjectListItem } from '@/models/system/project'; + +export function getProjectList(organizationId: string) { + return MSR.get({ url: `${ProjectListUrl}/${organizationId}` }); +} + +export default {}; diff --git a/frontend/src/api/modules/system/user.ts b/frontend/src/api/modules/system/user.ts index 6ae74852c4..dcdd26c5fb 100644 --- a/frontend/src/api/modules/system/user.ts +++ b/frontend/src/api/modules/system/user.ts @@ -1,5 +1,5 @@ import MSR from '@/api/http/index'; -import { GetUserListUrl, CreateUserUrl, UpdateUserUrl } from '@/api/requrls/system'; +import { GetUserListUrl, CreateUserUrl, UpdateUserUrl } from '@/api/requrls/system/user'; import type { UserListItem, CreateUserParams } from '@/models/system/user'; import type { TableQueryParams } from '@/models/common'; diff --git a/frontend/src/api/modules/system/usergroup.ts b/frontend/src/api/modules/system/usergroup.ts index f3179f7b51..77c8e998ad 100644 --- a/frontend/src/api/modules/system/usergroup.ts +++ b/frontend/src/api/modules/system/usergroup.ts @@ -1,5 +1,5 @@ import MSR from '@/api/http/index'; -import { updateUserGroupU, getUserGroupU, addUserGroupU, deleteUserGroupU } from '@/api/requrls/usergroup'; +import { updateUserGroupU, getUserGroupU, addUserGroupU, deleteUserGroupU } from '@/api/requrls/system/usergroup'; // import { QueryParams, CommonList } from '@/models/common'; import { UserGroupItem } from '@/components/bussiness/usergroup/type'; diff --git a/frontend/src/api/requrls/system/project.ts b/frontend/src/api/requrls/system/project.ts new file mode 100644 index 0000000000..15c761121a --- /dev/null +++ b/frontend/src/api/requrls/system/project.ts @@ -0,0 +1,3 @@ +export const ProjectListUrl = '/system/project/list'; + +export default {}; diff --git a/frontend/src/api/requrls/system.ts b/frontend/src/api/requrls/system/user.ts similarity index 100% rename from frontend/src/api/requrls/system.ts rename to frontend/src/api/requrls/system/user.ts diff --git a/frontend/src/api/requrls/usergroup.ts b/frontend/src/api/requrls/system/usergroup.ts similarity index 100% rename from frontend/src/api/requrls/usergroup.ts rename to frontend/src/api/requrls/system/usergroup.ts diff --git a/frontend/src/components/pure/ms-top-menu/index.vue b/frontend/src/components/pure/ms-top-menu/index.vue index a91b7ad5ac..544771c20b 100644 --- a/frontend/src/components/pure/ms-top-menu/index.vue +++ b/frontend/src/components/pure/ms-top-menu/index.vue @@ -3,7 +3,7 @@ v-if="appStore.topMenus.length > 0" class="bg-transparent" mode="horizontal" - :default-selected-keys="[appStore.topMenus[0].name]" + :default-selected-keys="[defaultActiveMenu]" > {{ t(menu.meta?.locale || '') }} @@ -12,6 +12,7 @@ diff --git a/frontend/src/locale/en-US/settings.ts b/frontend/src/locale/en-US/settings.ts index e23594c42d..8c8789e355 100644 --- a/frontend/src/locale/en-US/settings.ts +++ b/frontend/src/locale/en-US/settings.ts @@ -8,7 +8,14 @@ export default { 'settings.menuWidth': 'Menu Width (px)', 'settings.navbar.screen.toFull': 'Click to switch to full screen mode', 'settings.navbar.screen.toExit': 'Click to exit the full screen mode', - 'settings.navbar.alerts': 'alerts', + 'settings.navbar.alerts': 'Alerts', + 'settings.navbar.search': 'Search', + 'settings.navbar.task': 'Task center', + 'settings.navbar.help': 'Help center', + 'settings.help.guide': 'Use Guide', + 'settings.help.doc': 'Help docs', + 'settings.help.APIDoc': 'API docs', + 'settings.help.version': 'Version', 'settings.menu': 'Menu', 'settings.tabBar': 'Tab Bar', 'settings.footer': 'Footer', diff --git a/frontend/src/locale/zh-CN/settings.ts b/frontend/src/locale/zh-CN/settings.ts index 5adbaf7a04..1084ccd641 100644 --- a/frontend/src/locale/zh-CN/settings.ts +++ b/frontend/src/locale/zh-CN/settings.ts @@ -9,6 +9,13 @@ export default { 'settings.navbar.screen.toFull': '点击切换全屏模式', 'settings.navbar.screen.toExit': '点击退出全屏模式', 'settings.navbar.alerts': '消息通知', + 'settings.navbar.search': '搜索', + 'settings.navbar.task': '任务中心', + 'settings.navbar.help': '帮助中心', + 'settings.help.guide': '新手指引', + 'settings.help.doc': '帮助文档', + 'settings.help.APIDoc': 'API文档', + 'settings.help.version': '版本信息', 'settings.menu': '菜单栏', 'settings.tabBar': '多页签', 'settings.footer': '底部', diff --git a/frontend/src/mock/index.ts b/frontend/src/mock/index.ts index f1c8916542..5dd3b0ca81 100644 --- a/frontend/src/mock/index.ts +++ b/frontend/src/mock/index.ts @@ -4,6 +4,7 @@ import './user'; import './message-box'; import './api-test'; import './system/user'; +import './system/project'; Mock.setup({ timeout: '600-1000', diff --git a/frontend/src/mock/system/project.ts b/frontend/src/mock/system/project.ts new file mode 100644 index 0000000000..672e6da6b6 --- /dev/null +++ b/frontend/src/mock/system/project.ts @@ -0,0 +1,60 @@ +import Mock from 'mockjs'; +import setupMock, { successResponseWrap } from '@/utils/setup-mock'; + +const getProjectList = () => { + return [ + { + id: '0283f238hf2', + num: 0, + organizationId: 'v3v4h434c3', + name: '发了多少', + description: 'string', + createTime: 0, + updateTime: 0, + updateUser: 'string', + createUser: 'string', + deleteTime: 0, + deleted: true, + deleteUser: 'string', + enable: true, + }, + { + id: 'f9h832', + num: 0, + organizationId: 'v3v4h434c3', + name: '你了大 V', + description: 'string', + createTime: 0, + updateTime: 0, + updateUser: 'string', + createUser: 'string', + deleteTime: 0, + deleted: true, + deleteUser: 'string', + enable: true, + }, + { + id: '0v023i92', + num: 0, + organizationId: 'v3v4h434c3', + name: '代付款就是快递方式觉得都是就', + description: 'string', + createTime: 0, + updateTime: 0, + updateUser: 'string', + createUser: 'string', + deleteTime: 0, + deleted: true, + deleteUser: 'string', + enable: true, + }, + ]; +}; + +setupMock({ + setup: () => { + Mock.mock(new RegExp('/system/project/list'), () => { + return successResponseWrap(getProjectList()); + }); + }, +}); diff --git a/frontend/src/models/system/project.ts b/frontend/src/models/system/project.ts new file mode 100644 index 0000000000..18682fb3df --- /dev/null +++ b/frontend/src/models/system/project.ts @@ -0,0 +1,16 @@ +// 项目列表项 +export interface ProjectListItem { + id: string; + num: number; + organizationId: string; + name: string; + description: string; + createTime: number; + updateTime: number; + updateUser: string; + createUser: string; + deleteTime: number; + deleted: boolean; + deleteUser: string; + enable: boolean; +} diff --git a/frontend/src/router/constants.ts b/frontend/src/router/constants.ts index bb4f0d8e38..e94c05854d 100644 --- a/frontend/src/router/constants.ts +++ b/frontend/src/router/constants.ts @@ -1,21 +1,30 @@ +// 路由白名单,无需校验权限与登录状态 export const WHITE_LIST = [ { name: 'notFound', children: [] }, { name: 'login', children: [] }, { name: 'invite', children: [] }, ]; +// 左侧菜单底部对齐的菜单数组,数组项为一级路由的name export const BOTTOM_MENU_LIST = ['setting']; +// 404 路由 export const NOT_FOUND = { name: 'notFound', }; +// 重定向中转站路由 export const REDIRECT_ROUTE_NAME = 'Redirect'; +// 首页路由 export const DEFAULT_ROUTE_NAME = 'Workplace'; +// 默认 tab-bar 路,多页签模式下,打开的第一个页面 export const DEFAULT_ROUTE = { title: 'menu.dashboard.workplace', name: DEFAULT_ROUTE_NAME, fullPath: '/dashboard/workplace', }; + +// 不需要显示项目选择器的模块,数组项为一级路由的path +export const NOT_SHOW_PROJECT_SELECT_MODULE = ['setting']; diff --git a/frontend/src/router/routes/modules/api-test.ts b/frontend/src/router/routes/modules/api-test.ts index 93a48baf54..53f0fcafa4 100644 --- a/frontend/src/router/routes/modules/api-test.ts +++ b/frontend/src/router/routes/modules/api-test.ts @@ -9,11 +9,12 @@ const ApiTest: AppRouteRecordRaw = { locale: 'menu.apiTest', icon: 'icon-dashboard', order: 0, + hideChildrenInMenu: true, }, children: [ { path: 'list', - name: 'apiTest', + name: 'apiTestList', component: () => import('@/views/api-test/index.vue'), meta: { locale: 'menu.apiTest', diff --git a/frontend/src/store/modules/app/index.ts b/frontend/src/store/modules/app/index.ts index cb92c413f4..c8522efe0e 100644 --- a/frontend/src/store/modules/app/index.ts +++ b/frontend/src/store/modules/app/index.ts @@ -9,7 +9,14 @@ import type { NotificationReturn } from '@arco-design/web-vue/es/notification/in import type { RouteRecordNormalized, RouteRecordRaw } from 'vue-router'; const useAppStore = defineStore('app', { - state: (): AppState => ({ ...defaultSettings, loading: false, loadingTip: '', topMenus: [] as RouteRecordRaw[] }), + state: (): AppState => ({ + ...defaultSettings, + loading: false, + loadingTip: '', + topMenus: [] as RouteRecordRaw[], + currentOrgId: '', + currentProjectId: '', + }), getters: { appCurrentSetting(state: AppState): AppState { @@ -30,6 +37,12 @@ const useAppStore = defineStore('app', { getTopMenus(state: AppState): RouteRecordRaw[] { return state.topMenus; }, + getCurrentOrgId(state: AppState): string { + return state.currentOrgId; + }, + getCurrentProjectId(state: AppState): string { + return state.currentProjectId; + }, }, actions: { @@ -111,6 +124,21 @@ const useAppStore = defineStore('app', { setTopMenus(menus: RouteRecordRaw[] | undefined) { this.topMenus = menus ? [...menus] : []; }, + /** + * 设置当前组织 ID + */ + setCurrentOrgId(id: string) { + this.currentOrgId = id; + }, + /** + * 设置当前项目 ID + */ + setCurrentProjectId(id: string) { + this.currentProjectId = id; + }, + }, + persist: { + paths: ['currentOrgId', 'currentProjectId'], }, }); diff --git a/frontend/src/store/modules/app/types.ts b/frontend/src/store/modules/app/types.ts index 433734c5fe..9a219f7c52 100644 --- a/frontend/src/store/modules/app/types.ts +++ b/frontend/src/store/modules/app/types.ts @@ -17,6 +17,8 @@ export interface AppState { loading: boolean; loadingTip: string; topMenus: RouteRecordRaw[]; + currentOrgId: string; + currentProjectId: string; [key: string]: unknown; } diff --git a/frontend/src/store/modules/user/index.ts b/frontend/src/store/modules/user/index.ts index 6985477acd..8649dbcc11 100644 --- a/frontend/src/store/modules/user/index.ts +++ b/frontend/src/store/modules/user/index.ts @@ -54,7 +54,11 @@ const useUserStore = defineStore('user', { // 获取用户信息 async info() { const res = await getUserInfo(); - + const appStore = useAppStore(); + if (appStore.currentOrgId === '') { + // 第一次进系统才设置组织 ID,后续已经持久化存储了 + appStore.setCurrentOrgId(res.organization || ''); + } this.setInfo(res); },