Skip to content

Commit 596c6ac

Browse files
committed
Refactor DataProviderSettingsCard.vue for improved readability and structure. Clean up template formatting, reorganize data migration and machine ID display sections, and ensure consistent button styling. Update server connection check and migration data handling for better user experience.
1 parent 590cffc commit 596c6ac

File tree

1 file changed

+59
-60
lines changed

1 file changed

+59
-60
lines changed

src/components/settings/cards/DataProviderSettingsCard.vue

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,27 @@
22
<settings-card title="数据源设置" icon="mdi-database-cog">
33
<v-list>
44
<!-- 服务器模式设置 -->
5-
<template v-if="currentProvider === 'kv-server' || currentProvider === 'classworkscloud'">
5+
<template
6+
v-if="
7+
currentProvider === 'kv-server' ||
8+
currentProvider === 'classworkscloud'
9+
"
10+
>
611
<v-list-item>
712
<template #prepend>
813
<v-icon icon="mdi-lan-connect" class="mr-3" />
914
</template>
1015
<v-list-item-title>检查服务器连接</v-list-item-title>
1116
<template #append>
12-
<v-btn :loading="loading" variant="tonal" @click="checkServerConnection">
17+
<v-btn
18+
:loading="loading"
19+
variant="tonal"
20+
@click="checkServerConnection"
21+
>
1322
测试连接
1423
</v-btn>
15-
</template>
16-
</v-list-item><!-- 数据迁移,仅对KV本地存储有效 -->
17-
<v-list-item>
18-
<template #prepend>
19-
<v-icon icon="mdi-database-import" class="mr-3" />
20-
</template>
21-
<v-list-item-title>迁移旧数据</v-list-item-title>
22-
<v-list-item-subtitle>将旧的存储格式数据转移到新的KV存储</v-list-item-subtitle>
23-
<template #append>
24-
<v-btn :loading="migrateLoading" variant="tonal" @click="migrateData">
25-
迁移
26-
</v-btn>
27-
</template>
28-
</v-list-item>
24+
</template> </v-list-item
25+
><!-- 数据迁移,仅对KV本地存储有效 -->
2926
</template>
3027

3128
<!-- 本地存储设置 -->
@@ -35,7 +32,9 @@
3532
<v-icon icon="mdi-database" class="mr-3" />
3633
</template>
3734
<v-list-item-title>清除数据库缓存</v-list-item-title>
38-
<v-list-item-subtitle>这将清除所有本地数据库中的数据</v-list-item-subtitle>
35+
<v-list-item-subtitle
36+
>这将清除所有本地数据库中的数据</v-list-item-subtitle
37+
>
3938
<template #append>
4039
<v-btn color="error" variant="tonal" @click="confirmClearIndexedDB">
4140
清除
@@ -51,41 +50,38 @@
5150
<v-btn variant="tonal" @click="exportData"> 导出 </v-btn>
5251
</template>
5352
</v-list-item>
54-
55-
<!-- 显示机器ID -->
56-
<v-list-item>
57-
<template #prepend>
58-
<v-icon icon="mdi-identifier" class="mr-3" />
59-
</template>
60-
<v-list-item-title>本机唯一标识符</v-list-item-title>
61-
<v-list-item-subtitle v-if="machineId">{{ machineId }}</v-list-item-subtitle>
62-
<v-list-item-subtitle v-else>正在加载...</v-list-item-subtitle>
63-
</v-list-item>
64-
65-
<!-- 数据迁移,仅对KV本地存储有效 -->
66-
<v-list-item v-if="currentProvider === 'kv-local'">
67-
<template #prepend>
68-
<v-icon icon="mdi-database-import" class="mr-3" />
69-
</template>
70-
<v-list-item-title>迁移旧数据</v-list-item-title>
71-
<v-list-item-subtitle>将旧的存储格式数据转移到新的KV存储</v-list-item-subtitle>
72-
<template #append>
73-
<v-btn :loading="migrateLoading" variant="tonal" @click="migrateData">
74-
迁移
75-
</v-btn>
76-
</template>
77-
</v-list-item>
7853
</template>
79-
54+
<v-list-item>
55+
<template #prepend>
56+
<v-icon icon="mdi-database-import" class="mr-3" />
57+
</template>
58+
<v-list-item-title>迁移旧数据</v-list-item-title>
59+
<v-list-item-subtitle
60+
>将旧的存储格式数据转移到新的KV存储</v-list-item-subtitle
61+
>
62+
<template #append>
63+
<v-btn :loading="migrateLoading" variant="tonal" @click="migrateData">
64+
迁移
65+
</v-btn>
66+
</template> </v-list-item
67+
><!-- 显示机器ID -->
68+
<v-list-item>
69+
<template #prepend>
70+
<v-icon icon="mdi-identifier" class="mr-3" />
71+
</template>
72+
<v-list-item-title>本机唯一标识符</v-list-item-title>
73+
<v-list-item-subtitle v-if="machineId">{{
74+
machineId
75+
}}</v-list-item-subtitle>
76+
<v-list-item-subtitle v-else>正在加载...</v-list-item-subtitle>
77+
</v-list-item>
8078
<v-list-item>
8179
<template #prepend>
8280
<v-icon icon="mdi-lan-connect" class="mr-3" />
8381
</template>
8482
<v-list-item-title>查看本地缓存</v-list-item-title>
8583
<template #append>
86-
<v-btn variant="tonal" to="/cachemanagement">
87-
查看
88-
</v-btn>
84+
<v-btn variant="tonal" to="/cachemanagement"> 查看 </v-btn>
8985
</template>
9086
</v-list-item>
9187
</v-list>
@@ -97,8 +93,12 @@
9793
<v-card-text>{{ confirmMessage }}</v-card-text>
9894
<v-card-actions>
9995
<v-spacer></v-spacer>
100-
<v-btn color="grey" variant="text" @click="confirmDialog = false">取消</v-btn>
101-
<v-btn color="error" variant="tonal" @click="handleConfirm">确认</v-btn>
96+
<v-btn color="grey" variant="text" @click="confirmDialog = false"
97+
>取消</v-btn
98+
>
99+
<v-btn color="error" variant="tonal" @click="handleConfirm"
100+
>确认</v-btn
101+
>
102102
</v-card-actions>
103103
</v-card>
104104
</v-dialog>
@@ -133,19 +133,18 @@ export default {
133133
},
134134
135135
isKvProvider() {
136-
return this.currentProvider === 'kv-local' || this.currentProvider === 'kv-server' || this.currentProvider === 'classworkscloud';
137-
}
136+
return (
137+
this.currentProvider === "kv-local" ||
138+
this.currentProvider === "kv-server" ||
139+
this.currentProvider === "classworkscloud"
140+
);
141+
},
138142
},
139143
140144
async created() {
141145
// 如果是KV本地存储,获取机器ID
142-
if (this.currentProvider === 'kv-local') {
143-
try {
144-
this.machineId = getSetting('device.uuid');
145-
} catch (error) {
146-
console.error("获取机器ID失败:", error);
147-
}
148-
}
146+
147+
this.machineId = getSetting("device.uuid");
149148
},
150149
151150
methods: {
@@ -159,12 +158,12 @@ export default {
159158
// Prepare headers including site key if available
160159
const headers = { Accept: "application/json" };
161160
if (siteKey) {
162-
headers['x-site-key'] = siteKey;
161+
headers["x-site-key"] = siteKey;
163162
}
164163
165-
const response = await axios.get(`${domain}/api/test`, {
164+
const response = await axios.get(`${domain}/check`, {
166165
method: "GET",
167-
headers
166+
headers,
168167
});
169168
170169
if (response.data.status === "success") {
@@ -276,7 +275,7 @@ export default {
276275
277276
async migrateData() {
278277
this.migrateLoading = true;
279-
this.$router.push('/datamigration');
278+
this.$router.push("/datamigration");
280279
this.migrateLoading = false;
281280
},
282281

0 commit comments

Comments
 (0)