仰望星辰工作室

better-staridc-MNBT

better-staridc-MNBT/ templates/tdesign/spa/src/admin/views/RepairView.vue 3.3 KB · 127 行 原始文件
Z zfhsh first commit 2 个月前
1<template>
2 <div class="td-page">
3 <div class="td-page-head">
4 <div>
5 <h3 class="td-page-title"><i class="mdi mdi-backup-restore"></i>系统修复</h3>
6 <p class="td-page-subtitle">修复配置、数据表、缓存与文件权限</p>
7 </div>
8 </div>
9
10 <div class="td-form-note rep-note">
11 <b>警告:</b> 修复操作可能影响系统运行,请谨慎执行;建议先备份系统与数据库后再操作。
12 </div>
13
14 <div class="rep-grid">
15 <div v-for="item in repairItems" :key="item.id" class="td-set-card">
16 <div class="td-set-card-hd">
17 <div class="td-set-icon" :style="{ background: item.bg, color: item.color }">
18 <i class="mdi" :class="item.icon"></i>
19 </div>
20 <div class="rep-card-head">
21 <h4>{{ item.title }}</h4>
22 <p>{{ item.desc }}</p>
23 </div>
24 </div>
25 <div class="td-set-card-bd">
26 <div class="rep-detail">{{ item.detail }}</div>
27 <t-button
28 theme="primary"
29 variant="outline"
30 :loading="busyId === item.id"
31 @click="runRepair(item)"
32 >
33 <template #icon><i class="mdi mdi-wrench"></i></template>
34 执行修复
35 </t-button>
36 </div>
37 </div>
38 </div>
39 </div>
40</template>
41
42<script setup>
43import { ref } from 'vue'
44import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
45import { repair } from '@/admin/api/repair'
46
47const busyId = ref(0)
48
49const repairItems = [
50 {
51 id: 1,
52 title: '修复配置文件',
53 desc: '重新生成系统配置文件',
54 detail: '当 config.php 损坏或字段缺失时使用,会按当前环境重写配置。',
55 icon: 'mdi-tools',
56 color: '#0052d9',
57 bg: '#e8f3ff',
58 },
59 {
60 id: 2,
61 title: '重建数据表',
62 desc: '检查并修复数据库表结构',
63 detail: '比对系统所需表结构,自动新增缺失字段或修复损坏的表。',
64 icon: 'mdi-database-refresh',
65 color: '#2ba471',
66 bg: '#e8f8f0',
67 },
68 {
69 id: 3,
70 title: '清理缓存',
71 desc: '清理系统临时缓存文件',
72 detail: '删除缓存目录与编译模板,释放空间并解决缓存导致的问题。',
73 icon: 'mdi-broom',
74 color: '#e37318',
75 bg: '#fff3e0',
76 },
77 {
78 id: 4,
79 title: '修复权限',
80 desc: '修复文件和目录权限',
81 detail: '按推荐权限规则重置关键目录与文件的读写执行权限。',
82 icon: 'mdi-shield-key',
83 color: '#d54941',
84 bg: '#fdecee',
85 },
86]
87
88function runRepair(item) {
89 const dialog = DialogPlugin.confirm({
90 header: '确认执行修复',
91 body: `将执行「${item.title}」操作,是否继续?`,
92 confirmBtn: { content: '执行', theme: 'primary' },
93 onConfirm: async () => {
94 dialog.destroy()
95 busyId.value = item.id
96 const r = await repair(item.id, 'repair')
97 busyId.value = 0
98 if (r.ok) {
99 MessagePlugin.success(r.message || '修复成功')
100 }
101 },
102 onClose: () => dialog.destroy(),
103 })
104}
105</script>
106
107<style scoped>
108.rep-note {
109 margin-top: 0;
110 margin-bottom: 14px;
111}
112.rep-grid {
113 display: grid;
114 grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
115 gap: 14px;
116}
117.rep-card-head {
118 flex: 1;
119 min-width: 0;
120}
121.rep-detail {
122 font-size: 12px;
123 color: var(--td-text-secondary);
124 line-height: 1.7;
125 margin-bottom: 12px;
126}
127</style>