feat: 接入托盘 / 添加图标生成工具 / 重命名并完善前端

- 托盘:用 getlantern/systray 重写 internal/tray,支持显示/隐藏窗口与退出
- 图标:新增 pkg/icongen 工具,支持 png/jpg/gif/bmp/webp,输出 ico/png 多个尺寸
- 重命名:项目默认名改为「青梧映星」,wails.json/productname/companyname/copyright 同步更新
- 顶栏:新增顶部导航栏(主题切换、设置、用户),iconfont 自托管 fa-solid-900.woff2
- 主题:CSS 变量 + html[data-theme] 控制白昼/黑夜切换,同时调用 WindowSetDarkTheme/LightTheme
- 底部:版权栏包含工作室、开发者与点击跳转客服链接
- 打包:wails build + exe 版本更新至 1.20 MB
This commit is contained in:
2026-09-18 01:30:13 +08:00
parent d8789e9034
commit a2a1161f10
19 changed files with 755 additions and 259 deletions

View File

@@ -50,7 +50,6 @@
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.29.7",
"@babel/generator": "^7.29.7",
@@ -1226,7 +1225,6 @@
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"csstype": "^3.2.2"
}
@@ -1295,7 +1293,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.11.23",
"caniuse-lite": "^1.0.30001810",
@@ -1557,7 +1554,6 @@
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@@ -1599,7 +1595,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz",
"integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
@@ -1766,7 +1761,6 @@
"integrity": "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"esbuild": "^0.27.0 || ^0.28.0",
"fdir": "^6.5.0",

View File

@@ -1 +1 @@
ebabc2ea396231dd6d5148053c60fb95
30c0aca688848662b14455d10c0b255b

View File

@@ -1,34 +1,198 @@
@font-face {
font-family: 'iconfont';
src: url('./assets/fonts/fa/fa-solid-900.woff2') format('woff2');
font-weight: 900;
font-style: normal;
font-display: block;
}
:root {
--bg-page: #f0f2f5;
--bg-surface: #ffffff;
--bg-header: #ffffff;
--bg-input: #ffffff;
--bg-th: #fafafa;
--bg-btn-secondary: #f5f5f5;
--bg-btn-secondary-hover: #e8e8e8;
--border: #e5e5e5;
--border-input: #d9d9d9;
--border-cell: #f0f0f0;
--text-title: #1a1a2e;
--text-body: #333333;
--text-secondary: #666666;
--text-muted: #888888;
--text-faint: #999999;
--text-th: #555555;
--placeholder: #999999;
--accent: #1677ff;
--accent-hover: #4096ff;
--accent-soft: rgba(22, 119, 255, 0.1);
--shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
--toast-bg: rgba(26, 26, 46, 0.9);
--toast-color: #ffffff;
}
html[data-theme='dark'] {
--bg-page: #12151f;
--bg-surface: #1c2230;
--bg-header: #1c2230;
--bg-input: #12151f;
--bg-th: #171c28;
--bg-btn-secondary: #262d3d;
--bg-btn-secondary-hover: #38435a;
--border: #262d3d;
--border-input: #2e3648;
--border-cell: #262d3d;
--text-title: #e6e9f0;
--text-body: #d0d5e0;
--text-secondary: #8a93a6;
--text-muted: #8a93a6;
--text-faint: #6b7488;
--text-th: #a6aebd;
--placeholder: #6b7488;
--accent: #1677ff;
--accent-hover: #66a3ff;
--accent-soft: rgba(22, 119, 255, 0.18);
--shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
--toast-bg: rgba(230, 233, 240, 0.95);
--toast-color: #1c2230;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
background: var(--bg-page);
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #f0f2f5;
color: #333;
color: var(--text-body);
}
.icon {
font-family: 'iconfont' !important;
font-style: normal;
font-weight: 900;
line-height: 1;
font-size: 16px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-sun::before {
content: '\f185';
}
.icon-moon::before {
content: '\f186';
}
.icon-gear::before {
content: '\f013';
}
.icon-user::before {
content: '\f007';
}
.app {
min-height: 100vh;
display: flex;
flex-direction: column;
color: var(--text-body);
}
.topbar {
position: sticky;
top: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: flex-end;
height: 44px;
padding: 0 16px;
background: var(--bg-header);
border-bottom: 1px solid var(--border);
}
.topbar-actions {
display: flex;
align-items: center;
gap: 6px;
}
.icon-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: none;
border-radius: 8px;
background: transparent;
color: var(--text-secondary);
cursor: pointer;
transition: background 0.2s, color 0.2s;
}
.icon-btn:hover {
background: var(--accent-soft);
color: var(--accent);
}
.app-content {
max-width: 900px;
width: 100%;
flex: 1;
margin: 0 auto;
padding: 24px;
padding: 16px 24px 24px;
}
.footer {
display: flex;
justify-content: center;
align-items: center;
gap: 12px;
padding: 12px 16px;
border-top: 1px solid var(--border);
background: var(--bg-surface);
color: var(--text-muted);
font-size: 13px;
}
.footer-sep {
color: var(--border-input);
}
.footer-link {
color: var(--accent);
cursor: pointer;
text-decoration: none;
}
.footer-link:hover {
color: var(--accent-hover);
}
.header {
text-align: center;
margin-bottom: 32px;
margin-bottom: 16px;
}
.header h1 {
font-size: 28px;
color: #1a1a2e;
font-size: 22px;
color: var(--text-title);
}
.header p {
color: #666;
margin-top: 4px;
color: var(--text-secondary);
margin-top: 2px;
font-size: 13px;
}
.main {
@@ -38,16 +202,16 @@ body {
}
.card {
background: #fff;
background: var(--bg-surface);
border-radius: 12px;
padding: 24px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
box-shadow: var(--shadow);
}
.card h2 {
font-size: 18px;
margin-bottom: 16px;
color: #1a1a2e;
color: var(--text-title);
}
.card-header {
@@ -65,19 +229,25 @@ body {
.input {
flex: 1;
padding: 8px 12px;
border: 1px solid #d9d9d9;
border: 1px solid var(--border-input);
border-radius: 6px;
font-size: 14px;
background: var(--bg-input);
color: var(--text-body);
}
.input::placeholder {
color: var(--placeholder);
}
.input:focus {
outline: none;
border-color: #1677ff;
border-color: var(--accent);
}
.btn-primary {
padding: 8px 20px;
background: #1677ff;
background: var(--accent);
color: #fff;
border: none;
border-radius: 6px;
@@ -86,20 +256,21 @@ body {
}
.btn-primary:hover {
background: #4096ff;
background: var(--accent-hover);
}
.btn-secondary {
padding: 6px 14px;
background: #f5f5f5;
border: 1px solid #d9d9d9;
background: var(--bg-btn-secondary);
border: 1px solid var(--border-input);
border-radius: 6px;
cursor: pointer;
font-size: 13px;
color: var(--text-body);
}
.btn-secondary:hover {
background: #e8e8e8;
background: var(--bg-btn-secondary-hover);
}
.message {
@@ -116,19 +287,45 @@ body {
.table th,
.table td {
padding: 10px 12px;
border-bottom: 1px solid #f0f0f0;
border-bottom: 1px solid var(--border-cell);
text-align: left;
font-size: 14px;
}
.table th {
background: #fafafa;
background: var(--bg-th);
font-weight: 600;
color: #555;
color: var(--text-th);
}
.empty {
text-align: center;
color: #999;
color: var(--text-faint);
padding: 24px;
}
.toast {
position: fixed;
left: 50%;
bottom: 72px;
transform: translateX(-50%);
z-index: 100;
padding: 10px 18px;
border-radius: 8px;
font-size: 13px;
background: var(--toast-bg);
color: var(--toast-color);
box-shadow: var(--shadow);
animation: toast-in 0.2s ease;
}
@keyframes toast-in {
from {
opacity: 0;
transform: translateX(-50%) translateY(8px);
}
to {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
}

View File

@@ -1,9 +1,14 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import './App.css';
import {
GetUserList,
CreateUser,
} from '../wailsjs/go/main/App';
import {
BrowserOpenURL,
WindowSetDarkTheme,
WindowSetLightTheme,
} from '../wailsjs/runtime/runtime';
interface User {
id: number;
@@ -12,11 +17,44 @@ interface User {
created_at: string;
}
type Theme = 'light' | 'dark';
function getInitialTheme(): Theme {
const saved = localStorage.getItem('theme');
if (saved === 'light' || saved === 'dark') {
return saved;
}
return window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light';
}
function App() {
const [users, setUsers] = useState<User[]>([]);
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [message, setMessage] = useState('');
const [theme, setTheme] = useState<Theme>(getInitialTheme);
const [toast, setToast] = useState('');
useEffect(() => {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('theme', theme);
if (theme === 'dark') {
WindowSetDarkTheme();
} else {
WindowSetLightTheme();
}
}, [theme]);
const toggleTheme = () => {
setTheme((t) => (t === 'dark' ? 'light' : 'dark'));
};
const showToast = (text: string) => {
setToast(text);
window.setTimeout(() => setToast(''), 2200);
};
const loadUsers = async () => {
const result = await GetUserList();
@@ -41,67 +79,114 @@ function App() {
return (
<div className="app">
<header className="header">
<h1>Wails + React + Go</h1>
<p>Windows 桌面应用框架示例</p>
</header>
<nav className="topbar">
<div className="topbar-actions">
<button
className="icon-btn"
title={theme === 'dark' ? '切换到白天' : '切换到黑夜'}
onClick={toggleTheme}
>
<i className={`icon ${theme === 'dark' ? 'icon-sun' : 'icon-moon'}`} />
</button>
<button
className="icon-btn"
title="设置"
onClick={() => showToast('设置功能开发中…')}
>
<i className="icon icon-gear" />
</button>
<button
className="icon-btn"
title="用户"
onClick={() => showToast('用户中心开发中…')}
>
<i className="icon icon-user" />
</button>
</div>
</nav>
<main className="main">
<section className="card">
<h2>创建用户</h2>
<div className="form-row">
<input
className="input"
placeholder="名称"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<input
className="input"
placeholder="邮箱"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<button className="btn-primary" onClick={handleCreate}>
创建
</button>
</div>
{message && <p className="message">{message}</p>}
</section>
<div className="app-content">
<header className="header">
<h1>青梧映星</h1>
<p>Windows 桌面应用框架示例</p>
</header>
<section className="card">
<div className="card-header">
<h2>用户列表</h2>
<button className="btn-secondary" onClick={loadUsers}>
刷新
</button>
</div>
{users.length === 0 ? (
<p className="empty">暂无数据</p>
) : (
<table className="table">
<thead>
<tr>
<th>ID</th>
<th>名称</th>
<th>邮箱</th>
<th>创建时间</th>
</tr>
</thead>
<tbody>
{users.map((u) => (
<tr key={u.id}>
<td>{u.id}</td>
<td>{u.name}</td>
<td>{u.email}</td>
<td>{u.created_at}</td>
<main className="main">
<section className="card">
<h2>创建用户</h2>
<div className="form-row">
<input
className="input"
placeholder="名称"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<input
className="input"
placeholder="邮箱"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<button className="btn-primary" onClick={handleCreate}>
创建
</button>
</div>
{message && <p className="message">{message}</p>}
</section>
<section className="card">
<div className="card-header">
<h2>用户列表</h2>
<button className="btn-secondary" onClick={loadUsers}>
刷新
</button>
</div>
{users.length === 0 ? (
<p className="empty">暂无数据</p>
) : (
<table className="table">
<thead>
<tr>
<th>ID</th>
<th>名称</th>
<th>邮箱</th>
<th>创建时间</th>
</tr>
))}
</tbody>
</table>
)}
</section>
</main>
</thead>
<tbody>
{users.map((u) => (
<tr key={u.id}>
<td>{u.id}</td>
<td>{u.name}</td>
<td>{u.email}</td>
<td>{u.created_at}</td>
</tr>
))}
</tbody>
</table>
)}
</section>
</main>
</div>
<footer className="footer">
<span>青梧映星软件开发工作室</span>
<span className="footer-sep">|</span>
<span>开发者: Geliebte</span>
<span className="footer-sep">|</span>
<a
className="footer-link"
href="https://yser.ging.plus/"
onClick={(e) => {
e.preventDefault();
BrowserOpenURL('https://yser.ging.plus/');
}}
>
客户服务中心
</a>
</footer>
{toast && <div className="toast">{toast}</div>}
</div>
);
}

Binary file not shown.