befly-admin-ui 1.8.14 → 1.8.16
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/package.json +2 -2
- package/utils/arrayToTree.js +1 -4
- package/views/config/dict/components/edit.vue +12 -23
- package/views/config/dict/index.vue +13 -19
- package/views/config/dictType/components/edit.vue +12 -23
- package/views/config/dictType/index.vue +8 -8
- package/views/config/system/components/edit.vue +24 -39
- package/views/config/system/index.vue +8 -8
- package/views/index/components/addonList.vue +4 -17
- package/views/index/components/environmentInfo.vue +4 -19
- package/views/index/components/operationLogs.vue +3 -15
- package/views/index/components/performanceMetrics.vue +4 -15
- package/views/index/components/quickActions.vue +1 -1
- package/views/index/components/serviceStatus.vue +5 -26
- package/views/index/components/systemNotifications.vue +3 -13
- package/views/index/components/systemOverview.vue +3 -9
- package/views/index/components/systemResources.vue +5 -17
- package/views/index/components/userInfo.vue +26 -49
- package/views/index/index.vue +1 -1
- package/views/log/email/index.vue +23 -40
- package/views/log/login/index.vue +4 -4
- package/views/log/operate/index.vue +6 -6
- package/views/login_1/index.vue +7 -8
- package/views/people/admin/components/edit.vue +12 -29
- package/views/people/admin/index.vue +7 -7
- package/views/permission/api/index.vue +10 -16
- package/views/permission/menu/index.vue +9 -15
- package/views/permission/role/components/api.vue +41 -60
- package/views/permission/role/components/edit.vue +7 -19
- package/views/permission/role/components/menu.vue +33 -52
- package/views/permission/role/index.vue +8 -8
|
@@ -34,31 +34,19 @@
|
|
|
34
34
|
</div>
|
|
35
35
|
</template>
|
|
36
36
|
|
|
37
|
-
<script setup
|
|
37
|
+
<script setup>
|
|
38
38
|
import { reactive } from "vue";
|
|
39
39
|
import { CheckCircleIcon, CircleIcon, CloudIcon, CloseCircleIcon, DataBaseIcon, ErrorCircleIcon, HardDiskStorageIcon, LightingCircleIcon, MailIcon } from "tdesign-icons-vue-next";
|
|
40
40
|
import { $Http } from "@/plugins/http";
|
|
41
41
|
|
|
42
|
-
type ServiceStatusItem = {
|
|
43
|
-
name: string;
|
|
44
|
-
status: string;
|
|
45
|
-
responseTime?: string;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
42
|
// 组件内部数据
|
|
49
|
-
const services = reactive
|
|
43
|
+
const services = reactive([]);
|
|
50
44
|
|
|
51
45
|
// 获取数据
|
|
52
46
|
const fetchData = async () => {
|
|
53
47
|
try {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
{},
|
|
57
|
-
{
|
|
58
|
-
dropValues: [""]
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
services.splice(0, services.length, ...data.services);
|
|
48
|
+
const res = await $Http.json("/core/dashboard/serviceStatus", {}, [""]);
|
|
49
|
+
services.splice(0, services.length, ...res.data.services);
|
|
62
50
|
} catch (_error) {
|
|
63
51
|
// 静默失败:不阻断页面展示
|
|
64
52
|
}
|
|
@@ -67,16 +55,7 @@ const fetchData = async () => {
|
|
|
67
55
|
fetchData();
|
|
68
56
|
|
|
69
57
|
// 工具函数
|
|
70
|
-
const
|
|
71
|
-
const colors = {
|
|
72
|
-
running: "success",
|
|
73
|
-
stopped: "error",
|
|
74
|
-
unconfigured: "warning"
|
|
75
|
-
};
|
|
76
|
-
return colors[status] || "default";
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const getStatusText = (status: string): string => {
|
|
58
|
+
const getStatusText = (status) => {
|
|
80
59
|
const texts = {
|
|
81
60
|
running: "正常",
|
|
82
61
|
stopped: "停止",
|
|
@@ -25,30 +25,20 @@
|
|
|
25
25
|
</div>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
|
-
<script setup
|
|
28
|
+
<script setup>
|
|
29
29
|
import { reactive } from "vue";
|
|
30
30
|
import { Tag as TTag } from "tdesign-vue-next";
|
|
31
31
|
import { CheckCircleIcon, CloseCircleIcon, ErrorTriangleIcon, InfoCircleIcon, NotificationIcon } from "tdesign-icons-vue-next";
|
|
32
32
|
|
|
33
|
-
type NotificationType = "info" | "success" | "warning" | "error" | "other";
|
|
34
|
-
|
|
35
|
-
type NotificationItem = {
|
|
36
|
-
id: number;
|
|
37
|
-
type: NotificationType;
|
|
38
|
-
title: string;
|
|
39
|
-
isRead: boolean;
|
|
40
|
-
createdAt: number;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
33
|
// 组件内部数据
|
|
44
|
-
const notifications = reactive
|
|
34
|
+
const notifications = reactive([
|
|
45
35
|
{ id: 1, type: "warning", title: "系统更新提醒 - v1.1.0 版本已发布", isRead: false, createdAt: Date.now() - 3600000 },
|
|
46
36
|
{ id: 2, type: "info", title: "数据备份完成 - 今日凌晨自动备份成功", isRead: true, createdAt: Date.now() - 21600000 },
|
|
47
37
|
{ id: 3, type: "error", title: "SSL证书即将过期 - 请及时更新证书", isRead: false, createdAt: Date.now() - 86400000 },
|
|
48
38
|
{ id: 4, type: "success", title: "性能优化完成 - 响应速度提升30%", isRead: true, createdAt: Date.now() - 172800000 }
|
|
49
39
|
]);
|
|
50
40
|
|
|
51
|
-
const formatTime = (timestamp
|
|
41
|
+
const formatTime = (timestamp) => {
|
|
52
42
|
const date = new Date(timestamp);
|
|
53
43
|
const now = Date.now();
|
|
54
44
|
const diff = now - timestamp;
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
</div>
|
|
35
35
|
</template>
|
|
36
36
|
|
|
37
|
-
<script setup
|
|
37
|
+
<script setup>
|
|
38
38
|
import { reactive } from "vue";
|
|
39
39
|
import { InfoCircleIcon, LinkIcon, MenuIcon, UsergroupIcon } from "tdesign-icons-vue-next";
|
|
40
40
|
import { $Http } from "@/plugins/http";
|
|
@@ -49,14 +49,8 @@ const permissionStats = reactive({
|
|
|
49
49
|
// 获取数据
|
|
50
50
|
const fetchData = async () => {
|
|
51
51
|
try {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
{},
|
|
55
|
-
{
|
|
56
|
-
dropValues: [""]
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
Object.assign(permissionStats, data);
|
|
52
|
+
const res = await $Http.json("/core/dashboard/systemOverview", {}, [""]);
|
|
53
|
+
Object.assign(permissionStats, res.data);
|
|
60
54
|
} catch (_error) {
|
|
61
55
|
// 静默失败:不阻断页面展示
|
|
62
56
|
}
|
|
@@ -38,20 +38,14 @@
|
|
|
38
38
|
</div>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
|
-
<script setup
|
|
41
|
+
<script setup>
|
|
42
42
|
import { reactive } from "vue";
|
|
43
43
|
import { Progress as TProgress } from "tdesign-vue-next";
|
|
44
44
|
import { ChartIcon, CpuIcon, HardDiskStorageIcon, SystemStorageIcon } from "tdesign-icons-vue-next";
|
|
45
45
|
import { $Http } from "@/plugins/http";
|
|
46
46
|
|
|
47
|
-
type SystemResourcesInfo = {
|
|
48
|
-
cpu: { usage: number; cores: number };
|
|
49
|
-
memory: { used: number; total: number; percentage: number };
|
|
50
|
-
disk: { used: number; total: number; percentage: number };
|
|
51
|
-
};
|
|
52
|
-
|
|
53
47
|
// 组件内部数据
|
|
54
|
-
const systemResources = reactive
|
|
48
|
+
const systemResources = reactive({
|
|
55
49
|
cpu: { usage: 0, cores: 0 },
|
|
56
50
|
memory: { used: 0, total: 0, percentage: 0 },
|
|
57
51
|
disk: { used: 0, total: 0, percentage: 0 }
|
|
@@ -60,14 +54,8 @@ const systemResources = reactive<SystemResourcesInfo>({
|
|
|
60
54
|
// 获取数据
|
|
61
55
|
const fetchData = async () => {
|
|
62
56
|
try {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
{},
|
|
66
|
-
{
|
|
67
|
-
dropValues: [""]
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
Object.assign(systemResources, data);
|
|
57
|
+
const res = await $Http.json("/core/dashboard/systemResources", {}, [""]);
|
|
58
|
+
Object.assign(systemResources, res.data);
|
|
71
59
|
} catch (_error) {
|
|
72
60
|
// 静默失败:不阻断页面展示
|
|
73
61
|
}
|
|
@@ -76,7 +64,7 @@ const fetchData = async () => {
|
|
|
76
64
|
fetchData();
|
|
77
65
|
|
|
78
66
|
// 工具函数
|
|
79
|
-
const getProgressColor = (percentage
|
|
67
|
+
const getProgressColor = (percentage) => {
|
|
80
68
|
if (percentage < 50) return "success";
|
|
81
69
|
if (percentage < 80) return "warning";
|
|
82
70
|
return "danger";
|
|
@@ -38,79 +38,56 @@
|
|
|
38
38
|
</div>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
|
-
<script setup
|
|
41
|
+
<script setup>
|
|
42
42
|
import { reactive } from "vue";
|
|
43
43
|
import { Button as TButton, MessagePlugin } from "tdesign-vue-next";
|
|
44
44
|
import { CallIcon, MailIcon, RefreshIcon, TimeIcon, UserIcon } from "tdesign-icons-vue-next";
|
|
45
45
|
import { $Http } from "@/plugins/http";
|
|
46
46
|
|
|
47
|
-
type UserInfo = {
|
|
48
|
-
nickname?: string;
|
|
49
|
-
name?: string;
|
|
50
|
-
username?: string;
|
|
51
|
-
role?: {
|
|
52
|
-
name?: string;
|
|
53
|
-
};
|
|
54
|
-
roleCode?: string;
|
|
55
|
-
email?: string;
|
|
56
|
-
phone?: string;
|
|
57
|
-
lastLoginTime?: number | string;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
47
|
// 响应式数据
|
|
61
48
|
const $Data = reactive({
|
|
62
|
-
userInfo: {}
|
|
49
|
+
userInfo: {},
|
|
63
50
|
refreshing: false
|
|
64
51
|
});
|
|
65
52
|
|
|
66
|
-
async function fetchData()
|
|
53
|
+
async function fetchData() {
|
|
67
54
|
try {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
dropValues: [""]
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
Object.assign($Data.userInfo, data as UserInfo);
|
|
76
|
-
} catch (_error) {
|
|
77
|
-
MessagePlugin.error("获取用户信息失败");
|
|
55
|
+
const res = await $Http.json("/core/admin/detail", {}, [""]);
|
|
56
|
+
Object.assign($Data.userInfo, res.data);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
MessagePlugin.error(error.msg || error.message || "获取用户信息失败");
|
|
78
59
|
}
|
|
79
60
|
}
|
|
80
61
|
|
|
81
|
-
async function handleRefreshCache()
|
|
62
|
+
async function handleRefreshCache() {
|
|
82
63
|
try {
|
|
83
64
|
$Data.refreshing = true;
|
|
84
|
-
const result = await $Http.
|
|
65
|
+
const result = await $Http.json("/core/admin/cacheRefresh");
|
|
85
66
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const messages: string[] = [];
|
|
67
|
+
const apis = result.data.apis;
|
|
68
|
+
const menus = result.data.menus;
|
|
69
|
+
const roles = result.data.roles;
|
|
70
|
+
const messages = [];
|
|
91
71
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
if (roles && roles.success) {
|
|
99
|
-
messages.push(`角色缓存: ${roles.count} 个`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
MessagePlugin.success(`缓存刷新成功!${messages.join(",")}`);
|
|
103
|
-
} else {
|
|
104
|
-
MessagePlugin.warning(result.msg || "部分缓存刷新失败");
|
|
72
|
+
if (apis && apis.success) {
|
|
73
|
+
messages.push(`接口缓存: ${apis.count} 个`);
|
|
74
|
+
}
|
|
75
|
+
if (menus && menus.success) {
|
|
76
|
+
messages.push(`菜单缓存: ${menus.count} 个`);
|
|
105
77
|
}
|
|
106
|
-
|
|
107
|
-
|
|
78
|
+
if (roles && roles.success) {
|
|
79
|
+
messages.push(`角色缓存: ${roles.count} 个`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
MessagePlugin.success(`缓存刷新成功!${messages.join(",")}`);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
MessagePlugin.error(error.msg || error.message || "刷新缓存失败,请稍后重试");
|
|
108
85
|
} finally {
|
|
109
86
|
$Data.refreshing = false;
|
|
110
87
|
}
|
|
111
88
|
}
|
|
112
89
|
|
|
113
|
-
function formatTime(timestamp
|
|
90
|
+
function formatTime(timestamp) {
|
|
114
91
|
if (!timestamp) return "";
|
|
115
92
|
const date = new Date(Number(timestamp));
|
|
116
93
|
const now = new Date();
|
package/views/index/index.vue
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</div>
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
|
-
<script setup
|
|
22
|
+
<script setup>
|
|
23
23
|
import SystemOverview from "./components/systemOverview.vue";
|
|
24
24
|
import ServiceStatus from "./components/serviceStatus.vue";
|
|
25
25
|
import SystemResources from "./components/systemResources.vue";
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
</PagedTableDetail>
|
|
69
69
|
</template>
|
|
70
70
|
|
|
71
|
-
<script setup
|
|
71
|
+
<script setup>
|
|
72
72
|
import { reactive, ref } from "vue";
|
|
73
73
|
import { Button as TButton, Form as TForm, FormItem as TFormItem, Input as TInput, MessagePlugin, Space as TSpace, Tag as TTag, Textarea as TTextarea } from "tdesign-vue-next";
|
|
74
74
|
import { CheckCircleIcon, RefreshIcon, SendIcon } from "tdesign-icons-vue-next";
|
|
@@ -77,12 +77,7 @@ import DetailPanel from "@/components/detailPanel.vue";
|
|
|
77
77
|
import { $Http } from "@/plugins/http";
|
|
78
78
|
import PagedTableDetail from "@/components/pagedTableDetail.vue";
|
|
79
79
|
import { withDefaultColumns } from "befly-admin-ui/utils/withDefaultColumns";
|
|
80
|
-
|
|
81
|
-
type TDesignFormInstance = {
|
|
82
|
-
validate: () => Promise<unknown>;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const sendFormRef = ref<TDesignFormInstance | null>(null);
|
|
80
|
+
const sendFormRef = ref(null);
|
|
86
81
|
|
|
87
82
|
// 响应式数据
|
|
88
83
|
const $Data = reactive({
|
|
@@ -120,15 +115,15 @@ const $Data = reactive({
|
|
|
120
115
|
}
|
|
121
116
|
});
|
|
122
117
|
|
|
123
|
-
function onReload(reload
|
|
118
|
+
function onReload(reload) {
|
|
124
119
|
reload({ keepSelection: true });
|
|
125
120
|
}
|
|
126
121
|
|
|
127
|
-
function onCancelSend()
|
|
122
|
+
function onCancelSend() {
|
|
128
123
|
$Data.sendDialogVisible = false;
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
function openSendDialog()
|
|
126
|
+
function openSendDialog() {
|
|
132
127
|
$Data.sendForm = {
|
|
133
128
|
to: "",
|
|
134
129
|
cc: "",
|
|
@@ -138,11 +133,7 @@ function openSendDialog(): void {
|
|
|
138
133
|
$Data.sendDialogVisible = true;
|
|
139
134
|
}
|
|
140
135
|
|
|
141
|
-
|
|
142
|
-
close: () => void;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
async function onSend(reload: ((options: { keepSelection?: boolean; resetPage?: boolean }) => void) | null, context?: PageDialogEventContext): Promise<void> {
|
|
136
|
+
async function onSend(reload, context) {
|
|
146
137
|
const form = sendFormRef.value;
|
|
147
138
|
if (!form) {
|
|
148
139
|
MessagePlugin.warning("表单未就绪");
|
|
@@ -154,7 +145,7 @@ async function onSend(reload: ((options: { keepSelection?: boolean; resetPage?:
|
|
|
154
145
|
|
|
155
146
|
$Data.sending = true;
|
|
156
147
|
try {
|
|
157
|
-
const res = await $Http.
|
|
148
|
+
const res = await $Http.json("/core/email/send", {
|
|
158
149
|
to: $Data.sendForm.to,
|
|
159
150
|
subject: $Data.sendForm.subject,
|
|
160
151
|
content: $Data.sendForm.content,
|
|
@@ -162,42 +153,34 @@ async function onSend(reload: ((options: { keepSelection?: boolean; resetPage?:
|
|
|
162
153
|
isHtml: true
|
|
163
154
|
});
|
|
164
155
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
context.close();
|
|
169
|
-
} else {
|
|
170
|
-
$Data.sendDialogVisible = false;
|
|
171
|
-
}
|
|
172
|
-
if (reload) {
|
|
173
|
-
reload({ keepSelection: false, resetPage: true });
|
|
174
|
-
}
|
|
156
|
+
MessagePlugin.success("发送成功");
|
|
157
|
+
if (context && typeof context.close === "function") {
|
|
158
|
+
context.close();
|
|
175
159
|
} else {
|
|
176
|
-
|
|
160
|
+
$Data.sendDialogVisible = false;
|
|
177
161
|
}
|
|
178
|
-
|
|
179
|
-
|
|
162
|
+
if (reload) {
|
|
163
|
+
reload({ keepSelection: false, resetPage: true });
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
MessagePlugin.error(error.msg || error.message || "发送失败");
|
|
180
167
|
} finally {
|
|
181
168
|
$Data.sending = false;
|
|
182
169
|
}
|
|
183
170
|
}
|
|
184
171
|
|
|
185
|
-
async function onVerify()
|
|
172
|
+
async function onVerify() {
|
|
186
173
|
try {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
MessagePlugin.error(res.msg || "配置异常");
|
|
192
|
-
}
|
|
193
|
-
} catch (_error) {
|
|
194
|
-
MessagePlugin.error("验证失败");
|
|
174
|
+
await $Http.json("/core/email/verify");
|
|
175
|
+
MessagePlugin.success("邮件服务配置正常");
|
|
176
|
+
} catch (error) {
|
|
177
|
+
MessagePlugin.error(error.msg || error.message || "验证失败");
|
|
195
178
|
}
|
|
196
179
|
}
|
|
197
180
|
|
|
198
|
-
function formatTime(timestamp
|
|
181
|
+
function formatTime(timestamp) {
|
|
199
182
|
if (!timestamp) return "-";
|
|
200
|
-
const date = new Date(timestamp
|
|
183
|
+
const date = new Date(timestamp);
|
|
201
184
|
const year = date.getFullYear();
|
|
202
185
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
203
186
|
const day = String(date.getDate()).padStart(2, "0");
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
</PagedTableDetail>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
|
-
<script setup
|
|
41
|
+
<script setup>
|
|
42
42
|
import { reactive } from "vue";
|
|
43
43
|
import { Button as TButton, Tag as TTag } from "tdesign-vue-next";
|
|
44
44
|
import { RefreshIcon } from "tdesign-icons-vue-next";
|
|
@@ -73,13 +73,13 @@ const $Data = reactive({
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
function onReload(reload
|
|
76
|
+
function onReload(reload) {
|
|
77
77
|
reload({ keepSelection: true });
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function formatTime(timestamp
|
|
80
|
+
function formatTime(timestamp) {
|
|
81
81
|
if (!timestamp) return "-";
|
|
82
|
-
const date = new Date(timestamp
|
|
82
|
+
const date = new Date(timestamp);
|
|
83
83
|
const year = date.getFullYear();
|
|
84
84
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
85
85
|
const day = String(date.getDate()).padStart(2, "0");
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</PagedTableDetail>
|
|
62
62
|
</template>
|
|
63
63
|
|
|
64
|
-
<script setup
|
|
64
|
+
<script setup>
|
|
65
65
|
import { reactive } from "vue";
|
|
66
66
|
import { Button as TButton, Option as TOption, Select as TSelect, Tag as TTag } from "tdesign-vue-next";
|
|
67
67
|
import { RefreshIcon } from "tdesign-icons-vue-next";
|
|
@@ -123,17 +123,17 @@ const $Data = reactive({
|
|
|
123
123
|
]
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
function handleFilter(reload
|
|
126
|
+
function handleFilter(reload) {
|
|
127
127
|
reload({ keepSelection: false, resetPage: true });
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
function onReload(reload
|
|
130
|
+
function onReload(reload) {
|
|
131
131
|
reload({ keepSelection: true });
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
function formatTime(timestamp
|
|
134
|
+
function formatTime(timestamp) {
|
|
135
135
|
if (!timestamp) return "-";
|
|
136
|
-
const date = new Date(timestamp
|
|
136
|
+
const date = new Date(timestamp);
|
|
137
137
|
const year = date.getFullYear();
|
|
138
138
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
139
139
|
const day = String(date.getDate()).padStart(2, "0");
|
|
@@ -143,7 +143,7 @@ function formatTime(timestamp: unknown): string {
|
|
|
143
143
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
function formatJson(value
|
|
146
|
+
function formatJson(value) {
|
|
147
147
|
if (!value) return "-";
|
|
148
148
|
try {
|
|
149
149
|
const obj = typeof value === "string" ? JSON.parse(value) : value;
|
package/views/login_1/index.vue
CHANGED
|
@@ -63,18 +63,17 @@
|
|
|
63
63
|
</div>
|
|
64
64
|
</template>
|
|
65
65
|
|
|
66
|
-
<script setup
|
|
66
|
+
<script setup>
|
|
67
67
|
import { reactive, ref } from "vue";
|
|
68
68
|
import { useRouter } from "vue-router";
|
|
69
69
|
import { Form as TForm, FormItem as TFormItem, Input as TInput, Button as TButton, Checkbox as TCheckbox, InputAdornment as TInputAdornment, Select as TSelect, Option as TOption, MessagePlugin } from "tdesign-vue-next";
|
|
70
70
|
import { LockOnIcon, UserIcon } from "tdesign-icons-vue-next";
|
|
71
71
|
import { $Http } from "@/plugins/http";
|
|
72
|
-
import { $Storage } from "@/plugins/storage";
|
|
73
72
|
import { hashPassword } from "befly-admin-ui/utils/hashPassword";
|
|
74
73
|
|
|
75
74
|
const router = useRouter();
|
|
76
75
|
|
|
77
|
-
const formRef = ref
|
|
76
|
+
const formRef = ref(null);
|
|
78
77
|
|
|
79
78
|
// 数据定义
|
|
80
79
|
const $Data = reactive({
|
|
@@ -91,7 +90,7 @@ const $Data = reactive({
|
|
|
91
90
|
}
|
|
92
91
|
});
|
|
93
92
|
|
|
94
|
-
async function apiLogin()
|
|
93
|
+
async function apiLogin() {
|
|
95
94
|
try {
|
|
96
95
|
if (formRef.value === null) {
|
|
97
96
|
MessagePlugin.error("表单未就绪");
|
|
@@ -104,23 +103,23 @@ async function apiLogin(): Promise<void> {
|
|
|
104
103
|
|
|
105
104
|
const hashedPassword = await hashPassword($Data.formData.password);
|
|
106
105
|
|
|
107
|
-
const res = await $Http.
|
|
106
|
+
const res = await $Http.json("/core/auth/login", {
|
|
108
107
|
loginType: $Data.formData.loginType,
|
|
109
108
|
account: $Data.formData.account,
|
|
110
109
|
password: hashedPassword
|
|
111
110
|
});
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
localStorage.setItem("yicode-token", res.data.token);
|
|
114
113
|
|
|
115
114
|
if (res.data.userInfo) {
|
|
116
|
-
|
|
115
|
+
localStorage.setItem("yicode-userInfo", JSON.stringify(res.data.userInfo));
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
MessagePlugin.success(res.msg || "登录成功");
|
|
120
119
|
|
|
121
120
|
await router.push("/");
|
|
122
121
|
} catch (error) {
|
|
123
|
-
MessagePlugin.error("登录失败");
|
|
122
|
+
MessagePlugin.error(error.msg || error.message || "登录失败");
|
|
124
123
|
} finally {
|
|
125
124
|
$Data.loading = false;
|
|
126
125
|
}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</PageDialog>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
|
-
<script setup
|
|
28
|
+
<script setup>
|
|
29
29
|
import { computed, reactive, ref } from "vue";
|
|
30
30
|
|
|
31
31
|
import {
|
|
@@ -58,21 +58,10 @@ const $Prop = defineProps({
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
const $Emit = defineEmits
|
|
62
|
-
(e: "update:modelValue", value: boolean): void;
|
|
63
|
-
(e: "success"): void;
|
|
64
|
-
}>();
|
|
65
|
-
|
|
66
|
-
type PageDialogEventContext = {
|
|
67
|
-
close: () => void;
|
|
68
|
-
};
|
|
61
|
+
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
69
62
|
|
|
70
63
|
// 表单引用
|
|
71
|
-
|
|
72
|
-
validate: () => Promise<unknown>;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const formRef = ref<TDesignFormInstance | null>(null);
|
|
64
|
+
const formRef = ref(null);
|
|
76
65
|
|
|
77
66
|
const dialogVisible = computed({
|
|
78
67
|
get: () => $Prop.modelValue,
|
|
@@ -110,29 +99,23 @@ const $Data2 = reactive({
|
|
|
110
99
|
}
|
|
111
100
|
});
|
|
112
101
|
|
|
113
|
-
async function initData()
|
|
102
|
+
async function initData() {
|
|
114
103
|
await apiRoleLists();
|
|
115
104
|
if ($Prop.actionType === "upd" && $Prop.rowData.id) {
|
|
116
105
|
$Data.formData = Object.assign({}, $Prop.rowData);
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
108
|
|
|
120
|
-
async function apiRoleLists()
|
|
109
|
+
async function apiRoleLists() {
|
|
121
110
|
try {
|
|
122
|
-
const result = await $Http.
|
|
123
|
-
"/core/role/all",
|
|
124
|
-
{},
|
|
125
|
-
{
|
|
126
|
-
dropValues: [""]
|
|
127
|
-
}
|
|
128
|
-
);
|
|
111
|
+
const result = await $Http.json("/core/role/all", {}, [""]);
|
|
129
112
|
$Data.allRoleLists = result.data || [];
|
|
130
|
-
} catch (
|
|
131
|
-
MessagePlugin.error("加载角色列表失败");
|
|
113
|
+
} catch (error) {
|
|
114
|
+
MessagePlugin.error(error.msg || error.message || "加载角色列表失败");
|
|
132
115
|
}
|
|
133
116
|
}
|
|
134
117
|
|
|
135
|
-
async function onSubmit(context
|
|
118
|
+
async function onSubmit(context) {
|
|
136
119
|
try {
|
|
137
120
|
const form = formRef.value;
|
|
138
121
|
if (!form) {
|
|
@@ -144,14 +127,14 @@ async function onSubmit(context?: PageDialogEventContext): Promise<void> {
|
|
|
144
127
|
if (!valid) return;
|
|
145
128
|
|
|
146
129
|
$Data.submitting = true;
|
|
147
|
-
const formData =
|
|
130
|
+
const formData = $Prop.actionType === "add" ? fieldClear($Data.formData, { omitKeys: ["id", "state"] }) : fieldClear($Data.formData, { omitKeys: ["password"] });
|
|
148
131
|
|
|
149
132
|
const password = typeof formData["password"] === "string" ? String(formData["password"]) : "";
|
|
150
133
|
if ($Prop.actionType === "add" && password) {
|
|
151
134
|
formData["password"] = await hashPassword(password);
|
|
152
135
|
}
|
|
153
136
|
|
|
154
|
-
const result = await $Http.
|
|
137
|
+
const result = await $Http.json($Prop.actionType === "upd" ? "/core/admin/upd" : "/core/admin/ins", formData);
|
|
155
138
|
|
|
156
139
|
MessagePlugin.success(result.msg);
|
|
157
140
|
$Emit("success");
|
|
@@ -159,7 +142,7 @@ async function onSubmit(context?: PageDialogEventContext): Promise<void> {
|
|
|
159
142
|
context.close();
|
|
160
143
|
}
|
|
161
144
|
} catch (error) {
|
|
162
|
-
MessagePlugin.error(
|
|
145
|
+
MessagePlugin.error(error.msg || error.message || "提交失败");
|
|
163
146
|
} finally {
|
|
164
147
|
$Data.submitting = false;
|
|
165
148
|
}
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
</PagedTableDetail>
|
|
48
48
|
</template>
|
|
49
49
|
|
|
50
|
-
<script setup
|
|
50
|
+
<script setup>
|
|
51
51
|
import { reactive } from "vue";
|
|
52
52
|
import { Button as TButton, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Tag as TTag } from "tdesign-vue-next";
|
|
53
53
|
import { AddIcon, ChevronDownIcon, DeleteIcon, EditIcon, RefreshIcon } from "tdesign-icons-vue-next";
|
|
@@ -84,19 +84,19 @@ const $Data = reactive({
|
|
|
84
84
|
rowData: {}
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
function onAdd()
|
|
87
|
+
function onAdd() {
|
|
88
88
|
onAction("add", {});
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function onReload(reload
|
|
91
|
+
function onReload(reload) {
|
|
92
92
|
reload({ keepSelection: true });
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function onDialogSuccess(reload
|
|
95
|
+
function onDialogSuccess(reload) {
|
|
96
96
|
reload({ keepSelection: true });
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
function onAction(command
|
|
99
|
+
function onAction(command, rowData) {
|
|
100
100
|
$Data.actionType = command;
|
|
101
101
|
$Data.rowData = rowData;
|
|
102
102
|
if (command === "add" || command === "upd") {
|
|
@@ -104,8 +104,8 @@ function onAction(command: string, rowData: Record<string, unknown>): void {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function onDropdownAction(data
|
|
108
|
-
const record = data
|
|
107
|
+
function onDropdownAction(data, rowData, deleteRow) {
|
|
108
|
+
const record = data;
|
|
109
109
|
const rawValue = record && record["value"] ? record["value"] : "";
|
|
110
110
|
const cmd = rawValue ? String(rawValue) : "";
|
|
111
111
|
if (cmd === "del") {
|