mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
feat(storage): allow ignoring legacy data prompt
This commit is contained in:
1 parent
04c97ca9cf
commit
a94986f117
5 files changed
+57
-11
No files matched your search
@@ -21,6 +21,7 @@ const defaultDataDir = ref('')
|
||||
const isCustomDataDir = ref(false)
|
||||
const isUpdatingDataDir = ref(false)
|
||||
const dataDirError = ref<string | null>(null)
|
||||
const isMigrateHintIgnored = ref(false)
|
||||
|
||||
// 确认弹窗状态
|
||||
const showConfirmModal = ref(false)
|
||||
@@ -59,15 +60,40 @@ async function loadCacheInfo() {
|
||||
|
||||
// 加载数据目录
|
||||
const canMigrateToDefault = computed(() => {
|
||||
return IS_ELECTRON && dataDir.value && defaultDataDir.value && dataDir.value !== defaultDataDir.value
|
||||
return (
|
||||
IS_ELECTRON &&
|
||||
dataDir.value &&
|
||||
defaultDataDir.value &&
|
||||
dataDir.value !== defaultDataDir.value &&
|
||||
!isMigrateHintIgnored.value
|
||||
)
|
||||
})
|
||||
|
||||
function getMigrateHintIgnoreKey(pathValue: string, defaultPathValue: string): string {
|
||||
return `chatlab_ignore_migrate_default_hint:${pathValue}:${defaultPathValue}`
|
||||
}
|
||||
|
||||
function updateMigrateHintIgnored() {
|
||||
if (!dataDir.value || !defaultDataDir.value) {
|
||||
isMigrateHintIgnored.value = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
isMigrateHintIgnored.value =
|
||||
localStorage.getItem(getMigrateHintIgnoreKey(dataDir.value, defaultDataDir.value)) === '1'
|
||||
} catch {
|
||||
isMigrateHintIgnored.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDataDir() {
|
||||
try {
|
||||
const info = await useCacheService().getDataDir()
|
||||
dataDir.value = info.path
|
||||
defaultDataDir.value = info.defaultPath || ''
|
||||
isCustomDataDir.value = info.isCustom
|
||||
updateMigrateHintIgnored()
|
||||
} catch (error) {
|
||||
console.error('获取数据目录失败:', error)
|
||||
}
|
||||
@@ -140,6 +166,17 @@ function migrateToDefaultDir() {
|
||||
showConfirmModal.value = true
|
||||
}
|
||||
|
||||
function ignoreMigrateHint() {
|
||||
if (!dataDir.value || !defaultDataDir.value) return
|
||||
|
||||
try {
|
||||
localStorage.setItem(getMigrateHintIgnoreKey(dataDir.value, defaultDataDir.value), '1')
|
||||
} catch {
|
||||
// localStorage 不可用时只在当前页面隐藏,避免阻塞用户继续使用设置页。
|
||||
}
|
||||
isMigrateHintIgnored.value = true
|
||||
}
|
||||
|
||||
// 确认切换数据目录
|
||||
async function confirmDataDirChange() {
|
||||
showConfirmModal.value = false
|
||||
@@ -351,16 +388,21 @@ defineExpose({
|
||||
{{ defaultDataDir }}
|
||||
</p>
|
||||
</div>
|
||||
<UButton
|
||||
size="sm"
|
||||
color="primary"
|
||||
variant="soft"
|
||||
:loading="isUpdatingDataDir"
|
||||
:disabled="isUpdatingDataDir"
|
||||
@click="migrateToDefaultDir"
|
||||
>
|
||||
{{ t('settings.storage.dataLocation.migrateAction') }}
|
||||
</UButton>
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<UButton size="sm" variant="ghost" :disabled="isUpdatingDataDir" @click="ignoreMigrateHint">
|
||||
{{ t('settings.storage.dataLocation.ignoreMigrateHint') }}
|
||||
</UButton>
|
||||
<UButton
|
||||
size="sm"
|
||||
color="primary"
|
||||
variant="soft"
|
||||
:loading="isUpdatingDataDir"
|
||||
:disabled="isUpdatingDataDir"
|
||||
@click="migrateToDefaultDir"
|
||||
>
|
||||
{{ t('settings.storage.dataLocation.migrateAction') }}
|
||||
</UButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-2 text-xs text-amber-600 dark:text-amber-400">
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
"reset": "Reset",
|
||||
"open": "Open",
|
||||
"migrateHint": "Data is still at a legacy location. Migrate to the unified directory:",
|
||||
"ignoreMigrateHint": "Ignore",
|
||||
"migrateAction": "Migrate Now",
|
||||
"restartTip": "Please restart the app after switching. Data will be migrated from the old directory.",
|
||||
"confirmTitle": "Confirm Directory Change",
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
"reset": "デフォルトに戻す",
|
||||
"open": "開く",
|
||||
"migrateHint": "データがまだ旧ディレクトリにあります。統一ディレクトリへの移行をお勧めします:",
|
||||
"ignoreMigrateHint": "無視",
|
||||
"migrateAction": "今すぐ移行",
|
||||
"restartTip": "ディレクトリ変更後はアプリを再起動してください。旧ディレクトリのキャッシュは自動で移行されます",
|
||||
"confirmTitle": "データディレクトリの切り替えを確認",
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
"reset": "恢复默认",
|
||||
"open": "打开",
|
||||
"migrateHint": "检测到数据仍在旧位置,建议迁移至统一目录:",
|
||||
"ignoreMigrateHint": "忽略",
|
||||
"migrateAction": "一键迁移",
|
||||
"restartTip": "切换目录后请重启应用,旧目录下缓存会跟随迁移",
|
||||
"confirmTitle": "确认切换数据目录",
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
"reset": "還原預設",
|
||||
"open": "開啟",
|
||||
"migrateHint": "偵測到資料仍在舊位置,建議遷移至統一目錄:",
|
||||
"ignoreMigrateHint": "忽略",
|
||||
"migrateAction": "一鍵遷移",
|
||||
"restartTip": "切換目錄後請重新啟動應用程式,舊目錄下快取會跟隨遷移",
|
||||
"confirmTitle": "確認切換資料目錄",
|
||||
|
||||
Reference in new issue
Block a user