feat: 完整日志系统 + 设置增强 + 子窗口交互优化

This commit is contained in:
2026-07-20 13:17:28 +08:00
parent 1bc2da9c20
commit f89391c791
22 changed files with 559 additions and 112 deletions
+5 -17
View File
@@ -3,6 +3,7 @@
<SettingDialog v-if="dialogType === 'settings'" />
<HistoryDialog v-if="dialogType === 'history'" />
<TemplateDialog v-if="dialogType === 'templates'" />
<LogDialog v-if="dialogType === 'logs'" />
<RubricEditor v-if="dialogType === 'rubric'" />
<ResultDrawer v-if="dialogType === 'result'" />
</template>
@@ -12,15 +13,16 @@
</template>
<script setup lang="ts">
import { nextTick, onMounted } from 'vue'
import { onMounted } from 'vue'
import { useAppStore } from '@/stores/app'
import { useSettingsStore } from '@/stores/settings'
import { useGradingStore } from '@/stores/grading'
import { LogicalSize, getCurrentWindow } from '@tauri-apps/api/window'
import ResultDrawer from '@/components/ResultDrawer.vue'
import logger from '@/utils/logger'
import SettingDialog from '@/components/SettingDialog.vue'
import HistoryDialog from '@/pages/HistoryDialog.vue'
import TemplateDialog from '@/pages/TemplateDialog.vue'
import LogDialog from '@/pages/LogDialog.vue'
import RubricEditor from '@/components/RubricEditor.vue'
const appStore = useAppStore()
@@ -33,19 +35,6 @@ const isScreenshot = window.location.hash.startsWith('#/screenshot')
const winClass = isScreenshot ? 'win-screenshot' : dialogType ? 'win-dialog' : 'win-main'
document.documentElement.dataset.window = winClass
async function resizeToContent() {
await nextTick()
await nextTick()
const el = document.querySelector('.el-dialog') || document.querySelector('.drawer-panel') || document.querySelector('.win-dialog-body')
if (!el) return
const rect = el.getBoundingClientRect()
try {
const w = Math.ceil(rect.width) + 40
const h = Math.ceil(rect.height) + 80
await getCurrentWindow().setSize(new LogicalSize(Math.max(300, w), Math.max(200, h)))
} catch {}
}
onMounted(async () => {
if (dialogType === 'result') {
const { invoke } = await import('@tauri-apps/api/core')
@@ -57,17 +46,16 @@ onMounted(async () => {
if (data.currentQuestionIndex !== undefined) gradingStore.setCurrentQuestionIndex(data.currentQuestionIndex)
}
appStore.openResultDrawer()
await resizeToContent()
} else if (dialogType) {
if (dialogType === 'settings') await settingsStore.loadSettings()
const actions: Record<string, () => void> = {
settings: () => appStore.openSettingDialog(),
history: () => appStore.openHistoryDialog(),
templates: () => appStore.openTemplateDialog(),
logs: () => appStore.openLogDialog(),
rubric: () => appStore.openRubricEditor()
}
actions[dialogType]?.()
setTimeout(resizeToContent, 200)
} else {
await settingsStore.loadSettings()
}