Private
Public Access
1
0

重构:文件系统模块化架构,优化应用启动流程

This commit is contained in:
2026-01-28 00:28:54 +08:00
parent 4a9b25a505
commit 8c577f70e7
123 changed files with 32030 additions and 967 deletions

View File

@@ -2,9 +2,11 @@
<a-layout class="layout">
<a-layout-header class="header">
<div class="header-content">
<h2>Go Desk</h2>
<div class="header-left">
<h2>U-Desk</h2>
</div>
<a-tabs v-model:active-key="activeTab" class="header-tabs">
<a-tab-pane key="db-cli" title="数据库客户端"/>
<a-tab-pane key="db-cli" title="数据库"/>
<a-tab-pane key="file-system" title="文件管理"/>
<a-tab-pane key="user" title="用户查询"/>
<a-tab-pane key="device" title="设备调用测试"/>
@@ -13,11 +15,34 @@
<a-tooltip content="版本更新">
<a-button type="text" @click="showUpdateModal = true">
<template #icon>
<icon-sync />
<IconSync />
</template>
</a-button>
</a-tooltip>
<ThemeToggle />
<!-- 窗口控制按钮 -->
<div class="window-controls">
<div class="window-control-btn" @click="handleMinimize" title="最小化">
<svg width="12" height="12" viewBox="0 0 12 12">
<rect x="0" y="5" width="12" height="2" fill="currentColor"/>
</svg>
</div>
<div class="window-control-btn" @click="handleMaximize" :title="isMaximized ? '还原' : '最大化'">
<svg v-if="!isMaximized" width="12" height="12" viewBox="0 0 12 12">
<rect x="1" y="1" width="10" height="10" fill="none" stroke="currentColor" stroke-width="1.5"/>
</svg>
<svg v-else width="12" height="12" viewBox="0 0 12 12">
<rect x="2" y="0" width="10" height="10" fill="none" stroke="currentColor" stroke-width="1.5"/>
<rect x="0" y="2" width="10" height="10" fill="none" stroke="currentColor" stroke-width="1.5"/>
</svg>
</div>
<div class="window-control-btn close-btn" @click="handleClose" title="关闭">
<svg width="12" height="12" viewBox="0 0 12 12">
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</div>
</div>
</div>
</div>
</a-layout-header>
@@ -108,16 +133,65 @@
</template>
<script setup>
import {onMounted, ref} from 'vue'
import {onMounted, ref, watch} from 'vue'
import {Message} from '@arco-design/web-vue'
import {
IconMinus,
IconFullscreen,
IconFullscreenExit,
IconClose,
IconSync
} from '@arco-design/web-vue/es/icon'
import DeviceTest from './components/DeviceTest.vue'
import DbCli from './views/db-cli/index.vue'
import ThemeToggle from './components/ThemeToggle.vue'
import UpdatePanel from './components/UpdatePanel.vue'
import FileSystem from './components/FileSystem.vue'
const activeTab = ref('db-cli')
// 存储键
const ACTIVE_TAB_STORAGE_KEY = 'app-active-tab'
// 从 localStorage 恢复上次打开的区域,默认为 'db-cli'
const activeTab = ref(localStorage.getItem(ACTIVE_TAB_STORAGE_KEY) || 'db-cli')
const showUpdateModal = ref(false)
const isMaximized = ref(false)
// 监听 activeTab 变化,自动保存到 localStorage
watch(activeTab, (newTab) => {
localStorage.setItem(ACTIVE_TAB_STORAGE_KEY, newTab)
})
// 窗口控制方法
const handleMinimize = async () => {
try {
if (window.go?.main?.App?.WindowMinimize) {
await window.go.main.App.WindowMinimize()
}
} catch (error) {
console.error('最小化窗口失败:', error)
}
}
const handleMaximize = async () => {
try {
if (window.go?.main?.App?.WindowMaximize) {
await window.go.main.App.WindowMaximize()
isMaximized.value = await window.go.main.App.WindowIsMaximized()
}
} catch (error) {
console.error('最大化窗口失败:', error)
}
}
const handleClose = async () => {
try {
if (window.go?.main?.App?.WindowClose) {
await window.go.main.App.WindowClose()
}
} catch (error) {
console.error('关闭窗口失败:', error)
}
}
const loading = ref(false)
const formModel = ref({
keyword: '',
@@ -219,6 +293,8 @@ onMounted(() => {
.header {
background: var(--color-bg-2);
border-bottom: 1px solid var(--color-border);
user-select: none;
--wails-draggable: drag; /* Wails 拖拽属性 */
}
.header-content {
@@ -229,6 +305,13 @@ onMounted(() => {
padding: 0 20px;
}
.header-left {
display: flex;
align-items: center;
min-width: 150px;
--wails-draggable: drag; /* 左侧标题区域可拖拽 */
}
.header-content h2 {
margin: 0;
font-size: 18px;
@@ -244,11 +327,49 @@ onMounted(() => {
.header-actions {
display: flex;
align-items: center;
gap: 8px;
margin-left: 20px;
min-width: 200px;
justify-content: flex-end;
--wails-draggable: no-drag; /* 按钮区域不响应拖拽 */
}
.window-controls {
display: flex;
align-items: center;
margin-left: 12px;
padding-left: 12px;
border-left: 1px solid var(--color-border);
}
.window-control-btn {
width: 40px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.15s;
color: var(--color-text-2);
--wails-draggable: no-drag; /* 窗口控制按钮不响应拖拽 */
}
.window-control-btn:hover {
background: var(--color-fill-2);
color: var(--color-text-1);
}
.window-control-btn.close-btn:hover {
background: #e81123;
color: #ffffff;
}
.window-control-btn svg {
display: block;
pointer-events: none;
}
.content {
padding: 20px;
flex: 1;
overflow: auto;
background: var(--color-bg-1);
@@ -262,3 +383,28 @@ onMounted(() => {
flex: 1;
}
</style>
<!-- Wails 拖拽样式 -->
<style>
.header {
--wails-draggable: drag;
}
/* 所有按钮类元素都不可拖拽 */
.header-actions,
.window-control-btn {
--wails-draggable: no-drag;
}
/* tabs 的具体 tab 项不可拖拽,但空白区域可以拖拽 */
.arco-tabs-tab {
--wails-draggable: no-drag;
}
/* Arco Design 按钮不可拖拽 */
.arco-btn,
.arco-select,
.arco-tooltip {
--wails-draggable: no-drag;
}
</style>