1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

后台管理 登陆权限问题解决

This commit is contained in:
程序员小墨 2023-03-28 14:01:13 +08:00
parent 614e04ed1b
commit 880e4f8941
13 changed files with 498 additions and 386 deletions

View File

@ -11,7 +11,7 @@
Target Server Version : 80012 Target Server Version : 80012
File Encoding : 65001 File Encoding : 65001
Date: 22/03/2023 16:41:32 Date: 28/03/2023 13:51:00
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -49,10 +49,10 @@ INSERT INTO `apply1` VALUES (11, 2, '1', '飞机', '1', '2022-10-23 16:17:00', '
INSERT INTO `apply1` VALUES (12, 13, '1', '飞机', '1', '2022-10-26 19:25:00', '2022-10-26 21:25:00', 1, ''); INSERT INTO `apply1` VALUES (12, 13, '1', '飞机', '1', '2022-10-26 19:25:00', '2022-10-26 21:25:00', 1, '');
-- ---------------------------- -- ----------------------------
-- Table structure for community_gate -- Table structure for community_gate1
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `community_gate`; DROP TABLE IF EXISTS `community_gate1`;
CREATE TABLE `community_gate` ( CREATE TABLE `community_gate1` (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '雪花id', `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '雪花id',
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '大门显示名称', `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '大门显示名称',
`open` tinyint(1) NOT NULL DEFAULT 1 COMMENT '大门是否开放 1为开放 2为关闭', `open` tinyint(1) NOT NULL DEFAULT 1 COMMENT '大门是否开放 1为开放 2为关闭',
@ -60,7 +60,7 @@ CREATE TABLE `community_gate` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社区大门' ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社区大门' ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
-- Records of community_gate -- Records of community_gate1
-- ---------------------------- -- ----------------------------
-- ---------------------------- -- ----------------------------
@ -281,10 +281,13 @@ CREATE TABLE `order` (
-- ---------------------------- -- ----------------------------
-- Records of order -- Records of order
-- ---------------------------- -- ----------------------------
INSERT INTO `order` VALUES (1748800678865801225, 1, '2023-03-21 15:50:19', 'Pending', 21.99, NULL); INSERT INTO `order` VALUES (1748800678865801225, 3, '2023-03-21 15:50:19', 'Pending', 21.99, NULL);
INSERT INTO `order` VALUES (1749495597129404427, 1, '2023-03-21 16:30:54', 'Pending', 5.99, NULL); INSERT INTO `order` VALUES (1749495597129404427, 3, '2023-03-21 16:30:54', 'Pending', 5.99, NULL);
INSERT INTO `order` VALUES (1749495896040673288, 1, '2023-03-21 16:32:06', 'Pending', 5.99, NULL); INSERT INTO `order` VALUES (1749495896040673288, 3, '2023-03-21 16:32:06', 'Pending', 5.99, NULL);
INSERT INTO `order` VALUES (1749496012575215624, 1, '2023-03-21 16:32:33', 'Pending', 17.97, NULL); INSERT INTO `order` VALUES (1749496012575215624, 3, '2023-03-21 16:32:33', 'Pending', 17.97, NULL);
INSERT INTO `order` VALUES (1750312359831932932, 3, '2023-03-23 22:36:26', 'Cancelled', 87.50, NULL);
INSERT INTO `order` VALUES (1750312445567700999, 3, '2023-03-23 22:36:46', 'Processing', 87.50, NULL);
INSERT INTO `order` VALUES (1750313361633054722, 3, '2023-03-23 22:40:25', 'Processing', 2.50, NULL);
-- ---------------------------- -- ----------------------------
-- Table structure for order_detail -- Table structure for order_detail
@ -301,7 +304,7 @@ CREATE TABLE `order_detail` (
INDEX `good_id`(`good_id`) USING BTREE, INDEX `good_id`(`good_id`) USING BTREE,
CONSTRAINT `order_detail_ibfk_1` FOREIGN KEY (`good_id`) REFERENCES `goods` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `order_detail_ibfk_1` FOREIGN KEY (`good_id`) REFERENCES `goods` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `order_detail_ibfk_2` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `order_detail_ibfk_2` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 43 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB AUTO_INCREMENT = 46 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
-- Records of order_detail -- Records of order_detail
@ -316,6 +319,9 @@ INSERT INTO `order_detail` VALUES (39, 1748800678865801225, 19, 1, 21.99);
INSERT INTO `order_detail` VALUES (40, 1749495597129404427, 16, 1, 5.99); INSERT INTO `order_detail` VALUES (40, 1749495597129404427, 16, 1, 5.99);
INSERT INTO `order_detail` VALUES (41, 1749495896040673288, 16, 1, 5.99); INSERT INTO `order_detail` VALUES (41, 1749495896040673288, 16, 1, 5.99);
INSERT INTO `order_detail` VALUES (42, 1749496012575215624, 16, 3, 5.99); INSERT INTO `order_detail` VALUES (42, 1749496012575215624, 16, 3, 5.99);
INSERT INTO `order_detail` VALUES (43, 1750312359831932932, 55, 25, 3.50);
INSERT INTO `order_detail` VALUES (44, 1750312445567700999, 55, 25, 3.50);
INSERT INTO `order_detail` VALUES (45, 1750313361633054722, 56, 1, 2.50);
-- ---------------------------- -- ----------------------------
-- Table structure for report -- Table structure for report
@ -329,17 +335,18 @@ CREATE TABLE `report` (
`temperature` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '体温是否正常', `temperature` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '体温是否正常',
`address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址', `address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 61 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB AUTO_INCREMENT = 62 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
-- Records of report -- Records of report
-- ---------------------------- -- ----------------------------
INSERT INTO `report` VALUES (53, 1, '管理员 密码root', '2022-12-26 20:35:38', '1', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)'); INSERT INTO `report` VALUES (53, 3, '用户 密码user', '2022-12-26 20:35:38', '1', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)');
INSERT INTO `report` VALUES (55, 1, '管理员 密码root', '2022-12-27 21:03:24', '0', '湖北省武汉市洪山区文治街508号南湖雅园F栋2-104号'); INSERT INTO `report` VALUES (55, 3, '用户 密码user', '2022-12-27 21:03:24', '0', '湖北省武汉市洪山区文治街508号南湖雅园F栋2-104号');
INSERT INTO `report` VALUES (57, 1, '管理员 密码root', '2022-12-28 21:47:57', '0', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)'); INSERT INTO `report` VALUES (57, 3, '用户 密码user', '2022-12-28 21:47:57', '0', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)');
INSERT INTO `report` VALUES (58, 1, '管理员 密码root', '2022-12-29 18:20:00', '1', '湖北省武汉市洪山区鲁磨路209号'); INSERT INTO `report` VALUES (58, 3, '用户 密码user', '2022-12-29 18:20:00', '1', '湖北省武汉市洪山区鲁磨路209号');
INSERT INTO `report` VALUES (59, 1, '管理员 密码root', '2023-03-17 00:27:21', '0', '湖北省武汉市洪山区雄楚大道珞狮南路南湖雅园F-4-106'); INSERT INTO `report` VALUES (59, 3, '用户 密码user', '2023-03-17 00:27:21', '0', '湖北省武汉市洪山区雄楚大道珞狮南路南湖雅园F-4-106');
INSERT INTO `report` VALUES (60, 1, '管理员 密码root', '2023-03-20 00:47:22', '0', '湖北省武汉市武昌区武车路'); INSERT INTO `report` VALUES (60, 3, '用户 密码user', '2023-03-20 00:47:22', '0', '湖北省武汉市武昌区武车路');
INSERT INTO `report` VALUES (61, 3, '用户 密码user', '2023-03-23 22:24:14', '0', '湖北省武汉市武昌区修远路');
-- ---------------------------- -- ----------------------------
-- Table structure for setting -- Table structure for setting
@ -355,7 +362,7 @@ CREATE TABLE `setting` (
-- ---------------------------- -- ----------------------------
-- Records of setting -- Records of setting
-- ---------------------------- -- ----------------------------
INSERT INTO `setting` VALUES ('wechat_access_token', '66_k4e3ae12hwRMq2XLW5mW5rOBsLawIcKPsFjNC4ILQS6rYJi4RJN8tYXtwCJLxqimgAHrZ-MV0LqsFn7u_9OVjEOj7b-d3V4tirO3mxLTj59U87V5WhV0XNp1fFULMRhAJASTY', '2023-03-21 00:34:18'); INSERT INTO `setting` VALUES ('wechat_access_token', '66_qSxbHTU4lcXa4l8JgZisZm_2gXUmQH_vVSybGHP229Nv9QeacmXuYeQxpZQ-JNnLWI-HpJ9Zlf18B4Lnif5fR1EvGukoLFZmGWADlcobLsY-JlKZX7lXRzk6tAoRWTiACAZEB', '2023-03-24 00:26:42');
-- ---------------------------- -- ----------------------------
-- Table structure for user -- Table structure for user
@ -368,19 +375,20 @@ CREATE TABLE `user` (
`realname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '真实姓名', `realname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '真实姓名',
`id_number` varchar(18) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号', `id_number` varchar(18) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号',
`phone_number` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号', `phone_number` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号',
`role` int(11) NOT NULL COMMENT '角色 (0-超级管理员 1-工作人员 2-社区居民_房主 3-社区居民_家庭成员 4-社区居民_租客 5-访客)', `role` int(11) NOT NULL COMMENT '角色 (1-超级管理员 2-工作人员 3-社区居民_房主 4-社区居民_家庭成员 5-社区居民_租客 6-访客)',
`building_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门栋号+单元号', `building_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门栋号+单元号',
`doorplate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门牌号', `doorplate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门牌号',
`permission` int(11) NOT NULL DEFAULT 0 COMMENT '进出权限 (0-无 1-继承(普通居民) 2-永久 3-限时)', `permission` int(11) NOT NULL DEFAULT 0 COMMENT '进出权限 (0-无 1-继承(普通居民) 2-永久 3-限时)',
`permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间', `permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
-- Records of user -- Records of user
-- ---------------------------- -- ----------------------------
INSERT INTO `user` VALUES (1, 'root', '99adc231b045331e514a516b4b7680f588e3823213abe901738bc3ad67b2f6fcb3c64efb93d18002588d3ccc1a49efbae1ce20cb43df36b38651f11fa75678e8', '管理员 密码root', '420111111111111111', NULL, 1, NULL, NULL, 0, NULL); INSERT INTO `user` VALUES (1, 'root', '99adc231b045331e514a516b4b7680f588e3823213abe901738bc3ad67b2f6fcb3c64efb93d18002588d3ccc1a49efbae1ce20cb43df36b38651f11fa75678e8', '管理员 密码root', '420111111111111111', NULL, 1, NULL, NULL, 0, NULL);
INSERT INTO `user` VALUES (2, 'user', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户 密码user', '420111111111111111', NULL, 2, NULL, NULL, 0, NULL); INSERT INTO `user` VALUES (2, 'admin', 'c7ad44cbad762a5da0a452f9e854fdc1e0e7a52a38015f23f3eab1d80b931dd472634dfac71cd34ebc35d16ab7fb8a90c81f975113d6c7538dc69dd8de9077ec', '社区管理员 密码admin', '420111111111111111', NULL, 2, NULL, NULL, 0, NULL);
INSERT INTO `user` VALUES (3, 'user', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户 密码user', '420111111111111111', NULL, 3, NULL, NULL, 0, NULL);
-- ---------------------------- -- ----------------------------
-- Table structure for visitor1 -- Table structure for visitor1

View File

@ -1,5 +1,5 @@
// Generated by 'unplugin-auto-import' // Generated by 'unplugin-auto-import'
export {} export {}
declare global { declare global {
const ElMessage: typeof import('element-plus/es')['ElMessage']
} }

View File

@ -14,6 +14,7 @@
"element-plus": "^2.2.14", "element-plus": "^2.2.14",
"md-editor-v3": "^2.2.1", "md-editor-v3": "^2.2.1",
"pinia": "^2.0.20", "pinia": "^2.0.20",
"qs": "^6.11.1",
"vue": "^3.2.37", "vue": "^3.2.37",
"vue-cropperjs": "^5.0.0", "vue-cropperjs": "^5.0.0",
"vue-router": "^4.1.3", "vue-router": "^4.1.3",
@ -709,6 +710,15 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"dependencies": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
}
},
"node_modules/cesium": { "node_modules/cesium": {
"version": "1.102.0", "version": "1.102.0",
"resolved": "https://registry.npmmirror.com/cesium/-/cesium-1.102.0.tgz", "resolved": "https://registry.npmmirror.com/cesium/-/cesium-1.102.0.tgz",
@ -1427,8 +1437,17 @@
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
"dev": true },
"node_modules/get-intrinsic": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz",
"integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==",
"dependencies": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.3"
}
}, },
"node_modules/glob-parent": { "node_modules/glob-parent": {
"version": "5.1.2", "version": "5.1.2",
@ -1459,7 +1478,6 @@
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmmirror.com/has/-/has-1.0.3.tgz", "resolved": "https://registry.npmmirror.com/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"dependencies": { "dependencies": {
"function-bind": "^1.1.1" "function-bind": "^1.1.1"
}, },
@ -1467,6 +1485,14 @@
"node": ">= 0.4.0" "node": ">= 0.4.0"
} }
}, },
"node_modules/has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": { "node_modules/http-errors": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz", "resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz",
@ -1784,6 +1810,11 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node_modules/object-inspect": {
"version": "1.12.3",
"resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.12.3.tgz",
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g=="
},
"node_modules/on-finished": { "node_modules/on-finished": {
"version": "2.4.1", "version": "2.4.1",
"resolved": "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz", "resolved": "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz",
@ -1931,6 +1962,17 @@
"node": ">=12.0.0" "node": ">=12.0.0"
} }
}, },
"node_modules/qs": {
"version": "6.11.1",
"resolved": "https://registry.npmmirror.com/qs/-/qs-6.11.1.tgz",
"integrity": "sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ==",
"dependencies": {
"side-channel": "^1.0.4"
},
"engines": {
"node": ">=0.6"
}
},
"node_modules/queue-microtask": { "node_modules/queue-microtask": {
"version": "1.2.3", "version": "1.2.3",
"resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz", "resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz",
@ -2133,6 +2175,16 @@
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"dev": true "dev": true
}, },
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"dependencies": {
"call-bind": "^1.0.0",
"get-intrinsic": "^1.0.2",
"object-inspect": "^1.9.0"
}
},
"node_modules/source-map": { "node_modules/source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz",

View File

@ -14,6 +14,7 @@
"element-plus": "^2.2.14", "element-plus": "^2.2.14",
"md-editor-v3": "^2.2.1", "md-editor-v3": "^2.2.1",
"pinia": "^2.0.20", "pinia": "^2.0.20",
"qs": "^6.11.1",
"vue": "^3.2.37", "vue": "^3.2.37",
"vue-cropperjs": "^5.0.0", "vue-cropperjs": "^5.0.0",
"vue-router": "^4.1.3", "vue-router": "^4.1.3",

17
frontend/src/api/user.js Normal file
View File

@ -0,0 +1,17 @@
import send_request from '../utils/send_request';
/**
* 用户登录
* @returns
*/
export function userLogin({ username, password }) {
return send_request({
url: '/user/login',
method: 'POST',
useQS: true,
params: {
"username": username,
"password": password,
}
});
};

View File

@ -74,15 +74,15 @@ const router = useRouter();
const handleCommand = (command: string) => { const handleCommand = (command: string) => {
if (command == 'loginout') { if (command == 'loginout') {
// 退 // 退
send_request('v1/user/logout', "POST"); send_request({
url: 'v1/user/logout',
method: "POST",
} as any);
// () // ()
const tags = useTagsStore(); const tags = useTagsStore();
tags.clearTags(); tags.clearTags();
// localStorage // localStorage
localStorage.clear(); localStorage.clear();
// localStorage.removeItem('ms_username');
// localStorage.removeItem('ms_user_id');
// localStorage.removeItem('ms_role_id');
// //
router.push({ router.push({
path: '/login', path: '/login',

View File

@ -15,11 +15,13 @@ app.use(router);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) { for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component); app.component(key, component);
} }
// 自定义权限指令 // 自定义权限指令
const permiss = usePermissStore(); const permiss = usePermissStore();
app.directive('permiss', { app.directive('permiss', { // 元素级权限控制
mounted(el, binding) { mounted(el, binding) {
if (!permiss.key.includes(String(binding.value))) { const role = localStorage.getItem('ms_role_id');
if (!permiss[role as string] || !permiss[role as string].includes(binding.value as string)) {
el['hidden'] = true; el['hidden'] = true;
} }
}, },

View File

@ -198,18 +198,26 @@ const router = createRouter({
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
document.title = `${to.meta.title} | ${settings.siteTitle}`; document.title = `${to.meta.title} | ${settings.siteTitle}`;
const role = localStorage.getItem('ms_username'); const username = localStorage.getItem('ms_username');
const role = localStorage.getItem('ms_role_id');
const permiss = usePermissStore(); const permiss = usePermissStore();
if (!role && to.path !== '/login') { const currentUserPermiss = permiss[role as string];
// console.log("currentUserPermiss", currentUserPermiss)
if (!username && to.path !== '/login') {
next({ next({
path: '/login', path: '/login',
query: { query: {
redirectTo: router.currentRoute.value.path // window.location.href redirectTo: router.currentRoute.value.path // window.location.href
}, },
}); });
} else if (to.meta.permiss && !permiss.key.includes(to.meta.permiss)) { return
} else if (
to.meta.permiss &&
!(currentUserPermiss && currentUserPermiss.includes(to.meta.permiss as string))
) {
// 如果没有权限则进入403 // 如果没有权限则进入403
next('/403'); next('/403');
return
} else { } else {
next(); next();
} }

View File

@ -5,18 +5,58 @@ interface ObjectList {
[key: string]: string[]; [key: string]: string[];
} }
// 不同 role 的用户分别有哪些权限
export const usePermissStore = defineStore('permiss', { export const usePermissStore = defineStore('permiss', {
state: () => { state: () => {
const keys = localStorage.getItem('ms_keys');
const defaultList = localStorage.getItem('ms_default_list');
return { return {
key: keys ? JSON.parse(keys) : <string[]>[], "1": [
defaultList: JSON.stringify(defaultList) "dashboard",
"data-integration",
"default",
"equipment",
"equipment-setting",
"equipment-setting-manage",
"equipment-view",
"monitor-data",
"monitor-data-statistics",
"monitor-data-view",
"privilege",
"privilege-role-setting",
"privilege-user-setting",
"report",
"report-upload",
"resource",
"resource-staff-setting",
"resource-vehicle-setting",
"site-info",
"warning",
"warning-log",
"warning-setting",
"warning-view"
],
"2": [
"dashboard",
"data-integration",
"default",
"equipment",
"equipment-setting",
"equipment-view",
"monitor-data",
"monitor-data-statistics",
"monitor-data-view",
"report",
"report-upload",
"site-info",
"warning",
"warning-log",
"warning-setting",
"warning-view"
]
}; };
}, },
actions: { // actions: {
handleSet(val: string[]) { // handleSet(val: string[]) {
this.key = val; // this.key = val;
} // }
} // }
}); });

View File

@ -1,52 +1,67 @@
import request from './request'; import request from './request';
import settings from './settings'; import settings from './settings';
import { ElMessage, ElLoading } from 'element-plus';
import qs from 'qs';
async function send_request(url, method = "POST", params, callback) { async function send_request({ url, method = "POST", params, useQS = false, callback }) {
if (!url) { if (!url) {
return false; return false;
} }
let returnData = await request({ const loading = ElLoading.service({
lock: true,
text: '请稍候',
background: 'rgba(0, 0, 0, 0.7)',
});
let opt = {
baseURL: settings.backendHost, baseURL: settings.backendHost,
url: url, url: url,
method: method, method: method,
withCredentials: true, withCredentials: true,
}
if (method.toUpperCase() == "POST") {
// POST 请求参数 // POST 请求参数
data: method.toUpperCase() == "POST" ? params : null, opt.headers = { 'content-type': 'application/x-www-form-urlencoded' }
opt.data = useQS ? qs.stringify(params) : params
} else if (method.toUpperCase() == "GET") {
// GET 请求参数 // GET 请求参数
params: method.toUpperCase() == "GET" ? params : null, opt.params = params
}).then((response) => { }
return request(opt).then((response) => {
let result = response.data; let result = response.data;
// 判断后端是否处理成功 // 判断后端是否处理成功
if (!result.isSuccess) { if (!result.success) {
// 用户未登录情况 // 用户未登录情况
if (result.data && result.data.errCode == 20003) { // if (result.data && result.data.errCode == 20003) {
ElMessage.error(result?.data?.errMsg || "用户未登录"); // ElMessage.error(result?.data?.msg || "用户未登录");
localStorage.clear(); // localStorage.clear();
// window.location.reload(); // // window.location.reload();
// 如果同时发出多个请求可能会多次进来第二次及之后进入时hash已经变成 #/login 了 // // 如果同时发出多个请求可能会多次进来第二次及之后进入时hash已经变成 #/login 了
if (!window.location.hash.includes("/login")) { // if (!window.location.hash.includes("/login")) {
let newUrl = '/#/login?redirectTo=' + encodeURIComponent(window.location.hash.substring(1).split('?')[0]) // let newUrl = '/#/login?redirectTo=' + encodeURIComponent(window.location.hash.substring(1).split('?')[0])
console.log("newUrl", newUrl) // console.log("newUrl", newUrl)
window.location.href = newUrl; // window.location.href = newUrl;
} // }
} else { // } else {
ElMessage.error(result?.data?.errMsg || "服务器错误"); ElMessage.error(result?.data?.msg || "服务器错误");
} // }
return false; return null;
} }
let data = result.data; let data = result.data;
if (typeof (callback) === "function") { if (typeof (callback) === "function") {
callback(data); callback(data);
} }
return true; return data;
}).catch((err) => { }).catch((err) => {
console.error(err); console.error(err);
ElMessage.error(err.message); ElMessage.error(err.message);
// ElMessage.error('请求超时,请检查网络连接');
return false; return false;
}).finally(() => {
loading.close();
}) })
return returnData;
} }
export default send_request; export default send_request;

View File

@ -11,7 +11,7 @@ export default {
* 网页标题 / 登录页显示 * 网页标题 / 登录页显示
*/ */
siteTitle: "社区疫情防控系统", siteTitle: "社区疫情防控系统",
siteFullTitle: "社区疫情防控系统 - 后台管理系统(社区管理员)", siteFullTitle: "社区疫情防控系统 - 后台管理系统",
/** /**
* 开发公司名称 * 开发公司名称
@ -21,7 +21,7 @@ export default {
/** /**
* 后端接口请求地址 * 后端接口请求地址
* / 结尾 * 结尾加不加 / 都可
*/ */
backendHost: "http://epp.only4.work/", backendHost: "https://epp.only4.work/",
}; };

View File

@ -39,26 +39,18 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from 'vue'; import { ref, reactive } from 'vue';
import { useTagsStore } from '../store/tags'; import { useTagsStore } from '../store/tags';
import { usePermissStore } from '../store/permiss';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { ElMessage, ElLoading } from 'element-plus'; import { ElMessage } from 'element-plus';
import type { FormInstance, FormRules } from 'element-plus'; import type { FormInstance, FormRules } from 'element-plus';
import { Lock, User } from '@element-plus/icons-vue'; import { Lock, User } from '@element-plus/icons-vue';
import send_request from '../utils/send_request';
import settings from '../utils/settings'; import settings from '../utils/settings';
import * as userApi from '../api/user';
interface LoginInfo { interface LoginInfo {
username: string; username: string;
password: string; password: string;
} }
interface UserInfo {
username: string;
id: string;
roleId: string;
}
interface PrivilegeInfo { interface PrivilegeInfo {
"id": Number, "id": Number,
"roleId": Number, "roleId": Number,
@ -75,8 +67,8 @@ interface RoleInfo {
const router = useRouter(); const router = useRouter();
const param = reactive<LoginInfo>({ const param = reactive<LoginInfo>({
username: 'admin', username: 'root',
password: '123123' password: 'root'
}); });
const rules: FormRules = { const rules: FormRules = {
@ -95,7 +87,7 @@ const rules: FormRules = {
} }
] ]
}; };
const permiss: any = usePermissStore();
const login = ref<FormInstance>(); const login = ref<FormInstance>();
const submitForm = (formEl: FormInstance | undefined) => { const submitForm = (formEl: FormInstance | undefined) => {
if (!formEl) return; if (!formEl) return;
@ -116,47 +108,28 @@ const submitForm = (formEl: FormInstance | undefined) => {
return; return;
} }
const loading = ElLoading.service({ userApi.userLogin({
lock: true, username: param.username,
text: '请稍候', password: param.password
background: 'rgba(0, 0, 0, 0.7)', }).then(async (data: any) => {
});
await send_request('v1/user/login', "POST", {
userName: param.username,
passWord: param.password
}, async (data: UserInfo) => {
// //
if (!data) { if (!data) return;
ElMessage.error("用户名或密码错误");
return; console.log("login data", data, data.userInfo);
}
ElMessage.success('登录成功'); ElMessage.success('登录成功');
localStorage.setItem('ms_username', data.username); localStorage.setItem('ms_username', data.userInfo?.username);
localStorage.setItem('ms_user_id', data.id); localStorage.setItem('ms_realname', data.userInfo?.realname);
localStorage.setItem('ms_role_id', data.roleId); localStorage.setItem('ms_user_id', data.userInfo?.id);
localStorage.setItem('ms_role_id', data.userInfo?.role);
let defaultList = {};
await send_request('v1/role/list', "GET", {}, (roleList: Array<RoleInfo>) => {
for (let role of roleList) {
defaultList[role.id.toString()] = role.privileges.map((i: any) => i.module)
}
});
permiss.defaultList = defaultList;
permiss.key = defaultList[data.roleId];
if (typeof (permiss.key) === "undefined") return;
localStorage.setItem('ms_keys', JSON.stringify(permiss.key));
localStorage.setItem('ms_default_list', JSON.stringify(defaultList));
let targetRoute: any = router.currentRoute?.value?.query?.redirectTo let targetRoute: any = router.currentRoute?.value?.query?.redirectTo
if (targetRoute && !targetRoute.includes('/login')) { if (targetRoute && !targetRoute.includes('/login')) {
router.push(targetRoute); router.push(targetRoute);
} else { } else {
router.push('/'); router.push('/');
} }
}); })
loading.close();
}); });
}; };

View File

@ -114,20 +114,16 @@ Page({
let result = d.data; let result = d.data;
if (result.success) { if (result.success) {
// 登录成功 // 登录成功
if (result.data.userInfo.role != 2) { if ([3, 4, 5, 6].includes(result.data.userInfo.role)) {
wx.showModal({ wx.showModal({
title: '你不是社区居民', title: '你不是社区居民',
content: '请前往网页版登录', content: '管理员请前往网页版登录',
showCancel: false,
complete: (res) => { complete: (res) => {
if (res.cancel) { //
}
if (res.confirm) {
}
} }
}) })
return
} }
wx.setStorageSync("userInfo", result.data.userInfo); wx.setStorageSync("userInfo", result.data.userInfo);
console.log("userInfo", wx.getStorageSync("userInfo")) console.log("userInfo", wx.getStorageSync("userInfo"))