From 7aa010c242d5c7b0bfb928f15e86ef04b2d88041 Mon Sep 17 00:00:00 2001 From: Chaos Date: Wed, 5 Nov 2025 17:20:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(app):=20=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E8=B7=AF=E7=94=B1=E4=B8=8E=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F-=20=E6=B7=BB=E5=8A=A0=20about=20=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=B9=B6=E5=AE=9E=E7=8E=B0=E9=A1=B5=E9=9D=A2=E9=97=B4?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=20-=20=E6=9B=B4=E6=96=B0=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=EF=BC=8C=E8=AE=BE=E7=BD=AE=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E8=89=B2=E4=B8=8E=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2=20-?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20Header=20=E7=BB=84=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E7=BE=8E=E5=8C=96=E7=AA=97=E5=8F=A3=E6=8E=A7=E5=88=B6=E6=8C=89?= =?UTF-8?q?=E9=92=AE=20-=20=E5=BC=95=E5=85=A5=E6=8C=81=E4=B9=85=E5=8C=96?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E5=B7=A5=E5=85=B7=E7=B1=BB=20-=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20Tauri=20=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=9E=84=E5=BB=BA=E8=B7=AF=E5=BE=84=E4=B8=8E=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=9C=80=E5=B0=8F=E5=B0=BA=E5=AF=B8-=20=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=20SVG=20=E5=9B=BE=E6=A0=87=E6=96=87=E4=BB=B6=E4=B8=BA?= =?UTF-8?q?=20sprite=20=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/tauri.conf.json | 6 +- src/app.css | 9 ++- src/lib/assets/icon/close.svg | 1 - src/lib/assets/icon/sprite.svg | 3 + src/lib/components/layout/Header.svelte | 86 ++++++++++++++++++------- src/lib/utils/persistedStroeUtil.ts | 23 +++++++ src/routes/+page.svelte | 14 ++-- src/routes/about/+page.svelte | 7 ++ 8 files changed, 113 insertions(+), 36 deletions(-) delete mode 100644 src/lib/assets/icon/close.svg create mode 100644 src/lib/assets/icon/sprite.svg create mode 100644 src/lib/utils/persistedStroeUtil.ts create mode 100644 src/routes/about/+page.svelte diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 9e28cff..84c7e7c 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -4,7 +4,7 @@ "version": "0.1.0", "identifier": "cn.nopj.ittools", "build": { - "frontendDist": "../src", + "frontendDist": "../build", "devUrl": "http://localhost:5173", "beforeDevCommand": "npm run dev", "beforeBuildCommand": "npm run build" @@ -17,7 +17,9 @@ "height": 600, "resizable": true, "fullscreen": false, - "decorations": false + "decorations": false, + "minWidth": 400 , + "minHeight": 300 } ], "security": { diff --git a/src/app.css b/src/app.css index 5a491d0..11b0f61 100644 --- a/src/app.css +++ b/src/app.css @@ -1,10 +1,9 @@ @import 'tailwindcss'; -:global(body) { - +body { background-color: #1f1f1f; /* 示例:一个深灰色 */ - min-height: 100vh; - min-width: 100vw; - margin: 0; /* 移除浏览器默认的 body 边距 */ + + margin: 0; + color: white; } \ No newline at end of file diff --git a/src/lib/assets/icon/close.svg b/src/lib/assets/icon/close.svg deleted file mode 100644 index 1128373..0000000 --- a/src/lib/assets/icon/close.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/lib/assets/icon/sprite.svg b/src/lib/assets/icon/sprite.svg new file mode 100644 index 0000000..ac6d7ec --- /dev/null +++ b/src/lib/assets/icon/sprite.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/lib/components/layout/Header.svelte b/src/lib/components/layout/Header.svelte index 502d151..204e479 100644 --- a/src/lib/components/layout/Header.svelte +++ b/src/lib/components/layout/Header.svelte @@ -1,48 +1,40 @@
- 🎉 我的Tauri Svelte应用 +
- - - + + +
diff --git a/src/lib/utils/persistedStroeUtil.ts b/src/lib/utils/persistedStroeUtil.ts new file mode 100644 index 0000000..02a65f0 --- /dev/null +++ b/src/lib/utils/persistedStroeUtil.ts @@ -0,0 +1,23 @@ +import {writable,type Writable} from 'svelte/store'; + +export function persistedStore (key: string, initialValue: T): Writable { + let storedValue: T; + try { + const json = localStorage.getItem(key); + storedValue = json ? JSON.parse(json) : initialValue; + } catch (e) { + console.warn(`读取 localStorage key = ${key} 失败`, e); + storedValue = initialValue; + } + const store = writable(storedValue); + + store.subscribe(value => { + try { + localStorage.setItem(key, JSON.stringify(value)); + } catch (e) { + console.warn(`写入 localStorage key=${key} 失败`, e); + } + }); + + return store; +} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 7fa16b9..c08f1ea 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,12 +1,16 @@ -
-

112323{title}

-

{description}

+
+ +
    + +
  • goto('/about')}>关于
  • +
\ No newline at end of file diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte new file mode 100644 index 0000000..e721cd4 --- /dev/null +++ b/src/routes/about/+page.svelte @@ -0,0 +1,7 @@ + + +
    +
  • goto('/')}>首页
  • +
\ No newline at end of file