🚧 Optimize

This commit is contained in:
2025-09-30 00:28:15 +08:00
parent 4d6a4ff79f
commit cf8bf688bf
36 changed files with 1520 additions and 3896 deletions

View File

@@ -2,7 +2,7 @@
import {useConfigStore} from '@/stores/configStore';
import {useBackupStore} from '@/stores/backupStore';
import {useI18n} from 'vue-i18n';
import {computed, onMounted, onUnmounted} from 'vue';
import {computed, onUnmounted} from 'vue';
import SettingSection from '../components/SettingSection.vue';
import SettingItem from '../components/SettingItem.vue';
import ToggleSwitch from '../components/ToggleSwitch.vue';
@@ -13,14 +13,8 @@ const {t} = useI18n();
const configStore = useConfigStore();
const backupStore = useBackupStore();
// 确保配置已加载
onMounted(async () => {
if (!configStore.configLoaded) {
await configStore.initConfig();
}
});
onUnmounted(() => {
backupStore.clearError();
backupStore.clearStatus();
});
// 认证方式选项
@@ -142,6 +136,11 @@ const pushToRemote = async () => {
await backupStore.pushToRemote();
};
// 重试备份
const retryBackup = async () => {
await backupStore.retryBackup();
};
// 选择SSH密钥文件
const selectSshKeyFile = async () => {
// 使用DialogService选择文件
@@ -311,8 +310,8 @@ const selectSshKeyFile = async () => {
>
<div class="backup-operation-container">
<div class="backup-status-icons">
<span v-if="backupStore.pushSuccess" class="success-icon"></span>
<span v-if="backupStore.pushError" class="error-icon"></span>
<span v-if="backupStore.isSuccess" class="success-icon"></span>
<span v-if="backupStore.isError" class="error-icon"></span>
</div>
<button
class="push-button"
@@ -323,10 +322,18 @@ const selectSshKeyFile = async () => {
<span v-if="backupStore.isPushing" class="loading-spinner"></span>
{{ backupStore.isPushing ? t('settings.backup.pushing') : t('settings.backup.actions.push') }}
</button>
<button
v-if="backupStore.isError"
class="retry-button"
@click="() => retryBackup()"
:disabled="backupStore.isPushing"
>
{{ t('settings.backup.actions.retry') }}
</button>
</div>
</SettingItem>
<div v-if="backupStore.error" class="error-message-row">
{{ backupStore.error }}
<div v-if="backupStore.errorMessage" class="error-message-row">
{{ backupStore.errorMessage }}
</div>
</SettingSection>
</div>
@@ -428,7 +435,8 @@ const selectSshKeyFile = async () => {
}
// 按钮样式
.push-button {
.push-button,
.retry-button {
padding: 8px 16px;
background-color: var(--settings-input-bg);
border: 1px solid var(--settings-input-border);
@@ -472,6 +480,17 @@ const selectSshKeyFile = async () => {
}
}
.retry-button {
background-color: #ff9800;
border-color: #ff9800;
color: white;
&:hover:not(:disabled) {
background-color: #f57c00;
border-color: #f57c00;
}
}
// 错误信息行样式
.error-message-row {
color: #f44336;

View File

@@ -11,10 +11,11 @@ import {
MigrationService,
MigrationStatus
} from '@/../bindings/voidraft/internal/services';
import * as runtime from '@wailsio/runtime';
import {useSystemStore} from "@/stores/systemStore";
const {t} = useI18n();
const configStore = useConfigStore();
const systemStore = useSystemStore();
// 迁移进度状态
const migrationProgress = ref<MigrationProgress>(new MigrationProgress({
@@ -148,8 +149,7 @@ const alwaysOnTop = computed({
set: async (value: boolean) => {
// 先更新配置
await configStore.setAlwaysOnTop(value);
// 然后立即应用窗口置顶状态
await runtime.Window.SetAlwaysOnTop(value);
await systemStore.setWindowOnTop(value);
}
});

View File

@@ -1,17 +1,22 @@
<script setup lang="ts">
import {useI18n} from 'vue-i18n';
import {computed} from 'vue';
import {useConfigStore} from '@/stores/configStore';
import {useUpdateStore} from '@/stores/updateStore';
import { useI18n } from 'vue-i18n';
import { computed, onUnmounted } from 'vue';
import { useConfigStore } from '@/stores/configStore';
import { useUpdateStore } from '@/stores/updateStore';
import SettingSection from '../components/SettingSection.vue';
import SettingItem from '../components/SettingItem.vue';
import ToggleSwitch from '../components/ToggleSwitch.vue';
import { Remarkable } from 'remarkable';
const {t} = useI18n();
const { t } = useI18n();
const configStore = useConfigStore();
const updateStore = useUpdateStore();
// 清理状态
onUnmounted(() => {
updateStore.clearStatus();
});
// 初始化Remarkable实例并配置
const md = new Remarkable({
html: true, // 允许HTML
@@ -93,13 +98,21 @@ const currentVersion = computed(() => {
</SettingItem>
<!-- 检查结果 -->
<div class="check-results" v-if="updateStore.updateResult || updateStore.errorMessage">
<div class="check-results" v-if="updateStore.updateResult || updateStore.isError">
<!-- 错误信息 -->
<div v-if="updateStore.errorMessage" class="result-item error-result">
<div v-if="updateStore.isError" class="result-item error-result">
<div class="result-text">
<span class="result-icon"></span>
<div class="result-message">{{ updateStore.errorMessage }}</div>
</div>
<button
v-if="updateStore.isError"
class="retry-button"
@click="updateStore.checkForUpdates"
:disabled="updateStore.isChecking"
>
{{ t('common.retry') }}
</button>
</div>
<!-- 更新成功 -->
@@ -128,7 +141,7 @@ const currentVersion = computed(() => {
</div>
<!-- 已是最新版本 -->
<div v-else-if="updateStore.updateResult && !updateStore.hasUpdate && !updateStore.errorMessage"
<div v-else-if="updateStore.updateResult && !updateStore.hasUpdate && !updateStore.isError"
class="result-item latest-version">
<div class="result-text">
<span class="result-icon"></span>
@@ -232,6 +245,28 @@ const currentVersion = computed(() => {
overflow: visible;
padding-right: 8px; // 添加右侧内边距,防止文本贴近容器边缘
}
.retry-button {
margin-top: 8px;
padding: 6px 12px;
background-color: #ff9800;
border: 1px solid #ff9800;
border-radius: 4px;
color: white;
cursor: pointer;
font-size: 12px;
transition: all 0.2s ease;
&:hover:not(:disabled) {
background-color: #f57c00;
border-color: #f57c00;
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
}
}
@@ -421,4 +456,4 @@ const currentVersion = computed(() => {
padding: 6px 12px;
}
}
</style>
</style>