@befly-addon/admin 1.1.29 → 1.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apis/admin/cacheRefresh.ts +29 -24
- package/apis/admin/del.ts +12 -12
- package/apis/admin/detail.ts +9 -41
- package/apis/admin/ins.ts +28 -21
- package/apis/admin/list.ts +12 -12
- package/apis/admin/upd.ts +49 -14
- package/apis/api/all.ts +14 -10
- package/apis/api/list.ts +16 -25
- package/apis/auth/login.ts +55 -52
- package/apis/auth/sendSmsCode.ts +6 -6
- package/apis/dashboard/configStatus.ts +18 -18
- package/apis/dashboard/environmentInfo.ts +12 -12
- package/apis/dashboard/performanceMetrics.ts +5 -5
- package/apis/dashboard/permissionStats.ts +7 -7
- package/apis/dashboard/serviceStatus.ts +29 -29
- package/apis/dashboard/systemInfo.ts +5 -5
- package/apis/dashboard/systemOverview.ts +7 -7
- package/apis/dashboard/systemResources.ts +8 -8
- package/apis/dict/all.ts +24 -7
- package/apis/dict/del.ts +9 -17
- package/apis/dict/detail.ts +30 -16
- package/apis/dict/ins.ts +36 -18
- package/apis/dict/items.ts +27 -0
- package/apis/dict/list.ts +35 -10
- package/apis/dict/upd.ts +54 -20
- package/apis/dictType/all.ts +11 -0
- package/apis/dictType/del.ts +32 -0
- package/apis/dictType/detail.ts +17 -0
- package/apis/dictType/ins.ts +30 -0
- package/apis/dictType/list.ts +22 -0
- package/apis/dictType/upd.ts +42 -0
- package/apis/email/config.ts +4 -4
- package/apis/email/logList.ts +10 -10
- package/apis/email/send.ts +18 -18
- package/apis/email/verify.ts +5 -5
- package/apis/loginLog/list.ts +10 -10
- package/apis/menu/all.ts +17 -20
- package/apis/menu/list.ts +12 -13
- package/apis/operateLog/list.ts +10 -10
- package/apis/role/all.ts +7 -7
- package/apis/role/apiSave.ts +14 -16
- package/apis/role/apis.ts +24 -0
- package/apis/role/del.ts +27 -19
- package/apis/role/detail.ts +6 -7
- package/apis/role/ins.ts +10 -10
- package/apis/role/list.ts +11 -11
- package/apis/role/menuSave.ts +12 -14
- package/apis/role/menus.ts +24 -0
- package/apis/role/save.ts +14 -15
- package/apis/role/upd.ts +10 -10
- package/apis/sysConfig/all.ts +5 -6
- package/apis/sysConfig/del.ts +10 -10
- package/apis/sysConfig/get.ts +10 -11
- package/apis/sysConfig/ins.ts +11 -11
- package/apis/sysConfig/list.ts +9 -9
- package/apis/sysConfig/upd.ts +11 -11
- package/libs/emailHelper.ts +7 -7
- package/package.json +46 -34
- package/plugins/email.ts +9 -9
- package/tables/admin.json +0 -6
- package/tables/dict.json +13 -19
- package/tables/dictType.json +28 -0
- package/tables/role.json +4 -2
- package/views/403_1/index.vue +19 -3
- package/views/config/dict/components/edit.vue +76 -124
- package/views/config/dict/index.vue +142 -84
- package/views/config/dictType/components/edit.vue +105 -0
- package/views/config/dictType/index.vue +242 -0
- package/views/config/index.vue +12 -0
- package/views/config/system/components/edit.vue +36 -36
- package/views/config/system/index.vue +79 -50
- package/views/index/components/addonList.vue +3 -3
- package/views/index/components/environmentInfo.vue +10 -10
- package/views/index/components/operationLogs.vue +10 -10
- package/views/index/components/performanceMetrics.vue +8 -8
- package/views/index/components/quickActions.vue +3 -3
- package/views/index/components/serviceStatus.vue +19 -19
- package/views/index/components/systemNotifications.vue +12 -12
- package/views/index/components/systemOverview.vue +7 -7
- package/views/index/components/systemResources.vue +11 -11
- package/views/index/components/userInfo.vue +20 -19
- package/views/index/index.vue +12 -5
- package/views/log/email/index.vue +58 -51
- package/views/log/index.vue +12 -0
- package/views/log/login/index.vue +45 -38
- package/views/log/operate/index.vue +55 -48
- package/views/login_1/index.vue +191 -2
- package/views/people/admin/components/edit.vue +28 -29
- package/views/people/admin/index.vue +76 -40
- package/views/people/index.vue +12 -0
- package/views/permission/api/index.vue +21 -15
- package/views/permission/index.vue +12 -0
- package/views/permission/menu/index.vue +31 -16
- package/views/permission/role/components/api.vue +23 -23
- package/views/permission/role/components/edit.vue +18 -18
- package/views/permission/role/components/menu.vue +17 -19
- package/views/permission/role/index.vue +84 -49
- package/apis/admin/roleDetail.ts +0 -29
- package/apis/admin/roleSave.ts +0 -39
- package/apis/auth/logout.ts +0 -17
- package/apis/auth/register.ts +0 -43
- package/apis/dashboard/changelog.ts +0 -31
- package/apis/role/apiDetail.ts +0 -24
- package/apis/role/menuDetail.ts +0 -24
- package/views/403_1/meta.json +0 -4
- package/views/config/dict/meta.json +0 -4
- package/views/config/meta.json +0 -4
- package/views/config/system/meta.json +0 -4
- package/views/index/meta.json +0 -4
- package/views/log/email/meta.json +0 -4
- package/views/log/login/meta.json +0 -4
- package/views/log/meta.json +0 -4
- package/views/log/operate/meta.json +0 -4
- package/views/login_1/components/emailLoginForm.vue +0 -174
- package/views/login_1/components/registerForm.vue +0 -175
- package/views/login_1/components/welcomePanel.vue +0 -61
- package/views/login_1/meta.json +0 -4
- package/views/people/admin/meta.json +0 -4
- package/views/people/meta.json +0 -4
- package/views/permission/api/meta.json +0 -4
- package/views/permission/menu/meta.json +0 -4
- package/views/permission/meta.json +0 -4
- package/views/permission/role/meta.json +0 -4
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script setup>
|
|
14
|
-
import { Dialog as TDialog, Tree as TTree, Button as TButton, MessagePlugin } from
|
|
15
|
-
import { arrayToTree } from
|
|
16
|
-
import { $Http } from
|
|
14
|
+
import { Dialog as TDialog, Tree as TTree, Button as TButton, MessagePlugin } from "tdesign-vue-next";
|
|
15
|
+
import { arrayToTree } from "befly-vite/utils/arrayToTree";
|
|
16
|
+
import { $Http } from "@/plugins/http";
|
|
17
17
|
|
|
18
18
|
const $Prop = defineProps({
|
|
19
19
|
modelValue: {
|
|
@@ -26,7 +26,7 @@ const $Prop = defineProps({
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const $Emit = defineEmits([
|
|
29
|
+
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
30
30
|
|
|
31
31
|
const $Data = $ref({
|
|
32
32
|
visible: false,
|
|
@@ -51,20 +51,19 @@ const $Method = {
|
|
|
51
51
|
onClose() {
|
|
52
52
|
$Data.visible = false;
|
|
53
53
|
setTimeout(() => {
|
|
54
|
-
$Emit(
|
|
54
|
+
$Emit("update:modelValue", false);
|
|
55
55
|
}, 300);
|
|
56
56
|
},
|
|
57
57
|
|
|
58
58
|
// 加载菜单树(用于配置权限)
|
|
59
59
|
async apiMenuAll() {
|
|
60
60
|
try {
|
|
61
|
-
const res = await $Http(
|
|
61
|
+
const res = await $Http("/addon/admin/menu/all");
|
|
62
62
|
// menuAll 返回的 data 直接就是菜单数组
|
|
63
63
|
const menuList = Array.isArray(res.data) ? res.data : [];
|
|
64
64
|
$Data.menuTreeData = arrayToTree(menuList);
|
|
65
65
|
} catch (error) {
|
|
66
|
-
|
|
67
|
-
MessagePlugin.error('加载菜单失败');
|
|
66
|
+
MessagePlugin.error("加载菜单失败");
|
|
68
67
|
}
|
|
69
68
|
},
|
|
70
69
|
|
|
@@ -73,14 +72,14 @@ const $Method = {
|
|
|
73
72
|
if (!$Prop.rowData.id) return;
|
|
74
73
|
|
|
75
74
|
try {
|
|
76
|
-
const res = await $Http(
|
|
77
|
-
|
|
75
|
+
const res = await $Http("/addon/admin/role/menus", {
|
|
76
|
+
roleCode: $Prop.rowData.code
|
|
78
77
|
});
|
|
79
78
|
|
|
80
|
-
//
|
|
79
|
+
// menus 返回的 data 直接就是菜单 ID 数组
|
|
81
80
|
$Data.menuTreeCheckedKeys = Array.isArray(res.data) ? res.data : [];
|
|
82
81
|
} catch (error) {
|
|
83
|
-
|
|
82
|
+
MessagePlugin.error("加载数据失败");
|
|
84
83
|
}
|
|
85
84
|
},
|
|
86
85
|
|
|
@@ -89,21 +88,20 @@ const $Method = {
|
|
|
89
88
|
try {
|
|
90
89
|
$Data.submitting = true;
|
|
91
90
|
|
|
92
|
-
const res = await $Http(
|
|
93
|
-
|
|
91
|
+
const res = await $Http("/addon/admin/role/menuSave", {
|
|
92
|
+
roleCode: $Prop.rowData.code,
|
|
94
93
|
menuIds: $Data.menuTreeCheckedKeys
|
|
95
94
|
});
|
|
96
95
|
|
|
97
96
|
if (res.code === 0) {
|
|
98
|
-
MessagePlugin.success(
|
|
97
|
+
MessagePlugin.success("保存成功");
|
|
99
98
|
$Data.visible = false;
|
|
100
|
-
$Emit(
|
|
99
|
+
$Emit("success");
|
|
101
100
|
} else {
|
|
102
|
-
MessagePlugin.error(res.msg ||
|
|
101
|
+
MessagePlugin.error(res.msg || "保存失败");
|
|
103
102
|
}
|
|
104
103
|
} catch (error) {
|
|
105
|
-
|
|
106
|
-
MessagePlugin.error('保存失败');
|
|
104
|
+
MessagePlugin.error("保存失败");
|
|
107
105
|
} finally {
|
|
108
106
|
$Data.submitting = false;
|
|
109
107
|
}
|
|
@@ -18,7 +18,16 @@
|
|
|
18
18
|
</div>
|
|
19
19
|
<div class="main-content">
|
|
20
20
|
<div class="main-table">
|
|
21
|
-
<TTable
|
|
21
|
+
<TTable
|
|
22
|
+
:data="$Data.tableData"
|
|
23
|
+
:columns="$Data.columns"
|
|
24
|
+
:loading="$Data.loading"
|
|
25
|
+
:active-row-keys="$Data.activeRowKeys"
|
|
26
|
+
row-key="id"
|
|
27
|
+
height="calc(100vh - var(--search-height) - var(--pagination-height) - var(--layout-gap) * 4)"
|
|
28
|
+
active-row-type="single"
|
|
29
|
+
@active-change="$Method.onActiveChange"
|
|
30
|
+
>
|
|
22
31
|
<template #state="{ row }">
|
|
23
32
|
<TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
|
|
24
33
|
<TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
|
|
@@ -74,20 +83,27 @@
|
|
|
74
83
|
</template>
|
|
75
84
|
|
|
76
85
|
<script setup>
|
|
77
|
-
import { Button as TButton, Table as TTable, Tag as TTag, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from
|
|
78
|
-
import ILucidePlus from
|
|
79
|
-
import ILucideRotateCw from
|
|
80
|
-
import ILucidePencil from
|
|
81
|
-
import ILucideSettings from
|
|
82
|
-
import ILucideCode from
|
|
83
|
-
import ILucideTrash2 from
|
|
84
|
-
import ILucideChevronDown from
|
|
85
|
-
import EditDialog from
|
|
86
|
-
import MenuDialog from
|
|
87
|
-
import ApiDialog from
|
|
88
|
-
import DetailPanel from
|
|
89
|
-
import { $Http } from
|
|
90
|
-
import { withDefaultColumns } from
|
|
86
|
+
import { Button as TButton, Table as TTable, Tag as TTag, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from "tdesign-vue-next";
|
|
87
|
+
import ILucidePlus from "~icons/lucide/plus";
|
|
88
|
+
import ILucideRotateCw from "~icons/lucide/rotate-cw";
|
|
89
|
+
import ILucidePencil from "~icons/lucide/pencil";
|
|
90
|
+
import ILucideSettings from "~icons/lucide/settings";
|
|
91
|
+
import ILucideCode from "~icons/lucide/code";
|
|
92
|
+
import ILucideTrash2 from "~icons/lucide/trash-2";
|
|
93
|
+
import ILucideChevronDown from "~icons/lucide/chevron-down";
|
|
94
|
+
import EditDialog from "./components/edit.vue";
|
|
95
|
+
import MenuDialog from "./components/menu.vue";
|
|
96
|
+
import ApiDialog from "./components/api.vue";
|
|
97
|
+
import DetailPanel from "@/components/DetailPanel.vue";
|
|
98
|
+
import { $Http } from "@/plugins/http";
|
|
99
|
+
import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
|
|
100
|
+
|
|
101
|
+
definePage({
|
|
102
|
+
meta: {
|
|
103
|
+
title: "角色管理",
|
|
104
|
+
order: 1
|
|
105
|
+
}
|
|
106
|
+
});
|
|
91
107
|
|
|
92
108
|
// 响应式数据
|
|
93
109
|
const $Data = $ref({
|
|
@@ -96,25 +112,25 @@ const $Data = $ref({
|
|
|
96
112
|
activeRowKeys: [],
|
|
97
113
|
currentRow: null,
|
|
98
114
|
columns: withDefaultColumns([
|
|
99
|
-
{ colKey:
|
|
100
|
-
{ colKey:
|
|
101
|
-
{ colKey:
|
|
102
|
-
{ colKey:
|
|
103
|
-
{ colKey:
|
|
104
|
-
{ colKey:
|
|
105
|
-
{ colKey:
|
|
115
|
+
{ colKey: "id", title: "ID" },
|
|
116
|
+
{ colKey: "name", title: "角色名称" },
|
|
117
|
+
{ colKey: "code", title: "角色代码" },
|
|
118
|
+
{ colKey: "description", title: "描述" },
|
|
119
|
+
{ colKey: "sort", title: "排序" },
|
|
120
|
+
{ colKey: "state", title: "状态" },
|
|
121
|
+
{ colKey: "operation", title: "操作" }
|
|
106
122
|
]),
|
|
107
123
|
pagerConfig: {
|
|
108
124
|
currentPage: 1,
|
|
109
125
|
limit: 30,
|
|
110
126
|
total: 0,
|
|
111
|
-
align:
|
|
112
|
-
layout:
|
|
127
|
+
align: "right",
|
|
128
|
+
layout: "total, prev, pager, next, jumper"
|
|
113
129
|
},
|
|
114
130
|
editVisible: false,
|
|
115
131
|
menuVisible: false,
|
|
116
132
|
apiVisible: false,
|
|
117
|
-
actionType:
|
|
133
|
+
actionType: "add",
|
|
118
134
|
rowData: {}
|
|
119
135
|
});
|
|
120
136
|
|
|
@@ -127,7 +143,7 @@ const $Method = {
|
|
|
127
143
|
async apiRoleList() {
|
|
128
144
|
$Data.loading = true;
|
|
129
145
|
try {
|
|
130
|
-
const res = await $Http(
|
|
146
|
+
const res = await $Http("/addon/admin/role/list", {
|
|
131
147
|
page: $Data.pagerConfig.currentPage,
|
|
132
148
|
limit: $Data.pagerConfig.limit
|
|
133
149
|
});
|
|
@@ -143,8 +159,7 @@ const $Method = {
|
|
|
143
159
|
$Data.activeRowKeys = [];
|
|
144
160
|
}
|
|
145
161
|
} catch (error) {
|
|
146
|
-
|
|
147
|
-
MessagePlugin.error('加载数据失败');
|
|
162
|
+
MessagePlugin.error("加载数据失败");
|
|
148
163
|
} finally {
|
|
149
164
|
$Data.loading = false;
|
|
150
165
|
}
|
|
@@ -152,22 +167,43 @@ const $Method = {
|
|
|
152
167
|
|
|
153
168
|
// 删除角色
|
|
154
169
|
async apiRoleDel(row) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
let dialog = null;
|
|
171
|
+
let destroyed = false;
|
|
172
|
+
|
|
173
|
+
const destroy = () => {
|
|
174
|
+
if (destroyed) return;
|
|
175
|
+
destroyed = true;
|
|
176
|
+
if (dialog && typeof dialog.destroy === "function") {
|
|
177
|
+
dialog.destroy();
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
dialog = DialogPlugin.confirm({
|
|
182
|
+
header: "确认删除",
|
|
183
|
+
body: `确认删除角色“${row.name}”吗?`,
|
|
184
|
+
status: "warning",
|
|
185
|
+
confirmBtn: "删除",
|
|
186
|
+
cancelBtn: "取消",
|
|
187
|
+
onConfirm: async () => {
|
|
188
|
+
if (dialog && typeof dialog.setConfirmLoading === "function") {
|
|
189
|
+
dialog.setConfirmLoading(true);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
await $Http("/addon/admin/role/del", { id: row.id });
|
|
194
|
+
MessagePlugin.success("删除成功");
|
|
195
|
+
destroy();
|
|
196
|
+
await $Method.apiRoleList();
|
|
197
|
+
} catch (error) {
|
|
198
|
+
MessagePlugin.error("删除失败");
|
|
199
|
+
} finally {
|
|
200
|
+
if (dialog && typeof dialog.setConfirmLoading === "function") {
|
|
201
|
+
dialog.setConfirmLoading(false);
|
|
202
|
+
}
|
|
167
203
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
204
|
+
},
|
|
205
|
+
onClose: () => {
|
|
206
|
+
destroy();
|
|
171
207
|
}
|
|
172
208
|
});
|
|
173
209
|
},
|
|
@@ -207,13 +243,13 @@ const $Method = {
|
|
|
207
243
|
onAction(command, rowData) {
|
|
208
244
|
$Data.actionType = command;
|
|
209
245
|
$Data.rowData = rowData;
|
|
210
|
-
if (command ===
|
|
246
|
+
if (command === "add" || command === "upd") {
|
|
211
247
|
$Data.editVisible = true;
|
|
212
|
-
} else if (command ===
|
|
248
|
+
} else if (command === "menu") {
|
|
213
249
|
$Data.menuVisible = true;
|
|
214
|
-
} else if (command ===
|
|
250
|
+
} else if (command === "api") {
|
|
215
251
|
$Data.apiVisible = true;
|
|
216
|
-
} else if (command ===
|
|
252
|
+
} else if (command === "del") {
|
|
217
253
|
$Method.apiRoleDel(rowData);
|
|
218
254
|
}
|
|
219
255
|
}
|
|
@@ -223,6 +259,5 @@ $Method.initData();
|
|
|
223
259
|
</script>
|
|
224
260
|
|
|
225
261
|
<style scoped lang="scss">
|
|
226
|
-
|
|
227
|
-
}
|
|
262
|
+
/* page styles */
|
|
228
263
|
</style>
|
package/apis/admin/roleDetail.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: '获取管理员角色',
|
|
3
|
-
handler: async (befly, ctx) => {
|
|
4
|
-
// 查询管理员信息(框架自动转换为小驼峰)
|
|
5
|
-
const admin = await befly.db.getOne({
|
|
6
|
-
table: 'addon_admin_admin',
|
|
7
|
-
where: { id: ctx.body.adminId }
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
if (!admin) {
|
|
11
|
-
return befly.tool.No('管理员不存在');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 如果有角色编码,查询角色详细信息(使用 roleCode 而非 roleId)
|
|
15
|
-
let roleInfo = null;
|
|
16
|
-
if (admin.roleCode) {
|
|
17
|
-
roleInfo = await befly.db.getOne({
|
|
18
|
-
table: 'addon_admin_role',
|
|
19
|
-
where: { code: admin.roleCode }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return befly.tool.Yes('操作成功', {
|
|
24
|
-
roleId: admin.roleId,
|
|
25
|
-
roleCode: admin.roleCode,
|
|
26
|
-
role: roleInfo
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
};
|
package/apis/admin/roleSave.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: '管理员角色保存',
|
|
3
|
-
fields: {
|
|
4
|
-
roleCode: {
|
|
5
|
-
name: '角色编码',
|
|
6
|
-
type: 'string',
|
|
7
|
-
min: 2,
|
|
8
|
-
max: 50,
|
|
9
|
-
regexp: '^[a-zA-Z0-9_]+$'
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
handler: async (befly, ctx) => {
|
|
13
|
-
// 查询角色是否存在(使用 roleCode 而非 roleId)
|
|
14
|
-
const role = await befly.db.getOne({
|
|
15
|
-
table: 'addon_admin_role',
|
|
16
|
-
where: { code: ctx.body.roleCode }
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
if (!role) {
|
|
20
|
-
return befly.tool.No('角色不存在');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// 根据角色编码判断角色类型(硬编码规则)
|
|
24
|
-
const roleType = role.code === 'dev' || role.code === 'admin' ? 'admin' : 'user';
|
|
25
|
-
|
|
26
|
-
// 更新管理员的角色ID、角色编码和角色类型
|
|
27
|
-
await befly.db.updData({
|
|
28
|
-
table: 'addon_admin_admin',
|
|
29
|
-
where: { id: ctx.body.id },
|
|
30
|
-
data: {
|
|
31
|
-
roleId: role.id,
|
|
32
|
-
roleCode: role.code,
|
|
33
|
-
roleType: roleType
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return befly.tool.Yes('操作成功');
|
|
38
|
-
}
|
|
39
|
-
};
|
package/apis/auth/logout.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: '退出登录',
|
|
3
|
-
handler: async (befly, ctx) => {
|
|
4
|
-
// JWT token 是无状态的,前端删除 token 即可
|
|
5
|
-
// 如果需要实现 token 黑名单,可以在这里将 token 加入 Redis 黑名单
|
|
6
|
-
|
|
7
|
-
const token = ctx.headers.authorization?.replace('Bearer ', '');
|
|
8
|
-
|
|
9
|
-
if (token && befly.redis) {
|
|
10
|
-
// 将 token 加入黑名单,有效期设置为 token 的剩余有效期
|
|
11
|
-
const key = `token_blacklist:${token}`;
|
|
12
|
-
await befly.redis.set(key, '1', 'EX', 7 * 24 * 60 * 60); // 7天
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return befly.tool.Yes('退出成功');
|
|
16
|
-
}
|
|
17
|
-
};
|
package/apis/auth/register.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import adminTable from '../../tables/admin.json';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
name: '管理员注册',
|
|
5
|
-
auth: false,
|
|
6
|
-
fields: {
|
|
7
|
-
name: adminTable.name,
|
|
8
|
-
email: adminTable.email,
|
|
9
|
-
password: adminTable.password
|
|
10
|
-
},
|
|
11
|
-
required: ['name', 'email', 'password'],
|
|
12
|
-
handler: async (befly, ctx) => {
|
|
13
|
-
// 检查邮箱是否已存在
|
|
14
|
-
const existingAdmin = await befly.db.getOne({
|
|
15
|
-
table: 'addon_admin_admin',
|
|
16
|
-
where: { email: ctx.body.email }
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
if (existingAdmin) {
|
|
20
|
-
return befly.tool.No('该邮箱已被注册');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// 加密密码
|
|
24
|
-
const hashedPassword = await befly.cipher.hashPassword(ctx.body.password);
|
|
25
|
-
|
|
26
|
-
// 创建管理员
|
|
27
|
-
const adminId = await befly.db.insData({
|
|
28
|
-
table: 'addon_admin_admin',
|
|
29
|
-
data: {
|
|
30
|
-
name: ctx.body.name,
|
|
31
|
-
email: ctx.body.email,
|
|
32
|
-
password: hashedPassword,
|
|
33
|
-
role: 'user' // 默认为普通用户,state 由框架自动设置为 1
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return befly.tool.Yes('注册成功', {
|
|
38
|
-
id: adminId,
|
|
39
|
-
name: ctx.body.name,
|
|
40
|
-
email: ctx.body.email
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: '获取更新日志',
|
|
3
|
-
handler: async (befly, ctx) => {
|
|
4
|
-
// 更新日志数据(实际项目中可以从配置文件或数据库读取)
|
|
5
|
-
const changelog = [
|
|
6
|
-
{
|
|
7
|
-
version: 'v1.0.0',
|
|
8
|
-
date: '2025-10-25',
|
|
9
|
-
changes: ['新增角色权限管理功能', '新增菜单权限分配功能', '新增接口权限管理功能', '优化菜单同步性能', '优化字段类型验证', '修复数组类型字段验证bug']
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
version: 'v0.9.0',
|
|
13
|
-
date: '2025-10-20',
|
|
14
|
-
changes: ['初始版本发布', '完成基础框架搭建', '实现用户认证功能', '实现RBAC权限系统']
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
version: 'v0.8.0',
|
|
18
|
-
date: '2025-10-15',
|
|
19
|
-
changes: ['完成数据库设计', '实现核心API', '添加字段验证器', '集成Redis缓存']
|
|
20
|
-
}
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
// 根据 limit 参数返回指定数量的日志
|
|
24
|
-
const limit = ctx.body.limit || 5;
|
|
25
|
-
const lists = changelog.slice(0, limit);
|
|
26
|
-
|
|
27
|
-
return befly.tool.Yes('获取成功', {
|
|
28
|
-
lists: lists
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
package/apis/role/apiDetail.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: '获取角色接口权限',
|
|
3
|
-
handler: async (befly, ctx) => {
|
|
4
|
-
// 查询角色信息
|
|
5
|
-
const role = await befly.db.getOne({
|
|
6
|
-
table: 'addon_admin_role',
|
|
7
|
-
where: { id: ctx.body.roleId }
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
if (!role) {
|
|
11
|
-
return befly.tool.No('角色不存在');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 解析接口ID列表(逗号分隔的字符串转为数组)
|
|
15
|
-
const apiIds = role.apis
|
|
16
|
-
? role.apis
|
|
17
|
-
.split(',')
|
|
18
|
-
.map((id: string) => parseInt(id.trim()))
|
|
19
|
-
.filter((id: number) => !isNaN(id))
|
|
20
|
-
: [];
|
|
21
|
-
|
|
22
|
-
return befly.tool.Yes('操作成功', { apiIds });
|
|
23
|
-
}
|
|
24
|
-
};
|
package/apis/role/menuDetail.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: '获取角色菜单权限',
|
|
3
|
-
handler: async (befly, ctx) => {
|
|
4
|
-
// 查询角色信息
|
|
5
|
-
const role = await befly.db.getOne({
|
|
6
|
-
table: 'addon_admin_role',
|
|
7
|
-
where: { id: ctx.body.roleId }
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
if (!role) {
|
|
11
|
-
return befly.tool.No('角色不存在');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 解析菜单ID列表(逗号分隔的字符串转为数组)
|
|
15
|
-
const menuIds = role.menus
|
|
16
|
-
? role.menus
|
|
17
|
-
.split(',')
|
|
18
|
-
.map((id: string) => parseInt(id.trim()))
|
|
19
|
-
.filter((id: number) => !isNaN(id))
|
|
20
|
-
: [];
|
|
21
|
-
|
|
22
|
-
return befly.tool.Yes('操作成功', menuIds);
|
|
23
|
-
}
|
|
24
|
-
};
|
package/views/403_1/meta.json
DELETED
package/views/config/meta.json
DELETED
package/views/index/meta.json
DELETED
package/views/log/meta.json
DELETED