From 47c38883d3cbf03419b6a6e4e14f0c5eac469b4d Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期日, 07 四月 2024 10:42:45 +0800
Subject: [PATCH] update
---
src/views/login/components/passwordForm.vue | 119 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 61 insertions(+), 58 deletions(-)
diff --git a/src/views/login/components/passwordForm.vue b/src/views/login/components/passwordForm.vue
index b0eb9cb..a8e1c88 100644
--- a/src/views/login/components/passwordForm.vue
+++ b/src/views/login/components/passwordForm.vue
@@ -61,40 +61,7 @@
grant_type: "password",
scope: "all"
}
- //鑾峰彇鑿滃崟
- // var menu = null
- // if(this.form.user == 'admin'){
- // menu = await this.$API.system.menu.myMenus.get()
- // }else{
- // menu = await this.$API.demo.menu.get()
- // }
- // if(menu.code == 200){
- // if(menu.data.menu.length==0){
- // this.islogin = false
- // this.$alert("褰撳墠鐢ㄦ埛鏃犱换浣曡彍鍗曟潈闄愶紝璇疯仈绯荤郴缁熺鐞嗗憳", "鏃犳潈闄愯闂�", {
- // type: 'error',
- // center: true
- // })
- // return false
- // }
- // this.$TOOL.data.set("MENU", menu.data.menu)
- // this.$TOOL.data.set("PERMISSIONS", menu.data.permissions)
- // this.$TOOL.data.set("DASHBOARDGRID", menu.data.dashboardGrid)
- // }else{
- // this.islogin = false
- // this.$message.warning(menu.message)
- // return false
- // }
-
- // this.$router.replace({
- // path: '/'
- // })
- // this.$message.success("Login Success 鐧诲綍鎴愬姛")
- // this.islogin = false
-
-
-
- await this.$HTTP.postJ("/api/blade-auth/oauth/token",data).then(res=> {
+ await this.$HTTP.postJ("/api/blade-auth/oauth/token?" + this.$TOOL.qsStringify(data)).then(res=> {
if(res.user_id) {
//鑾峰彇token
this.$TOOL.cookie.set("TOKEN", res.access_token, {
@@ -105,11 +72,8 @@
res.dashboard = "0";
res.userId = "1";
this.$TOOL.data.set("USER_INFO", res);
- //鑾峰彇鑿滃崟
-
-
- }else {
this.islogin = false;
+ }else {
this.$message({
showClose: true,
message: res.error_description,
@@ -117,27 +81,66 @@
});
}
})
- await this.$API.system.menu.myMenus.get().then(resp=> {
- console.log('>>>>>>')
- if(resp.data.menu.length==0){
- this.islogin = false
- this.$alert("褰撳墠鐢ㄦ埛鏃犱换浣曡彍鍗曟潈闄愶紝璇疯仈绯荤郴缁熺鐞嗗憳", "鏃犳潈闄愯闂�", {
- type: 'error',
- center: true
- })
- return false
- }
- this.$TOOL.data.set("MENU", resp.data.menu)
- this.$TOOL.data.set("PERMISSIONS", resp.data.permissions)
- this.$TOOL.data.set("DASHBOARDGRID", resp.data.dashboardGrid)
-
- });
- this.$router.replace({
- path: '/'
- })
- this.$message.success("Login Success 鐧诲綍鎴愬姛")
+ await this.$HTTP.get("/api/blade-system/menu/routes?" + this.$TOOL.qsStringify({"appCode": "CPS"})).then(res=> {
+ if(res.data.length==0){
this.islogin = false
- },
+ this.$alert("褰撳墠鐢ㄦ埛鏃犱换浣曡彍鍗曟潈闄愶紝璇疯仈绯荤郴缁熺鐞嗗憳", "鏃犳潈闄愯闂�", {
+ type: 'error',
+ center: true
+ })
+ return false
+ }
+ //寮�濮�
+ function addComponentToLastLevel(items) {
+ return items.map((item) => {
+ // 澶嶅埗褰撳墠椤癸紝閬垮厤鐩存帴淇敼鍘熷瀵硅薄
+ const clonedItem = { ...item };
+
+ // 妫�鏌ュ綋鍓嶉」鏄惁鏈� children 灞炴��
+ if (clonedItem.children) {
+ // 閫掑綊澶勭悊 children
+ clonedItem.children = addComponentToLastLevel(clonedItem.children);
+ } else {
+ // 濡傛灉娌℃湁 children 灞炴�э紝璇存槑鏄渶鍚庝竴绾э紝娣诲姞 component 瀵硅薄
+ var len = clonedItem.path.length;
+ clonedItem.component = clonedItem.path.substring(1,len);
+ }
+ //console.log(clonedItem.source)
+ clonedItem.meta = {title: clonedItem.name,icon: "el-icon-takeaway-box", type: "menu"}
+ return clonedItem;
+ });
+ }
+ var transformedArray = addComponentToLastLevel(res.data);
+ transformedArray[0].path = "/home";
+ transformedArray[0].children = [{
+ component: "home",
+ meta: {title: "宸ヤ綔鍙�", icon: 'el-icon-menu', affix: true},
+ name: "宸ヤ綔鍙�",
+ path: "/dashboard"
+ }]
+ //缁撴潫
+ var obj = {
+ dashboardGrid: ["welcome", "ver", "time", "progress", "echarts", "about"],
+ menu: transformedArray,
+ permissions: ["list.add", "list.edit", "list.delete", "user.add", "user.edit", "user.delete"]
+ }
+ console.log(obj.menu)
+ // this.$API.system.menu.myMenus.get().then(resp=> {
+ // Object.assign({},transformedArray,resp.data.menu);
+ // this.$TOOL.data.set("MENU", obj.menu)
+ // this.$TOOL.data.set("PERMISSIONS", obj.permissions)
+ // this.$TOOL.data.set("DASHBOARDGRID", obj.dashboardGrid)
+ // });
+ this.$TOOL.data.set("MENU", obj.menu)
+ this.$TOOL.data.set("PERMISSIONS", obj.permissions)
+ this.$TOOL.data.set("DASHBOARDGRID", obj.dashboardGrid)
+ })
+ this.$router.replace({
+ path: '/'
+ })
+ this.$message.success("Login Success 鐧诲綍鎴愬姛")
+ this.islogin = false;
+ }
}
}
</script>
--
Gitblit v1.9.3