From bd5a7ca6133eeddb8fed41ee2eb1c0c0874db91d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期六, 11 四月 2026 16:15:10 +0800
Subject: [PATCH] 中兴实强app 1.部署修改
---
src/directive/permission/hasPermi.ts | 31 +------
src/utils/permission.ts | 40 ---------
src/directive/permission/hasRole.ts | 31 +------
src/store/modules/user.ts | 89 +++++++++------------
src/manifest.json | 2
src/App.vue | 5
6 files changed, 54 insertions(+), 144 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index a238560..a28785c 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -17,10 +17,11 @@
}, 5000);
// 鍒濆鍖栨帹閫佹湇鍔�
- initPushService();
+ // initPushService();
});
// 鍒濆鍖栨帹閫佹湇鍔★紙uni-push 1.0锛�
const initPushService = () => {
+ return;
// #ifdef APP-PLUS
console.log("寮�濮嬪垵濮嬪寲鎺ㄩ�佹湇鍔★紙uni-push 1.0锛�");
if (typeof plus !== "undefined" && plus.push) {
@@ -108,4 +109,4 @@
<style lang="scss">
@import "uview-plus/index.scss";
@import "@/static/scss/index.scss";
-</style>
\ No newline at end of file
+</style>
diff --git a/src/directive/permission/hasPermi.ts b/src/directive/permission/hasPermi.ts
index efac852..7227930 100644
--- a/src/directive/permission/hasPermi.ts
+++ b/src/directive/permission/hasPermi.ts
@@ -1,30 +1,7 @@
-/**
-* v-hasPermi 鎿嶄綔鏉冮檺澶勭悊
-* Copyright (c) 2019 ruoyi
-*/
-
-import useUserStore from '@/store/modules/user'
-
import type { Directive } from "vue";
+
const vHasPermi: Directive = {
- mounted(el, binding, vnode) {
- const { value } = binding
- const all_permission = "*:*:*";
- const permissions = useUserStore().permissions
+ mounted() {}
+};
- if (value && value instanceof Array && value.length > 0) {
- const permissionFlag = value
-
- const hasPermissions = permissions.some(permission => {
- return all_permission === permission || permissionFlag.includes(permission)
- })
-
- if (!hasPermissions) {
- el.parentNode && el.parentNode.removeChild(el)
- }
- } else {
- throw new Error(`璇疯缃搷浣滄潈闄愭爣绛惧�糮)
- }
- }
-}
-export default vHasPermi
+export default vHasPermi;
diff --git a/src/directive/permission/hasRole.ts b/src/directive/permission/hasRole.ts
index 94a2b50..d4a5cc7 100644
--- a/src/directive/permission/hasRole.ts
+++ b/src/directive/permission/hasRole.ts
@@ -1,30 +1,7 @@
-/**
-* v-hasRole 瑙掕壊鏉冮檺澶勭悊
-* Copyright (c) 2019 ruoyi
-*/
-
-import useUserStore from '@/store/modules/user'
import type { Directive } from "vue";
+
const vHasRole: Directive = {
- mounted(el, binding, vnode) {
- const { value } = binding
- const super_admin = "admin";
- const roles = useUserStore().roles
+ mounted() {}
+};
- if (value && value instanceof Array && value.length > 0) {
- const roleFlag = value
-
- const hasRole = roles.some(role => {
- return super_admin === role || roleFlag.includes(role)
- })
-
- if (!hasRole) {
- el.parentNode && el.parentNode.removeChild(el)
- }
- } else {
- throw new Error(`璇疯缃鑹叉潈闄愭爣绛惧�糮)
- }
- }
-}
-
-export default vHasRole;
\ No newline at end of file
+export default vHasRole;
diff --git a/src/manifest.json b/src/manifest.json
index cce9364..688e2f3 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -24,7 +24,7 @@
"modules" : {
"Camera" : {},
"Barcode" : {},
- "Push" : {},
+ // "Push" : {},
"Maps" : {}
},
/* 搴旂敤鍙戝竷淇℃伅 */
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 140e0a3..64ada0b 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,9 +1,7 @@
-import {logout, getInfo, loginCheckFactory} from "@/api/login";
-import { getRouters as getRoutersApi } from "@/api/menu";
+import { logout, getInfo, loginCheckFactory } from "@/api/login";
import { getToken, setToken, removeToken } from "@/utils/auth";
-import defAva from "@/static/images/profile.jpg";
import { defineStore } from "pinia";
-import config from '@/config.js'
+import config from "@/config.js";
export interface LoginForm {
userName: string;
@@ -23,45 +21,45 @@
currentLoginTime: "",
roles: Array(),
permissions: [],
- routers: [], // 璺敱鏉冮檺鏁版嵁
+ routers: [],
}),
actions: {
- // 閮ㄩ棬鐧诲綍
loginCheckFactory(userInfo: any) {
- const userName = userInfo.userName
- const password = userInfo.password
+ const userName = userInfo.userName;
+ const password = userInfo.password;
return new Promise((resolve, reject) => {
- loginCheckFactory(userName, password).then((res: any) => {
- setToken(res.token)
- this.token = res.token
- resolve(null)
- }).catch((error: any) => {
- reject(error)
- })
- })
+ loginCheckFactory(userName, password)
+ .then((res: any) => {
+ setToken(res.token);
+ this.token = res.token;
+ resolve(null);
+ })
+ .catch((error: any) => {
+ reject(error);
+ });
+ });
},
- // 鑾峰彇鐢ㄦ埛淇℃伅
getInfo() {
return new Promise((resolve, reject) => {
getInfo()
.then((res: any) => {
- const user = res.user
- let avatar = user.avatar || ""
- avatar = config.baseUrl + '/profile/' + avatar
- if (res.roles && res.roles.length > 0) { // 楠岃瘉杩斿洖鐨剅oles鏄惁鏄竴涓潪绌烘暟缁�
- this.roles = res.roles
- this.permissions = res.permissions
+ const user = res.user;
+ let avatar = user.avatar || "";
+ avatar = config.baseUrl + "/profile/" + avatar;
+ if (res.roles && res.roles.length > 0) {
+ this.roles = res.roles;
+ this.permissions = res.permissions;
} else {
- this.roles = ['ROLE_DEFAULT']
+ this.roles = ["ROLE_DEFAULT"];
}
- this.id = user.userId
- this.name = user.userName
- this.avatar = avatar
- this.currentFactoryName = user.currentFactoryName
- this.nickName = user.nickName
- this.roleName = user.roles[0].roleName
- this.currentDeptId = user.tenantId
- this.currentLoginTime = this.getCurrentTime()
+ this.id = user.userId;
+ this.name = user.userName;
+ this.avatar = avatar;
+ this.currentFactoryName = user.currentFactoryName;
+ this.nickName = user.nickName;
+ this.roleName = user.roles[0].roleName;
+ this.currentDeptId = user.tenantId;
+ this.currentLoginTime = this.getCurrentTime();
resolve(res);
})
.catch((error) => {
@@ -69,7 +67,6 @@
});
});
},
- // 閫�鍑虹郴缁�
logOut() {
return new Promise<null>((resolve, reject) => {
logout()
@@ -90,26 +87,18 @@
},
getCurrentTime() {
const now = new Date();
- const year = now.getFullYear(); // 鑾峰彇骞翠唤
- const month = String(now.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮嬶紝瑕�+1锛屽苟琛ラ浂
- const day = String(now.getDate()).padStart(2, '0'); // 鏃ユ湡琛ラ浂
- const hours = String(now.getHours()).padStart(2, '0'); // 灏忔椂琛ラ浂
- const minutes = String(now.getMinutes()).padStart(2, '0'); // 鍒嗛挓琛ラ浂
- const seconds = String(now.getSeconds()).padStart(2, '0'); // 绉掓暟琛ラ浂
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, "0");
+ const day = String(now.getDate()).padStart(2, "0");
+ const hours = String(now.getHours()).padStart(2, "0");
+ const minutes = String(now.getMinutes()).padStart(2, "0");
+ const seconds = String(now.getSeconds()).padStart(2, "0");
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
- // 鑾峰彇璺敱鏉冮檺
getRouters() {
- return new Promise((resolve, reject) => {
- getRoutersApi()
- .then((res: any) => {
- // 瀛樺偍璺敱鏉冮檺鏁版嵁
- this.routers = res.data || [];
- resolve(res);
- })
- .catch((error) => {
- reject(error);
- });
+ return new Promise((resolve) => {
+ this.routers = [];
+ resolve({ data: [] });
});
},
},
diff --git a/src/utils/permission.ts b/src/utils/permission.ts
index 3d6c5cd..68d3b84 100644
--- a/src/utils/permission.ts
+++ b/src/utils/permission.ts
@@ -1,28 +1,10 @@
-import useUserStore from '@/store/modules/user'
-
/**
* 瀛楃鏉冮檺鏍¢獙
* @param {Array} value 鏍¢獙鍊�
* @returns {Boolean}
*/
export function checkPermi(value:Array<string>) {
- if (value && value instanceof Array && value.length > 0) {
- const permissions:Array<string> = useUserStore().permissions
- const permissionDatas = value
- const all_permission = "*:*:*"
-
- const hasPermission = permissions.some(permission => {
- return all_permission === permission || permissionDatas.includes(permission)
- })
-
- if (!hasPermission) {
- return false
- }
- return true
- } else {
- console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
- return false
- }
+ return true
}
/**
@@ -31,21 +13,5 @@
* @returns {Boolean}
*/
export function checkRole(value:Array<string>) {
- if (value && value instanceof Array && value.length > 0) {
- const roles:Array<string> = useUserStore().roles
- const permissionRoles = value
- const super_admin = "admin"
-
- const hasRole = roles.some(role => {
- return super_admin === role || permissionRoles.includes(role)
- })
-
- if (!hasRole) {
- return false
- }
- return true
- } else {
- console.error(`need roles! Like checkRole="['admin','editor']"`)
- return false
- }
-}
\ No newline at end of file
+ return true
+}
--
Gitblit v1.9.3