fix: 设置页同步信息引用未定义变量导致的运行时崩溃(loadError/isSyncConfigured/autoOn)

This commit is contained in:
root
2026-10-16 15:18:51 +08:00
parent 04ae06ec1c
commit 9bd04441e1
6 changed files with 21 additions and 23 deletions
+4 -6
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { onMounted, ref, watch } from 'vue'
import Icon from '../components/Icon.vue'
import ConfirmDialog from '../components/ConfirmDialog.vue'
import {
@@ -13,7 +13,7 @@ import { downloadCsv } from '../lib/csv'
import { hhmm, parseDateStr, todayStr } from '../lib/date'
import { computeDay } from '../domain/attendance'
import { changeLoginPassword, deleteCurrentUser, getSession } from '../db/auth'
import { ensureCloudBinding, getSyncBase, getSyncLastTime, syncWithStoredConfig, syncLastError, enableRealtimeSync, stopRealtime, type SyncResult } from '../sync/engine'
import { ensureCloudBinding, getSyncBase, getSyncLastTime, isSyncConfigured, syncWithStoredConfig, syncLastError, type SyncResult } from '../sync/engine'
import { getCloudCreds } from '../db/auth'
import { showToast } from '../lib/toast'
@@ -49,10 +49,9 @@ async function loadSyncInfo() {
syncBase.value = await getSyncBase()
cloudUser.value = getCloudCreds()?.username || ''
lastSync.value = await getSyncLastTime()
loadError.value = syncLastError.value
const conf = await isSyncConfigured()
autoOn.value = conf
autoSyncErr.value = syncLastError.value
}
watch(syncLastError, v => { autoSyncErr.value = v })
async function saveSyncConfig() {
@@ -364,7 +363,6 @@ async function doImport() {
</div>
<div v-if="syncStatus" class="muted acc-line">上次同步:{{ lastSync || '--' }} · {{ syncStatus }}</div>
<div v-if="syncError" class="form-error">{{ syncError }}</div>
<div v-if="autoSyncErr" class="form-error">最近自动同步失败:{{ autoSyncErr }}</div>
<div v-if="autoSyncErr" class="form-error">最近自动同步失败:{{ autoSyncErr }}(可点「立即同步」重试)</div>
</div>