From 57e9cc82018aa80307de944c05ae428842cf5f65 Mon Sep 17 00:00:00 2001 From: ks3356143 <314298729@qq.com> Date: Fri, 26 Apr 2024 19:06:14 +0800 Subject: [PATCH] ks001 --- cdTMP/src/api/request.js | 7 +++- cdTMP/src/api/system/user.js | 11 +++++ cdTMP/src/api/system/workplace.js | 14 +++++++ cdTMP/src/router/guard/userLoginInfo.js | 15 ++++--- cdTMP/src/store/modules/user.js | 1 - cdTMP/src/utils/request.js | 2 +- .../workplace/components/cpns/st-count.vue | 41 +++++++++---------- .../components/cpns/st-project-chart.vue | 2 +- cdTMP/src/views/login.vue | 26 ++++++++---- .../src/views/project/design-demand/index.vue | 2 +- cdTMP/src/views/project/dut/index.vue | 2 +- cdTMP/src/views/project/testDemand/index.vue | 2 +- .../src/views/testmanage/projmanage/index.vue | 3 +- 13 files changed, 81 insertions(+), 47 deletions(-) create mode 100644 cdTMP/src/api/system/workplace.js diff --git a/cdTMP/src/api/request.js b/cdTMP/src/api/request.js index 09f9156..2578ec2 100644 --- a/cdTMP/src/api/request.js +++ b/cdTMP/src/api/request.js @@ -65,8 +65,11 @@ function createService() { err("登录状态已过期,需要重新登录") // 清楚本地localStorage tool.local.clear() - // 移动到网站的根目录 - window.location.href = "/" + // 移动到网站的根目录-这里不需要因为导航守卫可以返回login页面 + if (error.response.data.data.code === 40001) { + } else { + window.location.href = "/" + } break case 403: err("没有权限访问该资源") diff --git a/cdTMP/src/api/system/user.js b/cdTMP/src/api/system/user.js index 123eb3f..b92c2fc 100644 --- a/cdTMP/src/api/system/user.js +++ b/cdTMP/src/api/system/user.js @@ -102,4 +102,15 @@ export default { params }) }, + /** + * 加载LDAP的用户数据 + * @returns + */ + loadLDAPUsers(params = {}) { + return request({ + url: "system/user/ldap", + method: "get", + params + }) + } } diff --git a/cdTMP/src/api/system/workplace.js b/cdTMP/src/api/system/workplace.js new file mode 100644 index 0000000..a21be01 --- /dev/null +++ b/cdTMP/src/api/system/workplace.js @@ -0,0 +1,14 @@ +import { request } from "@/api/request" +export default { + /** + * 查询工作台的统计信息 + * @returns 统计用户和项目情况 + */ + getStatistics(params = {}) { + return request({ + url: `/system/workplace/statistics`, + method: "get", + params + }) + } +} diff --git a/cdTMP/src/router/guard/userLoginInfo.js b/cdTMP/src/router/guard/userLoginInfo.js index 767361a..9e8ddc6 100644 --- a/cdTMP/src/router/guard/userLoginInfo.js +++ b/cdTMP/src/router/guard/userLoginInfo.js @@ -2,39 +2,38 @@ import NProgress from "nprogress" // progress bar import { useUserStore } from "@/store" // userInfo守卫 export default function setupUserLoginInfoGuard(router) { - router.beforeEach(async (to, from, next) => { + router.beforeEach(async (to, from) => { NProgress.start() const userStore = useUserStore() if (userStore.isLogin()) { if (userStore.role) { - next() + return } else { try { await userStore.info() - next() + return } catch (error) { await userStore.logout() - next({ + return { name: "login", query: { redirect: to.name, ...to.query } - }) + } } } } else { if (to.name === "login") { - next() return } - next({ + return { name: "login", query: { redirect: to.name, ...to.query } - }) + } } }) } diff --git a/cdTMP/src/store/modules/user.js b/cdTMP/src/store/modules/user.js index 4e1bce6..59b47fb 100644 --- a/cdTMP/src/store/modules/user.js +++ b/cdTMP/src/store/modules/user.js @@ -79,7 +79,6 @@ const useUserStore = defineStore("user", { } }) .catch((e) => { - console.log(e) return false }) }, diff --git a/cdTMP/src/utils/request.js b/cdTMP/src/utils/request.js index 5fe9090..f878411 100644 --- a/cdTMP/src/utils/request.js +++ b/cdTMP/src/utils/request.js @@ -62,7 +62,7 @@ function createService() { case 401: err("登录状态已过期,需要重新登录") tool.local.clear() - window.location.href = "/" + window.location.href = "/login" break case 403: err("没有权限访问该资源") diff --git a/cdTMP/src/views/dashboard/workplace/components/cpns/st-count.vue b/cdTMP/src/views/dashboard/workplace/components/cpns/st-count.vue index 929c972..37de9d7 100644 --- a/cdTMP/src/views/dashboard/workplace/components/cpns/st-count.vue +++ b/cdTMP/src/views/dashboard/workplace/components/cpns/st-count.vue @@ -15,11 +15,7 @@
总数
-
2
-
-
-
新增
-
15
+
{{ statistics.ucount }}
@@ -39,11 +35,7 @@
总数
-
23
-
-
-
减少
-
2
+
{{ statistics.ppcount }}
@@ -63,11 +55,7 @@
总数
-
234
-
-
-
新增
-
3
+
{{ statistics.pcount }}
@@ -83,15 +71,11 @@
OC
- 提交项目总数 + 完成项目总数
总数
-
45
-
-
-
新增
-
2
+
{{ statistics.pdcount }}
@@ -101,6 +85,21 @@
+ +