Implement data migration tool and enhance KV storage support. Add automatic redirection for legacy data providers, improve user interface for migration settings, and update data handling for Classworks cloud storage. Refactor components for better integration with new storage options.
This commit is contained in:
@@ -82,14 +82,14 @@
|
||||
<!-- 统一的数据显示卡片 -->
|
||||
<v-card class="mb-6">
|
||||
<v-card-title class="d-flex align-center">
|
||||
<span>{{ migrationType === 'local' ? '本地数据库内容' : '服务器数据预览' }}</span>
|
||||
<span>{{ migrationType === 'local' ? '本地数据库内容' : '服务器数据内容' }}</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="primary"
|
||||
@click="migrationType === 'local' ? scanLocalDatabase() : previewServerData()"
|
||||
:loading="loading || scanning"
|
||||
>
|
||||
{{ migrationType === 'local' ? '扫描数据' : '预览数据' }}
|
||||
{{ migrationType === 'local' ? '扫描数据' : '加载数据' }}
|
||||
</v-btn>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
@@ -99,7 +99,7 @@
|
||||
>
|
||||
{{ migrationType === 'local'
|
||||
? '尚未扫描本地数据或未找到可迁移的数据。点击"扫描数据"按钮开始扫描。'
|
||||
: '尚未预览服务器数据或未找到可迁移的数据。点击"预览数据"按钮开始查询。'
|
||||
: '尚未预览服务器数据或未找到可迁移的数据。点击"加载数据"按钮开始查询。'
|
||||
}}
|
||||
</v-alert>
|
||||
|
||||
@@ -478,7 +478,8 @@ export default {
|
||||
const res = await axios.get(homeworkUrl, {
|
||||
headers: this.getRequestHeaders()
|
||||
});
|
||||
if (res.data) {
|
||||
if (res.data&&res.data.status!=false) {
|
||||
console.log(res.data);
|
||||
this.serverItems.push({
|
||||
type: 'homework',
|
||||
key: `homework_${this.classNumber}_${dateStr}`,
|
||||
@@ -624,7 +625,7 @@ export default {
|
||||
|
||||
if (itemType === 'config') {
|
||||
// 配置键名: classNumber/classworks-config
|
||||
await db.put("kv", JSON.stringify(value), `${this.classNumber}/classworks-config`);
|
||||
await db.put("kv", JSON.stringify(value), `classworks-config`);
|
||||
return { success: true, message: '配置已迁移' };
|
||||
} else {
|
||||
// 数据键名: classNumber/classworks-data-YYYYMMDD
|
||||
@@ -644,7 +645,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
await db.put("kv", JSON.stringify(value), `${this.classNumber}/classworks-data-${dateStr}`);
|
||||
await db.put("kv", JSON.stringify(value), `classworks-data-${dateStr}`);
|
||||
return { success: true, message: `${dateStr} 数据已迁移` };
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -169,10 +169,9 @@ export default {
|
||||
'dark': '深色'
|
||||
},
|
||||
'server.provider': {
|
||||
'server': '远程服务器',
|
||||
'indexedDB': '本地存储',
|
||||
'kv-local': 'KV本地存储',
|
||||
'kv-server': 'KV远程服务器'
|
||||
'kv-server': 'KV远程服务器',
|
||||
'classworkscloud': 'Classworks云端存储'
|
||||
}
|
||||
},
|
||||
// 默认图标映射,按设置类型
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<settings-card title="数据源设置" icon="mdi-database-cog">
|
||||
<v-list>
|
||||
<!-- 服务器模式设置 -->
|
||||
<template v-if="currentProvider === 'server' || currentProvider === 'kv-server'">
|
||||
<template v-if="currentProvider === 'kv-server' || currentProvider === 'classworkscloud'">
|
||||
<v-list-item>
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-lan-connect" class="mr-3" />
|
||||
@@ -13,17 +13,29 @@
|
||||
测试连接
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-list-item><!-- 数据迁移,仅对KV本地存储有效 -->
|
||||
<v-list-item>
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-database-import" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title>迁移旧数据</v-list-item-title>
|
||||
<v-list-item-subtitle>将旧的存储格式数据转移到新的KV存储</v-list-item-subtitle>
|
||||
<template #append>
|
||||
<v-btn :loading="migrateLoading" variant="tonal" @click="migrateData">
|
||||
迁移
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
<!-- IndexedDB设置 -->
|
||||
<template v-if="currentProvider === 'indexedDB' || currentProvider === 'kv-local'">
|
||||
<!-- 本地存储设置 -->
|
||||
<template v-if="currentProvider === 'kv-local'">
|
||||
<v-list-item>
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-database" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title>清除数据库缓存</v-list-item-title>
|
||||
<v-list-item-subtitle>这将清除所有IndexedDB中的数据</v-list-item-subtitle>
|
||||
<v-list-item-subtitle>这将清除所有本地数据库中的数据</v-list-item-subtitle>
|
||||
<template #append>
|
||||
<v-btn color="error" variant="tonal" @click="confirmClearIndexedDB">
|
||||
清除
|
||||
@@ -40,8 +52,8 @@
|
||||
</template>
|
||||
</v-list-item>
|
||||
|
||||
<!-- 显示机器ID,仅对KV本地存储有效 -->
|
||||
<v-list-item v-if="currentProvider === 'kv-local'">
|
||||
<!-- 显示机器ID -->
|
||||
<v-list-item>
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-identifier" class="mr-3" />
|
||||
</template>
|
||||
@@ -76,31 +88,6 @@
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
|
||||
<v-list-item>
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-database-sync" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title>高级数据迁移工具</v-list-item-title>
|
||||
<v-list-item-subtitle>更强大的数据迁移工具,支持从本地或服务器迁移到KV存储</v-list-item-subtitle>
|
||||
<template #append>
|
||||
<v-btn variant="tonal" color="primary" to="/datamigration">
|
||||
打开
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
|
||||
<v-list-item>
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-lan-connect" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title>CSES转WakeUP工具</v-list-item-title>
|
||||
<template #append>
|
||||
<v-btn variant="tonal" to="/cses2wakeup">
|
||||
查看
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
|
||||
<!-- 确认对话框 -->
|
||||
@@ -122,7 +109,6 @@
|
||||
import SettingsCard from "@/components/SettingsCard.vue";
|
||||
import { getSetting } from "@/utils/settings";
|
||||
import axios from "axios";
|
||||
import { getMachineId } from "@/utils/providers/kvProvider";
|
||||
|
||||
export default {
|
||||
name: "DataProviderSettingsCard",
|
||||
@@ -147,7 +133,7 @@ export default {
|
||||
},
|
||||
|
||||
isKvProvider() {
|
||||
return this.currentProvider === 'kv-local' || this.currentProvider === 'kv-server';
|
||||
return this.currentProvider === 'kv-local' || this.currentProvider === 'kv-server' || this.currentProvider === 'classworkscloud';
|
||||
}
|
||||
},
|
||||
|
||||
@@ -155,7 +141,7 @@ export default {
|
||||
// 如果是KV本地存储,获取机器ID
|
||||
if (this.currentProvider === 'kv-local') {
|
||||
try {
|
||||
this.machineId = await getMachineId();
|
||||
this.machineId = getSetting('device.uuid');
|
||||
} catch (error) {
|
||||
console.error("获取机器ID失败:", error);
|
||||
}
|
||||
|
||||
@@ -12,12 +12,18 @@
|
||||
</p>
|
||||
</v-alert>
|
||||
|
||||
<v-alert v-if="isClassworksCloud" type="info" color="success" variant="tonal" class="my-2">
|
||||
<v-alert-title>Classworks云端存储</v-alert-title>
|
||||
<p>Classworks云端存储是官方提供的存储解决方案,自动配置了最优的访问设置。</p>
|
||||
<p>使用此选项时,服务器域名和网站令牌将自动配置,无需手动设置。</p>
|
||||
</v-alert>
|
||||
|
||||
<v-divider class="my-2" />
|
||||
<setting-item setting-key="server.domain" title="服务器域名" />
|
||||
<setting-item setting-key="server.domain" title="服务器域名" :disabled="isClassworksCloud" />
|
||||
<v-divider class="my-2" />
|
||||
<setting-item setting-key="server.classNumber" title="班号" />
|
||||
<v-divider class="my-2" />
|
||||
<setting-item setting-key="server.siteKey" title="网站令牌">
|
||||
<setting-item setting-key="server.siteKey" title="网站令牌" :disabled="isClassworksCloud">
|
||||
<template #description>
|
||||
用于后端验证请求的安全令牌。如需要,请从系统管理员获取。
|
||||
</template>
|
||||
@@ -53,8 +59,11 @@ export default {
|
||||
isKvProvider() {
|
||||
return this.currentProvider === 'kv-local' || this.currentProvider === 'kv-server';
|
||||
},
|
||||
isClassworksCloud() {
|
||||
return this.currentProvider === 'classworkscloud';
|
||||
},
|
||||
useServer() {
|
||||
return this.currentProvider === 'server' || this.currentProvider === 'kv-server';
|
||||
return this.currentProvider === 'server' || this.currentProvider === 'kv-server' || this.currentProvider === 'classworkscloud';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user