@befly-addon/admin 1.0.9 → 1.0.11
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/api/all.ts +5 -12
- package/apis/menu/all.ts +8 -14
- package/package.json +17 -3
- package/tables/admin.json +157 -13
- package/tables/api.json +79 -7
- package/tables/dict.json +79 -7
- package/tables/menu.json +79 -7
- package/tables/role.json +79 -7
- package/util.ts +1 -150
- package/views/403/index.vue +68 -0
- package/views/admin/components/edit.vue +150 -0
- package/views/admin/components/role.vue +138 -0
- package/views/admin/index.vue +179 -0
- package/views/dict/components/edit.vue +159 -0
- package/views/dict/index.vue +162 -0
- package/views/index/components/addonList.vue +127 -0
- package/views/index/components/environmentInfo.vue +99 -0
- package/views/index/components/operationLogs.vue +114 -0
- package/views/index/components/performanceMetrics.vue +150 -0
- package/views/index/components/quickActions.vue +27 -0
- package/views/index/components/serviceStatus.vue +183 -0
- package/views/index/components/systemNotifications.vue +132 -0
- package/views/index/components/systemOverview.vue +190 -0
- package/views/index/components/systemResources.vue +106 -0
- package/views/index/components/userInfo.vue +206 -0
- package/views/index/index.vue +29 -0
- package/views/login/components/emailLoginForm.vue +167 -0
- package/views/login/components/registerForm.vue +170 -0
- package/views/login/components/welcomePanel.vue +61 -0
- package/views/login/index.vue +191 -0
- package/views/menu/components/edit.vue +153 -0
- package/views/menu/index.vue +177 -0
- package/views/news/detail/index.vue +26 -0
- package/views/news/index.vue +26 -0
- package/views/role/components/api.vue +283 -0
- package/views/role/components/edit.vue +132 -0
- package/views/role/components/menu.vue +146 -0
- package/views/role/index.vue +179 -0
- package/views/user/index.vue +322 -0
- package/apis/dashboard/addonList.ts +0 -47
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="section-block">
|
|
3
|
+
<div class="section-header">
|
|
4
|
+
<i-lucide:bell style="width: 20px; height: 20px" />
|
|
5
|
+
<h2>系统通知</h2>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="section-content">
|
|
8
|
+
<div class="notification-compact-list">
|
|
9
|
+
<div v-for="notification in notifications" :key="notification.id" class="notification-compact-item">
|
|
10
|
+
<div class="notification-icon" :class="`type-${notification.type}`">
|
|
11
|
+
<i-lucide:info v-if="notification.type === 'info'" style="width: 16px; height: 16px" />
|
|
12
|
+
<i-lucide:check-circle v-else-if="notification.type === 'success'" style="width: 16px; height: 16px" />
|
|
13
|
+
<i-lucide:alert-triangle v-else-if="notification.type === 'warning'" style="width: 16px; height: 16px" />
|
|
14
|
+
<i-lucide:x-circle v-else-if="notification.type === 'error'" style="width: 16px; height: 16px" />
|
|
15
|
+
<i-lucide:bell v-else style="width: 16px; height: 16px" />
|
|
16
|
+
</div>
|
|
17
|
+
<div class="notification-content">
|
|
18
|
+
<span class="notification-title">{{ notification.title }}</span>
|
|
19
|
+
<span class="notification-time">{{ formatTime(notification.createdAt) }}</span>
|
|
20
|
+
</div>
|
|
21
|
+
<tiny-tag v-if="!notification.isRead" type="primary" size="small">新</tiny-tag>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup>
|
|
29
|
+
import { ref } from 'vue';
|
|
30
|
+
|
|
31
|
+
// 组件内部数据
|
|
32
|
+
const notifications = $ref([
|
|
33
|
+
{ id: 1, type: 'warning', title: '系统更新提醒 - v1.1.0 版本已发布', isRead: false, createdAt: Date.now() - 3600000 },
|
|
34
|
+
{ id: 2, type: 'info', title: '数据备份完成 - 今日凌晨自动备份成功', isRead: true, createdAt: Date.now() - 21600000 },
|
|
35
|
+
{ id: 3, type: 'error', title: 'SSL证书即将过期 - 请及时更新证书', isRead: false, createdAt: Date.now() - 86400000 },
|
|
36
|
+
{ id: 4, type: 'success', title: '性能优化完成 - 响应速度提升30%', isRead: true, createdAt: Date.now() - 172800000 }
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const formatTime = (timestamp) => {
|
|
40
|
+
const date = new Date(timestamp);
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
const diff = now - timestamp;
|
|
43
|
+
|
|
44
|
+
if (diff < 3600000) {
|
|
45
|
+
return `${Math.floor(diff / 60000)}分钟前`;
|
|
46
|
+
} else if (diff < 86400000) {
|
|
47
|
+
return `${Math.floor(diff / 3600000)}小时前`;
|
|
48
|
+
} else {
|
|
49
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
50
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
51
|
+
return `${month}-${day}`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<style scoped lang="scss">
|
|
57
|
+
.notification-compact-list {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: $spacing-xs;
|
|
61
|
+
|
|
62
|
+
.notification-compact-item {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: $spacing-sm;
|
|
66
|
+
padding: $spacing-sm $spacing-md;
|
|
67
|
+
background: rgba($primary-color, 0.02);
|
|
68
|
+
border-radius: $border-radius-small;
|
|
69
|
+
border: 1px solid $border-color;
|
|
70
|
+
transition: all 0.2s ease;
|
|
71
|
+
|
|
72
|
+
&:hover {
|
|
73
|
+
background: rgba($primary-color, 0.05);
|
|
74
|
+
border-color: $primary-color;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.notification-icon {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
width: 32px;
|
|
82
|
+
height: 32px;
|
|
83
|
+
border-radius: $border-radius-small;
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
|
|
86
|
+
&.type-info {
|
|
87
|
+
background: rgba($primary-color, 0.1);
|
|
88
|
+
color: $primary-color;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&.type-success {
|
|
92
|
+
background: rgba($success-color, 0.1);
|
|
93
|
+
color: $success-color;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.type-warning {
|
|
97
|
+
background: rgba($warning-color, 0.1);
|
|
98
|
+
color: $warning-color;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&.type-error {
|
|
102
|
+
background: rgba($error-color, 0.1);
|
|
103
|
+
color: $error-color;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.notification-content {
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: $spacing-sm;
|
|
111
|
+
flex: 1;
|
|
112
|
+
min-width: 0;
|
|
113
|
+
|
|
114
|
+
.notification-title {
|
|
115
|
+
font-size: 14px;
|
|
116
|
+
color: $text-primary;
|
|
117
|
+
font-weight: 500;
|
|
118
|
+
overflow: hidden;
|
|
119
|
+
text-overflow: ellipsis;
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
flex: 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.notification-time {
|
|
125
|
+
font-size: 14px;
|
|
126
|
+
color: $text-placeholder;
|
|
127
|
+
flex-shrink: 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="section-block">
|
|
3
|
+
<div class="section-header">
|
|
4
|
+
<i-lucide:info style="width: 20px; height: 20px" />
|
|
5
|
+
<h2>系统概览</h2>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="section-content">
|
|
8
|
+
<tiny-row :flex="true" :gap="12">
|
|
9
|
+
<tiny-col :xs="24" :sm="12" :md="12" :lg="12">
|
|
10
|
+
<div class="info-block">
|
|
11
|
+
<div class="stats-grid">
|
|
12
|
+
<div class="stat-box stat-primary">
|
|
13
|
+
<i-lucide:menu style="width: 24px; height: 24px" />
|
|
14
|
+
<div class="stat-content">
|
|
15
|
+
<div class="stat-value">{{ permissionStats.menuCount }}</div>
|
|
16
|
+
<div class="stat-label">菜单总数</div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="stat-box stat-success">
|
|
20
|
+
<i-lucide:webhook style="width: 24px; height: 24px" />
|
|
21
|
+
<div class="stat-content">
|
|
22
|
+
<div class="stat-value">{{ permissionStats.apiCount }}</div>
|
|
23
|
+
<div class="stat-label">接口总数</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="stat-box stat-warning">
|
|
27
|
+
<i-lucide:users style="width: 24px; height: 24px" />
|
|
28
|
+
<div class="stat-content">
|
|
29
|
+
<div class="stat-value">{{ permissionStats.roleCount }}</div>
|
|
30
|
+
<div class="stat-label">角色总数</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</tiny-col>
|
|
36
|
+
</tiny-row>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup>
|
|
42
|
+
import { ref } from 'vue';
|
|
43
|
+
|
|
44
|
+
// 组件内部数据
|
|
45
|
+
const permissionStats = $ref({
|
|
46
|
+
menuCount: 0,
|
|
47
|
+
apiCount: 0,
|
|
48
|
+
roleCount: 0
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// 获取数据
|
|
52
|
+
const fetchData = async () => {
|
|
53
|
+
try {
|
|
54
|
+
const { data } = await $Http('/addon/admin/dashboard/systemOverview');
|
|
55
|
+
Object.assign(permissionStats, data);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('获取系统概览失败:', error);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
fetchData();
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style scoped lang="scss">
|
|
65
|
+
.info-block {
|
|
66
|
+
background: transparent;
|
|
67
|
+
border: none;
|
|
68
|
+
padding: 0;
|
|
69
|
+
height: 100%;
|
|
70
|
+
|
|
71
|
+
.info-header {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
gap: 6px;
|
|
75
|
+
padding-bottom: 8px;
|
|
76
|
+
margin-bottom: 12px;
|
|
77
|
+
border-bottom: 2px solid $primary-color;
|
|
78
|
+
|
|
79
|
+
.info-title {
|
|
80
|
+
font-size: 14px;
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
color: $text-primary;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.info-grid-compact {
|
|
87
|
+
display: grid;
|
|
88
|
+
grid-template-columns: repeat(3, 1fr);
|
|
89
|
+
gap: 10px;
|
|
90
|
+
|
|
91
|
+
.info-grid-item {
|
|
92
|
+
display: flex;
|
|
93
|
+
justify-content: space-between;
|
|
94
|
+
align-items: center;
|
|
95
|
+
padding: 10px 12px;
|
|
96
|
+
background: rgba($primary-color, 0.02);
|
|
97
|
+
border-radius: $border-radius-small;
|
|
98
|
+
border: 1px solid $border-color;
|
|
99
|
+
transition: all 0.2s ease;
|
|
100
|
+
|
|
101
|
+
&:hover {
|
|
102
|
+
background: rgba($primary-color, 0.05);
|
|
103
|
+
border-color: $primary-color;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.label {
|
|
107
|
+
font-size: 14px;
|
|
108
|
+
color: $text-secondary;
|
|
109
|
+
font-weight: 500;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.value {
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
color: $text-primary;
|
|
115
|
+
font-weight: 600;
|
|
116
|
+
|
|
117
|
+
&.highlight {
|
|
118
|
+
color: $primary-color;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.stats-grid {
|
|
126
|
+
display: grid;
|
|
127
|
+
grid-template-columns: repeat(3, 1fr);
|
|
128
|
+
gap: 10px;
|
|
129
|
+
|
|
130
|
+
.stat-box {
|
|
131
|
+
background: rgba($primary-color, 0.02);
|
|
132
|
+
border: 1px solid $border-color;
|
|
133
|
+
border-radius: 6px;
|
|
134
|
+
padding: 12px;
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
gap: 10px;
|
|
138
|
+
transition: all 0.3s;
|
|
139
|
+
|
|
140
|
+
&:hover {
|
|
141
|
+
background: rgba($primary-color, 0.05);
|
|
142
|
+
border-color: $primary-color;
|
|
143
|
+
transform: translateY(-2px);
|
|
144
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.stat-content {
|
|
148
|
+
flex: 1;
|
|
149
|
+
|
|
150
|
+
.stat-value {
|
|
151
|
+
font-size: 20px;
|
|
152
|
+
font-weight: 700;
|
|
153
|
+
margin-bottom: 2px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.stat-label {
|
|
157
|
+
font-size: 14px;
|
|
158
|
+
color: $text-secondary;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&.stat-primary {
|
|
163
|
+
border-color: $primary-color;
|
|
164
|
+
background: linear-gradient(135deg, rgba(0, 82, 217, 0.05), white);
|
|
165
|
+
|
|
166
|
+
.stat-value {
|
|
167
|
+
color: $primary-color;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
&.stat-success {
|
|
172
|
+
border-color: $success-color;
|
|
173
|
+
background: linear-gradient(135deg, rgba(82, 196, 26, 0.05), white);
|
|
174
|
+
|
|
175
|
+
.stat-value {
|
|
176
|
+
color: $success-color;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&.stat-warning {
|
|
181
|
+
border-color: $warning-color;
|
|
182
|
+
background: linear-gradient(135deg, rgba(250, 173, 20, 0.05), white);
|
|
183
|
+
|
|
184
|
+
.stat-value {
|
|
185
|
+
color: $warning-color;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
</style>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="section-block">
|
|
3
|
+
<div class="section-header">
|
|
4
|
+
<i-lucide:activity style="width: 20px; height: 20px" />
|
|
5
|
+
<h2>系统资源</h2>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="section-content">
|
|
8
|
+
<div class="resource-compact-list">
|
|
9
|
+
<div class="resource-compact-item">
|
|
10
|
+
<div class="resource-compact-header">
|
|
11
|
+
<i-lucide:cpu style="width: 16px; height: 16px" />
|
|
12
|
+
<span class="resource-label">CPU</span>
|
|
13
|
+
<span class="resource-value">{{ systemResources.cpu.usage }}%</span>
|
|
14
|
+
<span class="resource-desc">{{ systemResources.cpu.cores }}核心</span>
|
|
15
|
+
</div>
|
|
16
|
+
<tiny-progress :percentage="systemResources.cpu.usage" :status="getProgressColor(systemResources.cpu.usage)" />
|
|
17
|
+
</div>
|
|
18
|
+
<div class="resource-compact-item">
|
|
19
|
+
<div class="resource-compact-header">
|
|
20
|
+
<i-lucide:hard-drive style="width: 16px; height: 16px" />
|
|
21
|
+
<span class="resource-label">内存</span>
|
|
22
|
+
<span class="resource-value">{{ systemResources.memory.percentage }}%</span>
|
|
23
|
+
<span class="resource-desc">{{ systemResources.memory.used }}GB / {{ systemResources.memory.total }}GB</span>
|
|
24
|
+
</div>
|
|
25
|
+
<tiny-progress :percentage="systemResources.memory.percentage" :status="getProgressColor(systemResources.memory.percentage)" />
|
|
26
|
+
</div>
|
|
27
|
+
<div class="resource-compact-item">
|
|
28
|
+
<div class="resource-compact-header">
|
|
29
|
+
<i-lucide:disc style="width: 16px; height: 16px" />
|
|
30
|
+
<span class="resource-label">磁盘</span>
|
|
31
|
+
<span class="resource-value">{{ systemResources.disk.percentage }}%</span>
|
|
32
|
+
<span class="resource-desc">{{ systemResources.disk.used }}GB / {{ systemResources.disk.total }}GB</span>
|
|
33
|
+
</div>
|
|
34
|
+
<tiny-progress :percentage="systemResources.disk.percentage" :status="getProgressColor(systemResources.disk.percentage)" />
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup>
|
|
42
|
+
import { ref } from 'vue';
|
|
43
|
+
|
|
44
|
+
// 组件内部数据
|
|
45
|
+
const systemResources = $ref({
|
|
46
|
+
cpu: { usage: 0, cores: 0 },
|
|
47
|
+
memory: { used: 0, total: 0, percentage: 0 },
|
|
48
|
+
disk: { used: 0, total: 0, percentage: 0 }
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// 获取数据
|
|
52
|
+
const fetchData = async () => {
|
|
53
|
+
try {
|
|
54
|
+
const { data } = await $Http('/addon/admin/dashboard/systemResources');
|
|
55
|
+
Object.assign(systemResources, data);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('获取系统资源失败:', error);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
fetchData();
|
|
62
|
+
|
|
63
|
+
// 工具函数
|
|
64
|
+
const getProgressColor = (percentage) => {
|
|
65
|
+
if (percentage < 50) return 'success';
|
|
66
|
+
if (percentage < 80) return 'warning';
|
|
67
|
+
return 'danger';
|
|
68
|
+
};
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<style scoped lang="scss">
|
|
72
|
+
.resource-compact-list {
|
|
73
|
+
display: grid;
|
|
74
|
+
grid-template-columns: repeat(3, 1fr);
|
|
75
|
+
gap: $spacing-md;
|
|
76
|
+
|
|
77
|
+
.resource-compact-item {
|
|
78
|
+
.resource-compact-header {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: 10px;
|
|
82
|
+
margin-bottom: 8px;
|
|
83
|
+
|
|
84
|
+
.resource-label {
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
font-weight: 600;
|
|
87
|
+
color: $text-secondary;
|
|
88
|
+
min-width: 50px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.resource-value {
|
|
92
|
+
font-size: 16px;
|
|
93
|
+
font-weight: 700;
|
|
94
|
+
color: $primary-color;
|
|
95
|
+
min-width: 60px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.resource-desc {
|
|
99
|
+
font-size: 14px;
|
|
100
|
+
color: $text-placeholder;
|
|
101
|
+
flex: 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</style>
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="section-block user-info-card">
|
|
3
|
+
<div class="user-header">
|
|
4
|
+
<div class="user-avatar">
|
|
5
|
+
<i-lucide:user style="width: 32px; height: 32px" />
|
|
6
|
+
</div>
|
|
7
|
+
<div class="user-basic">
|
|
8
|
+
<div class="user-name">{{ $Data.userInfo.nickname || $Data.userInfo.name || $Data.userInfo.username || '未设置' }}</div>
|
|
9
|
+
<div class="user-role">{{ $Data.userInfo.role?.name || '普通用户' }}</div>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="user-details">
|
|
13
|
+
<div class="detail-item">
|
|
14
|
+
<i-lucide:mail style="width: 14px; height: 14px" />
|
|
15
|
+
<span>{{ $Data.userInfo.email || '未设置' }}</span>
|
|
16
|
+
</div>
|
|
17
|
+
<div v-if="$Data.userInfo.phone" class="detail-item">
|
|
18
|
+
<i-lucide:phone style="width: 14px; height: 14px" />
|
|
19
|
+
<span>{{ $Data.userInfo.phone }}</span>
|
|
20
|
+
</div>
|
|
21
|
+
<div v-if="$Data.userInfo.lastLoginTime" class="detail-item">
|
|
22
|
+
<i-lucide:clock style="width: 14px; height: 14px" />
|
|
23
|
+
<span>{{ $Method.formatTime($Data.userInfo.lastLoginTime) }}</span>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<!-- 仅 dev 角色显示刷新缓存按钮 -->
|
|
28
|
+
<div v-if="$Data.userInfo.roleCode === 'dev'" class="user-actions">
|
|
29
|
+
<tiny-button type="primary" size="mini" :loading="$Data.refreshing" @click="$Method.handleRefreshCache">
|
|
30
|
+
<template #icon>
|
|
31
|
+
<i-lucide:rotate-cw style="width: 14px; height: 14px" />
|
|
32
|
+
</template>
|
|
33
|
+
刷新缓存
|
|
34
|
+
</tiny-button>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup>
|
|
40
|
+
import { ref } from 'vue';
|
|
41
|
+
|
|
42
|
+
// 响应式数据
|
|
43
|
+
const $Data = $ref({
|
|
44
|
+
userInfo: {},
|
|
45
|
+
refreshing: false
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// 方法集合
|
|
49
|
+
const $Method = {
|
|
50
|
+
// 获取数据
|
|
51
|
+
async fetchData() {
|
|
52
|
+
try {
|
|
53
|
+
const { data } = await $Http('/addon/admin/admin/info');
|
|
54
|
+
Object.assign($Data.userInfo, data);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('获取用户信息失败:', error);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
// 刷新缓存
|
|
61
|
+
async handleRefreshCache() {
|
|
62
|
+
try {
|
|
63
|
+
$Data.refreshing = true;
|
|
64
|
+
const result = await $Http('/addon/admin/admin/cacheRefresh');
|
|
65
|
+
|
|
66
|
+
if (result.code === 0) {
|
|
67
|
+
const { apis, menus, roles } = result.data;
|
|
68
|
+
const messages = [];
|
|
69
|
+
|
|
70
|
+
if (apis.success) {
|
|
71
|
+
messages.push(`接口缓存: ${apis.count} 个`);
|
|
72
|
+
}
|
|
73
|
+
if (menus.success) {
|
|
74
|
+
messages.push(`菜单缓存: ${menus.count} 个`);
|
|
75
|
+
}
|
|
76
|
+
if (roles.success) {
|
|
77
|
+
messages.push(`角色缓存: ${roles.count} 个`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
TinyMessage.success({
|
|
81
|
+
message: `缓存刷新成功!${messages.join(',')}`,
|
|
82
|
+
duration: 3000
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
TinyMessage.warning({
|
|
86
|
+
message: result.msg || '部分缓存刷新失败',
|
|
87
|
+
duration: 3000
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('刷新缓存失败:', error);
|
|
92
|
+
TinyMessage.error({
|
|
93
|
+
message: '刷新缓存失败,请稍后重试',
|
|
94
|
+
duration: 3000
|
|
95
|
+
});
|
|
96
|
+
} finally {
|
|
97
|
+
$Data.refreshing = false;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
// 格式化时间
|
|
102
|
+
formatTime(timestamp) {
|
|
103
|
+
if (!timestamp) return '';
|
|
104
|
+
const date = new Date(Number(timestamp));
|
|
105
|
+
const now = new Date();
|
|
106
|
+
const diff = now - date;
|
|
107
|
+
|
|
108
|
+
// 小于1分钟
|
|
109
|
+
if (diff < 60000) {
|
|
110
|
+
return '刚刚';
|
|
111
|
+
}
|
|
112
|
+
// 小于1小时
|
|
113
|
+
if (diff < 3600000) {
|
|
114
|
+
return `${Math.floor(diff / 60000)}分钟前`;
|
|
115
|
+
}
|
|
116
|
+
// 小于24小时
|
|
117
|
+
if (diff < 86400000) {
|
|
118
|
+
return `${Math.floor(diff / 3600000)}小时前`;
|
|
119
|
+
}
|
|
120
|
+
// 小于7天
|
|
121
|
+
if (diff < 604800000) {
|
|
122
|
+
return `${Math.floor(diff / 86400000)}天前`;
|
|
123
|
+
}
|
|
124
|
+
// 超过7天显示具体日期
|
|
125
|
+
return `${date.getMonth() + 1}月${date.getDate()}日`;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// 初始化
|
|
130
|
+
$Method.fetchData();
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<style scoped lang="scss">
|
|
134
|
+
.user-info-card {
|
|
135
|
+
background-color: #fff;
|
|
136
|
+
padding: 15px;
|
|
137
|
+
.user-header {
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
gap: 12px;
|
|
141
|
+
padding-bottom: 12px;
|
|
142
|
+
border-bottom: 1px solid $border-color;
|
|
143
|
+
|
|
144
|
+
.user-avatar {
|
|
145
|
+
width: 48px;
|
|
146
|
+
height: 48px;
|
|
147
|
+
background: linear-gradient(135deg, $primary-color, #764ba2);
|
|
148
|
+
border-radius: 50%;
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
justify-content: center;
|
|
152
|
+
color: white;
|
|
153
|
+
flex-shrink: 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.user-basic {
|
|
157
|
+
flex: 1;
|
|
158
|
+
min-width: 0;
|
|
159
|
+
|
|
160
|
+
.user-name {
|
|
161
|
+
font-size: 16px;
|
|
162
|
+
font-weight: 600;
|
|
163
|
+
color: $text-primary;
|
|
164
|
+
margin-bottom: 4px;
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
text-overflow: ellipsis;
|
|
167
|
+
white-space: nowrap;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.user-role {
|
|
171
|
+
font-size: 12px;
|
|
172
|
+
color: $text-secondary;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.user-details {
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
gap: 8px;
|
|
181
|
+
margin-top: 12px;
|
|
182
|
+
|
|
183
|
+
.detail-item {
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
gap: 8px;
|
|
187
|
+
font-size: 12px;
|
|
188
|
+
color: $text-secondary;
|
|
189
|
+
|
|
190
|
+
span {
|
|
191
|
+
overflow: hidden;
|
|
192
|
+
text-overflow: ellipsis;
|
|
193
|
+
white-space: nowrap;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.user-actions {
|
|
199
|
+
margin-top: 16px;
|
|
200
|
+
padding-top: 12px;
|
|
201
|
+
border-top: 1px solid $border-color;
|
|
202
|
+
display: flex;
|
|
203
|
+
justify-content: center;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="dashboard-container">
|
|
3
|
+
<SystemOverview />
|
|
4
|
+
<ServiceStatus />
|
|
5
|
+
<SystemResources />
|
|
6
|
+
<PerformanceMetrics />
|
|
7
|
+
<EnvironmentInfo />
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup>
|
|
12
|
+
import SystemOverview from './components/systemOverview.vue';
|
|
13
|
+
import ServiceStatus from './components/serviceStatus.vue';
|
|
14
|
+
import SystemResources from './components/systemResources.vue';
|
|
15
|
+
import PerformanceMetrics from './components/performanceMetrics.vue';
|
|
16
|
+
import EnvironmentInfo from './components/environmentInfo.vue';
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<style scoped lang="scss">
|
|
20
|
+
.dashboard-container {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: 12px;
|
|
24
|
+
overflow-y: auto;
|
|
25
|
+
height: 100%;
|
|
26
|
+
background-color: #fff;
|
|
27
|
+
padding: 15px;
|
|
28
|
+
}
|
|
29
|
+
</style>
|