feat(app): 初始化应用路由与基础样式- 添加 about 页面并实现页面间导航
- 更新全局样式,设置背景色与文字颜色 -优化 Header 组件,美化窗口控制按钮 - 引入持久化存储工具类 - 调整 Tauri 配置,设置构建路径与窗口最小尺寸- 替换 SVG 图标文件为 sprite 形式
This commit is contained in:
@@ -1,48 +1,40 @@
|
||||
<script lang="ts">
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import {onMount} from 'svelte';
|
||||
|
||||
|
||||
const win = getCurrentWindow();
|
||||
|
||||
let isMax = false;
|
||||
|
||||
|
||||
const minimize = () => win.minimize();
|
||||
const closeWindow = () => win.close();
|
||||
const maximize = () => win.toggleMaximize();
|
||||
|
||||
|
||||
onMount(async () => {
|
||||
// 1. 获取初始状态
|
||||
isMax = await win.isMaximized();
|
||||
|
||||
// 2. 使用 onResized 更稳定(而不是 tauri://resize)
|
||||
const unlisten = await win.onResized(async () => {
|
||||
isMax = await win.isMaximized();
|
||||
});
|
||||
|
||||
// 3. 返回清理函数
|
||||
return () => unlisten();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<header class="custom-titlebar" data-tauri-drag-region>
|
||||
<div class="app-title" data-tauri-drag-region>
|
||||
🎉 我的Tauri Svelte应用
|
||||
|
||||
</div>
|
||||
|
||||
<div class="window-controls">
|
||||
<button data-tauri-drag-region="false" class="h-btn" on:click={minimize}>最小化</button>
|
||||
<button data-tauri-drag-region="false" class="h-btn" on:click={maximize}>{ isMax?'取消最大化':'最大化'}</button>
|
||||
<button data-tauri-drag-region="false" class="h-btn btn-close" on:click={closeWindow}>关闭</button>
|
||||
<button type="button" aria-label="最小化窗口" data-tauri-drag-region="false" class="h-btn btn-minimize" on:click={minimize}></button>
|
||||
<button
|
||||
type="button"
|
||||
data-tauri-drag-region="false"
|
||||
class="h-btn btn-max"
|
||||
aria-label="最大化窗口"
|
||||
on:click={maximize}></button>
|
||||
<button type="button"
|
||||
data-tauri-drag-region="false"
|
||||
class="h-btn btn-close"
|
||||
aria-label="关闭窗口"
|
||||
on:click={closeWindow}></button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<style>
|
||||
.custom-titlebar {
|
||||
height: 30px;
|
||||
background-color: #333;
|
||||
background-color: #1f1f1f;
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -54,6 +46,54 @@
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.window-controls {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.window-controls button {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
/* 🟡 最小化按钮 */
|
||||
.window-controls button.btn-minimize {
|
||||
background-color: #febc2e;
|
||||
}
|
||||
.window-controls button.btn-minimize:hover {
|
||||
background-color: #ffca45;
|
||||
box-shadow: 0 0 4px #ffca45;
|
||||
}
|
||||
.window-controls button.btn-minimize:active {
|
||||
background-color: #d9a323;
|
||||
}
|
||||
|
||||
/* 🔴 关闭按钮 */
|
||||
.window-controls button.btn-close {
|
||||
background-color: #ff5f57;
|
||||
}
|
||||
.window-controls button.btn-close:hover {
|
||||
background-color: #ff7b73;
|
||||
box-shadow: 0 0 4px #ff7b73;
|
||||
}
|
||||
.window-controls button.btn-close:active {
|
||||
background-color: #e0463c;
|
||||
}
|
||||
|
||||
/* 🟢 最大化按钮(未最大化状态) */
|
||||
.window-controls button.btn-max {
|
||||
background-color: #28c940;
|
||||
}
|
||||
.window-controls button.btn-max:hover {
|
||||
background-color: #34d058;
|
||||
box-shadow: 0 0 4px #34d058;
|
||||
}
|
||||
.window-controls button.btn-max:active {
|
||||
background-color: #1fae39;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user