befly-admin-ui 1.10.0 → 1.10.2

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.
Files changed (34) hide show
  1. package/components/detailPanel.vue +52 -54
  2. package/components/pageDialog.vue +131 -117
  3. package/components/pageTableDetail.vue +381 -398
  4. package/layouts/default.vue +212 -215
  5. package/package.json +2 -2
  6. package/views/config/dict/components/edit.vue +83 -60
  7. package/views/config/dict/index.vue +53 -68
  8. package/views/config/dictType/components/edit.vue +81 -57
  9. package/views/config/dictType/index.vue +39 -51
  10. package/views/config/system/components/edit.vue +97 -86
  11. package/views/config/system/index.vue +37 -51
  12. package/views/index/components/addonList.vue +14 -11
  13. package/views/index/components/environmentInfo.vue +25 -22
  14. package/views/index/components/operationLogs.vue +20 -16
  15. package/views/index/components/performanceMetrics.vue +24 -21
  16. package/views/index/components/serviceStatus.vue +26 -22
  17. package/views/index/components/systemNotifications.vue +24 -19
  18. package/views/index/components/systemOverview.vue +368 -385
  19. package/views/index/components/systemResources.vue +22 -19
  20. package/views/index/components/userInfo.vue +56 -56
  21. package/views/log/email/index.vue +99 -100
  22. package/views/log/error/index.vue +112 -130
  23. package/views/log/login/index.vue +17 -28
  24. package/views/log/operate/index.vue +33 -46
  25. package/views/login_1/index.vue +50 -32
  26. package/views/people/admin/components/edit.vue +1 -1
  27. package/views/people/admin/index.vue +28 -29
  28. package/views/permission/api/index.vue +46 -58
  29. package/views/permission/menu/index.vue +46 -52
  30. package/views/permission/role/components/api.vue +143 -144
  31. package/views/permission/role/components/edit.vue +74 -52
  32. package/views/permission/role/components/menu.vue +119 -121
  33. package/views/permission/role/index.vue +49 -63
  34. package/views/resource/gallery/index.vue +78 -88
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <PageDialog v-model="dialogVisible" title="菜单权限" width="900px" :confirm-loading="$Data.submitting" @confirm="onSubmit">
2
+ <PageDialog v-model="$Computed.dialogVisible" title="菜单权限" width="900px" :confirm-loading="$Data.submitting" @confirm="$Method.onSubmit">
3
3
  <div class="comp-role-menu">
4
4
  <!-- 搜索框 -->
5
5
  <div class="search-box">
6
- <TInput v-model="$Data.searchText" placeholder="搜索菜单名称或路径" clearable @change="onSearch">
6
+ <TInput v-model="$Data.searchText" placeholder="搜索菜单名称或路径" clearable @change="$Method.onSearch">
7
7
  <template #prefix-icon>
8
8
  <SearchIcon />
9
9
  </template>
@@ -38,7 +38,7 @@ import { computed, reactive } from "vue";
38
38
  import { CheckboxGroup as TCheckboxGroup, Checkbox as TCheckbox, Input as TInput, MessagePlugin } from "tdesign-vue-next";
39
39
  import { SearchIcon } from "tdesign-icons-vue-next";
40
40
  import PageDialog from "befly-admin-ui/components/pageDialog.vue";
41
- import { $Http } from "@/plugins/http";
41
+ import { $Http } from "@/plugins/http.js";
42
42
  import { arrayToTree } from "befly-admin-ui/utils/arrayToTree";
43
43
 
44
44
  const $Prop = defineProps({
@@ -54,13 +54,6 @@ const $Prop = defineProps({
54
54
 
55
55
  const $Emit = defineEmits(["update:modelValue", "success"]);
56
56
 
57
- const dialogVisible = computed({
58
- get: () => $Prop.modelValue,
59
- set: (value) => {
60
- $Emit("update:modelValue", value);
61
- }
62
- });
63
-
64
57
  const $Data = reactive({
65
58
  submitting: false,
66
59
  searchText: "",
@@ -69,130 +62,135 @@ const $Data = reactive({
69
62
  checkedMenuPaths: []
70
63
  });
71
64
 
72
- async function initData() {
73
- await Promise.all([apiMenuAll(), apiRoleMenuDetail()]);
74
- $Data.filteredMenuGroups = $Data.menuGroups;
75
- }
76
-
77
- async function apiMenuAll() {
78
- try {
79
- const res = await $Http("/core/menu/all", {}, [""]);
80
- const lists = Array.isArray(res?.data?.lists) ? res.data.lists : [];
81
-
82
- const treeResult = arrayToTree(lists, "path", "parentPath", "children", "sort");
83
- const roots = Array.isArray(treeResult?.tree) ? treeResult.tree : [];
84
-
85
- const groups = [];
86
- for (const root of roots) {
87
- const rootPath = typeof root?.path === "string" ? root.path : "";
88
- const rootName = typeof root?.name === "string" ? root.name : "";
89
-
90
- const menus = [];
91
-
92
- const walk = (node, depth) => {
93
- const name = typeof node["name"] === "string" ? String(node["name"]) : "";
94
- const path = typeof node["path"] === "string" ? String(node["path"]) : "";
95
- if (path.length > 0) {
96
- menus.push({
97
- value: path,
98
- name: name,
99
- path: path,
100
- depth: depth,
101
- label: `${name} ${path}`.trim()
102
- });
103
- }
65
+ const $Computed = reactive({
66
+ dialogVisible: computed({
67
+ get: () => $Prop.modelValue,
68
+ set: (value) => {
69
+ $Emit("update:modelValue", value);
70
+ }
71
+ })
72
+ });
104
73
 
105
- const children = Array.isArray(node["children"]) ? node["children"] : [];
106
- for (const child of children) {
107
- if (child && typeof child === "object") {
108
- walk(child, depth + 1);
74
+ const $Method = {
75
+ async initData() {
76
+ await Promise.all([$Method.apiMenuAll(), $Method.apiRoleMenuDetail()]);
77
+ $Data.filteredMenuGroups = $Data.menuGroups;
78
+ },
79
+ async apiMenuAll() {
80
+ try {
81
+ const res = await $Http("/core/menu/all", {}, [""]);
82
+ const lists = Array.isArray(res?.data?.lists) ? res.data.lists : [];
83
+
84
+ const treeResult = arrayToTree(lists, "path", "parentPath", "children", "sort");
85
+ const roots = Array.isArray(treeResult?.tree) ? treeResult.tree : [];
86
+
87
+ const groups = [];
88
+ for (const root of roots) {
89
+ const rootPath = typeof root?.path === "string" ? root.path : "";
90
+ const rootName = typeof root?.name === "string" ? root.name : "";
91
+ const menus = [];
92
+
93
+ const walk = (node, depth) => {
94
+ const name = typeof node["name"] === "string" ? String(node["name"]) : "";
95
+ const path = typeof node["path"] === "string" ? String(node["path"]) : "";
96
+ if (path.length > 0) {
97
+ menus.push({
98
+ value: path,
99
+ name: name,
100
+ path: path,
101
+ depth: depth,
102
+ label: `${name} ${path}`.trim()
103
+ });
109
104
  }
110
- }
111
- };
112
105
 
113
- walk(root, 0);
114
-
115
- const groupTitle = rootName.length > 0 ? rootName : rootPath;
116
- groups.push({
117
- name: rootPath.length > 0 ? rootPath : groupTitle,
118
- title: groupTitle.length > 0 ? groupTitle : "未命名菜单",
119
- menus: menus
120
- });
121
- }
106
+ const children = Array.isArray(node["children"]) ? node["children"] : [];
107
+ for (const child of children) {
108
+ if (child && typeof child === "object") {
109
+ walk(child, depth + 1);
110
+ }
111
+ }
112
+ };
122
113
 
123
- $Data.menuGroups = groups;
124
- } catch (error) {
125
- MessagePlugin.error(error.msg || error.message || "加载菜单失败");
126
- }
127
- }
114
+ walk(root, 0);
128
115
 
129
- async function apiRoleMenuDetail() {
130
- if (!$Prop.rowData.id) return;
131
-
132
- try {
133
- const res = await $Http(
134
- "/core/role/menus",
135
- {
136
- roleCode: $Prop.rowData.code
137
- },
138
- [""]
139
- );
140
-
141
- $Data.checkedMenuPaths = Array.isArray(res.data) ? res.data : [];
142
- } catch (error) {
143
- MessagePlugin.error(error.msg || error.message || "加载数据失败");
144
- }
145
- }
116
+ const groupTitle = rootName.length > 0 ? rootName : rootPath;
117
+ groups.push({
118
+ name: rootPath.length > 0 ? rootPath : groupTitle,
119
+ title: groupTitle.length > 0 ? groupTitle : "未命名菜单",
120
+ menus: menus
121
+ });
122
+ }
146
123
 
147
- function onSearch() {
148
- const kw = typeof $Data.searchText === "string" ? $Data.searchText.trim().toLowerCase() : "";
149
- if (kw.length === 0) {
150
- $Data.filteredMenuGroups = $Data.menuGroups;
151
- return;
152
- }
124
+ $Data.menuGroups = groups;
125
+ } catch (error) {
126
+ MessagePlugin.error(error.msg || error.message || "加载菜单失败");
127
+ }
128
+ },
129
+ async apiRoleMenuDetail() {
130
+ if (!$Prop.rowData.id) return;
131
+
132
+ try {
133
+ const res = await $Http(
134
+ "/core/role/menus",
135
+ {
136
+ roleCode: $Prop.rowData.code
137
+ },
138
+ [""]
139
+ );
140
+
141
+ $Data.checkedMenuPaths = Array.isArray(res.data) ? res.data : [];
142
+ } catch (error) {
143
+ MessagePlugin.error(error.msg || error.message || "加载数据失败");
144
+ }
145
+ },
146
+ onSearch() {
147
+ const kw = typeof $Data.searchText === "string" ? $Data.searchText.trim().toLowerCase() : "";
148
+ if (kw.length === 0) {
149
+ $Data.filteredMenuGroups = $Data.menuGroups;
150
+ return;
151
+ }
153
152
 
154
- $Data.filteredMenuGroups = $Data.menuGroups
155
- .map((group) => {
156
- const groupRecord = group && typeof group === "object" ? group : null;
157
- const groupMenus = groupRecord && Array.isArray(groupRecord["menus"]) ? groupRecord["menus"] : [];
153
+ $Data.filteredMenuGroups = $Data.menuGroups
154
+ .map((group) => {
155
+ const groupRecord = group && typeof group === "object" ? group : null;
156
+ const groupMenus = groupRecord && Array.isArray(groupRecord["menus"]) ? groupRecord["menus"] : [];
157
+ const menus = groupMenus.filter((menu) => {
158
+ const menuRecord = menu && typeof menu === "object" ? menu : null;
159
+ const label = menuRecord && typeof menuRecord["label"] === "string" ? String(menuRecord["label"]) : "";
160
+ return label.toLowerCase().includes(kw);
161
+ });
162
+
163
+ return {
164
+ name: groupRecord && typeof groupRecord["name"] === "string" ? String(groupRecord["name"]) : "",
165
+ title: groupRecord && typeof groupRecord["title"] === "string" ? String(groupRecord["title"]) : "",
166
+ menus: menus
167
+ };
168
+ })
169
+ .filter((group) => group.menus.length > 0);
170
+ },
171
+ async onSubmit(context) {
172
+ try {
173
+ $Data.submitting = true;
158
174
 
159
- const menus = groupMenus.filter((menu) => {
160
- const menuRecord = menu && typeof menu === "object" ? menu : null;
161
- const label = menuRecord && typeof menuRecord["label"] === "string" ? String(menuRecord["label"]) : "";
162
- return label.toLowerCase().includes(kw);
175
+ await $Http("/core/role/menuSave", {
176
+ roleCode: $Prop.rowData.code,
177
+ menuPaths: $Data.checkedMenuPaths
163
178
  });
164
179
 
165
- return {
166
- name: groupRecord && typeof groupRecord["name"] === "string" ? String(groupRecord["name"]) : "",
167
- title: groupRecord && typeof groupRecord["title"] === "string" ? String(groupRecord["title"]) : "",
168
- menus: menus
169
- };
170
- })
171
- .filter((group) => group.menus.length > 0);
172
- }
173
-
174
- async function onSubmit(context) {
175
- try {
176
- $Data.submitting = true;
177
-
178
- const res = await $Http("/core/role/menuSave", {
179
- roleCode: $Prop.rowData.code,
180
- menuPaths: $Data.checkedMenuPaths
181
- });
182
-
183
- MessagePlugin.success("保存成功");
184
- $Emit("success");
185
- if (context && typeof context.close === "function") {
186
- context.close();
180
+ MessagePlugin.success("保存成功");
181
+ $Emit("success");
182
+ if (context && typeof context.close === "function") {
183
+ context.close();
184
+ }
185
+ } catch (error) {
186
+ MessagePlugin.error(error.msg || error.message || "保存失败");
187
+ } finally {
188
+ $Data.submitting = false;
187
189
  }
188
- } catch (error) {
189
- MessagePlugin.error(error.msg || error.message || "保存失败");
190
- } finally {
191
- $Data.submitting = false;
192
190
  }
193
- }
191
+ };
194
192
 
195
- initData();
193
+ $Method.initData();
196
194
  </script>
197
195
 
198
196
  <style scoped lang="scss">
@@ -1,21 +1,13 @@
1
1
  <template>
2
2
  <PageTableDetail class="page-role page-table" :columns="$Data.columns" :endpoints="$Data.endpoints" :table-slot-names="['state', 'menuCount', 'apiCount']">
3
3
  <template #toolLeft>
4
- <TButton theme="primary" @click="onAdd">
4
+ <TButton theme="primary" @click="$Method.onAdd">
5
5
  <template #icon>
6
6
  <AddIcon />
7
7
  </template>
8
8
  </TButton>
9
9
  </template>
10
10
 
11
- <template #toolRight="scope">
12
- <TButton shape="circle" @click="onReload(scope.reload)">
13
- <template #icon>
14
- <RefreshIcon />
15
- </template>
16
- </TButton>
17
- </template>
18
-
19
11
  <template #state="{ row }">
20
12
  <TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
21
13
  <TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
@@ -23,15 +15,15 @@
23
15
  </template>
24
16
 
25
17
  <template #menuCount="{ row }">
26
- {{ getPathCount(row.menus) }}
18
+ {{ $Method.getPathCount(row.menus) }}
27
19
  </template>
28
20
 
29
21
  <template #apiCount="{ row }">
30
- {{ getPathCount(row.apis) }}
22
+ {{ $Method.getPathCount(row.apis) }}
31
23
  </template>
32
24
 
33
25
  <template #operation="{ row, deleteRow }">
34
- <TDropdown trigger="click" placement="bottom-right" @click="onDropdownAction($event, row, deleteRow)">
26
+ <TDropdown trigger="click" placement="bottom-right" @click="$Method.onDropdownAction($event, row, deleteRow)">
35
27
  <TButton theme="primary" size="small">
36
28
  操作
37
29
  <template #suffix><ChevronDownIcon /></template>
@@ -59,13 +51,13 @@
59
51
 
60
52
  <template #dialogs="scope">
61
53
  <!-- 编辑对话框组件 -->
62
- <EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="onDialogSuccess(scope.reload)" />
54
+ <EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.onDialogSuccess(scope.reload)" />
63
55
 
64
56
  <!-- 菜单权限对话框组件 -->
65
- <MenuDialog v-if="$Data.menuVisible" v-model="$Data.menuVisible" :row-data="$Data.rowData" @success="onDialogSuccess(scope.reload)" />
57
+ <MenuDialog v-if="$Data.menuVisible" v-model="$Data.menuVisible" :row-data="$Data.rowData" @success="$Method.onDialogSuccess(scope.reload)" />
66
58
 
67
59
  <!-- 接口权限对话框组件 -->
68
- <ApiDialog v-if="$Data.apiVisible" v-model="$Data.apiVisible" :row-data="$Data.rowData" @success="onDialogSuccess(scope.reload)" />
60
+ <ApiDialog v-if="$Data.apiVisible" v-model="$Data.apiVisible" :row-data="$Data.rowData" @success="$Method.onDialogSuccess(scope.reload)" />
69
61
  </template>
70
62
  </PageTableDetail>
71
63
  </template>
@@ -73,7 +65,7 @@
73
65
  <script setup>
74
66
  import { reactive } from "vue";
75
67
  import { Button as TButton, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Tag as TTag } from "tdesign-vue-next";
76
- import { AddIcon, ChevronDownIcon, CodeIcon, DeleteIcon, EditIcon, RefreshIcon, SettingIcon } from "tdesign-icons-vue-next";
68
+ import { AddIcon, ChevronDownIcon, CodeIcon, DeleteIcon, EditIcon, SettingIcon } from "tdesign-icons-vue-next";
77
69
  import EditDialog from "./components/edit.vue";
78
70
  import MenuDialog from "./components/menu.vue";
79
71
  import ApiDialog from "./components/api.vue";
@@ -94,7 +86,7 @@ const $Data = reactive({
94
86
  ]),
95
87
  endpoints: {
96
88
  list: {
97
- path: "/core/role/list",
89
+ path: "/core/role/select",
98
90
  dropValues: [""]
99
91
  },
100
92
  delete: {
@@ -117,57 +109,51 @@ const $Data = reactive({
117
109
  rowData: {}
118
110
  });
119
111
 
120
- function onAdd() {
121
- onAction("add", {});
122
- }
123
-
124
- function onReload(reload) {
125
- reload({ keepSelection: true });
126
- }
127
-
128
- function onDialogSuccess(reload) {
129
- reload({ keepSelection: true });
130
- }
131
-
132
- function getPathCount(value) {
133
- if (!Array.isArray(value)) return 0;
134
- return value.filter((p) => typeof p === "string" && p.trim().length > 0).length;
135
- }
136
-
137
- function onAction(command, rowData) {
138
- $Data.actionType = command;
139
-
140
- if (command === "add") {
141
- $Data.rowData = {};
142
- } else {
143
- $Data.rowData = Object.assign({}, rowData);
144
- }
112
+ const $Method = {
113
+ onAdd() {
114
+ $Method.onAction("add", {});
115
+ },
116
+ onDialogSuccess(reload) {
117
+ reload({ keepSelection: true });
118
+ },
119
+ getPathCount(value) {
120
+ if (!Array.isArray(value)) return 0;
121
+ return value.filter((path) => typeof path === "string" && path.trim().length > 0).length;
122
+ },
123
+ onAction(command, rowData) {
124
+ $Data.actionType = command;
145
125
 
146
- if (command === "add" || command === "upd") {
147
- $Data.editVisible = true;
148
- return;
149
- }
126
+ if (command === "add") {
127
+ $Data.rowData = {};
128
+ } else {
129
+ $Data.rowData = Object.assign({}, rowData);
130
+ }
150
131
 
151
- if (command === "menu") {
152
- $Data.menuVisible = true;
153
- return;
154
- }
132
+ if (command === "add" || command === "upd") {
133
+ $Data.editVisible = true;
134
+ return;
135
+ }
155
136
 
156
- if (command === "api") {
157
- $Data.apiVisible = true;
158
- }
159
- }
137
+ if (command === "menu") {
138
+ $Data.menuVisible = true;
139
+ return;
140
+ }
160
141
 
161
- function onDropdownAction(data, rowData, deleteRow) {
162
- const record = data;
163
- const rawValue = record && record["value"] ? record["value"] : "";
164
- const cmd = rawValue ? String(rawValue) : "";
165
- if (cmd === "del") {
166
- deleteRow(rowData);
167
- return;
142
+ if (command === "api") {
143
+ $Data.apiVisible = true;
144
+ }
145
+ },
146
+ onDropdownAction(data, rowData, deleteRow) {
147
+ const record = data;
148
+ const rawValue = record && record["value"] ? record["value"] : "";
149
+ const cmd = rawValue ? String(rawValue) : "";
150
+ if (cmd === "del") {
151
+ deleteRow(rowData);
152
+ return;
153
+ }
154
+ $Method.onAction(cmd, rowData);
168
155
  }
169
- onAction(cmd, rowData);
170
- }
156
+ };
171
157
  </script>
172
158
 
173
159
  <style scoped lang="scss">