Skip to content

Commit d01a623

Browse files
committed
feat(shell): set window size and reset html
1 parent 02032cf commit d01a623

4 files changed

Lines changed: 77 additions & 4 deletions

File tree

‎app/index.html‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
<!doctype html>
2-
<html lang="en">
2+
<html lang="zh-CN">
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Tauri + React + Typescript</title>
7+
<title>熵减 · 本地知识提取</title>
8+
<!-- J1-2:body 的 UA 8px margin + 无高度基准 ⇒ 整窗常驻纵向滚动条/底缘白条。
9+
reset 放 index.html 而不是 tokens.css:tokens.css 是生成物(改它会被 drift 测试判失败),
10+
而 reset 是**文档结构**约定,不是设计 token。 -->
11+
<style>
12+
html, body, #root { margin: 0; height: 100%; }
13+
/* 规格 §1 决策 17:细滚动条 6px(审计 J1-2「6px 细滚动条规格全站未实现」) */
14+
* { scrollbar-width: thin; }
15+
::-webkit-scrollbar { width: 6px; height: 6px; }
16+
::-webkit-scrollbar-thumb { background: #c9c4b8; border-radius: 3px; }
17+
::-webkit-scrollbar-track { background: transparent; }
18+
</style>
819
</head>
920

1021
<body>

‎app/src-tauri/tauri.conf.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
"windows": [
1414
{
1515
"title": "熵减 · 本地知识提取",
16-
"width": 960,
17-
"height": 720
16+
"width": 1280,
17+
"height": 800,
18+
"minWidth": 1024,
19+
"minHeight": 640,
20+
"resizable": true
1821
}
1922
],
2023
"security": {

‎app/src/shell/windowSize.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @ai-context 主窗尺寸守卫:`tauri.conf.json` 与 `windowSize.ts` 必须逐字一致。
3+
*
4+
* Why 读 JSON 而不是信任常量:真值在 JSON 里,常量是**影子**。只有把两者钉在一起,
5+
* 「改了 JSON 忘了常量」才是红的(反之亦然)。规格 §1 决策 17 的两个数字是本测试的断言对象。
6+
*
7+
* 口径:只断言四个数字与存在性;**不**断言 JSON 里的其它字段(批 4/8 会动它们)。
8+
*/
9+
import { readFileSync } from "node:fs";
10+
import { dirname, join } from "node:path";
11+
import { fileURLToPath } from "node:url";
12+
import { describe, expect, it } from "vitest";
13+
import { NAV_MIN_WIDTH, WINDOW_SIZE } from "./windowSize";
14+
15+
const APP = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
16+
const CONF = join(APP, "src-tauri", "tauri.conf.json");
17+
18+
describe("主窗尺寸(规格 §1 决策 17)", () => {
19+
const conf = JSON.parse(readFileSync(CONF, "utf8"));
20+
const win = conf.app.windows[0];
21+
22+
it("默认 1280×800", () => {
23+
expect(win.width).toBe(WINDOW_SIZE.defaultWidth);
24+
expect(win.height).toBe(WINDOW_SIZE.defaultHeight);
25+
});
26+
27+
it("最小 1024×640(J1-1:今天完全没有 min 尺寸)", () => {
28+
expect(win.minWidth).toBe(WINDOW_SIZE.minWidth);
29+
expect(win.minHeight).toBe(WINDOW_SIZE.minHeight);
30+
});
31+
32+
it("窗口可缩放(否则 min 尺寸无意义)", () => {
33+
expect(win.resizable ?? true).toBe(true);
34+
});
35+
36+
it("断点下限 = 最小窗宽(防止两处各写一个 1024)", () => {
37+
expect(NAV_MIN_WIDTH).toBe(1024);
38+
expect(NAV_MIN_WIDTH).toBe(win.minWidth);
39+
});
40+
});

‎app/src/shell/windowSize.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @ai-context 主窗尺寸的**单一真源**(规格 §1 决策 17:默认 1280×800,最小 1024×640)。
3+
*
4+
* Why 要有这个 TS 常量:真值在 `app/src-tauri/tauri.conf.json`(JSON,TS 读不到也不该读),
5+
* 而前端有三处需要同一组数字 —— ① 断点下限(T5 的 1024 档)② 验收测试(T14 量「1024 无溢出」)
6+
* ③ 守卫测试(读 JSON 逐字比对,防止有人只改一边)。
7+
* 没有它,「1024」会在前端再散落成第 8 处魔数 —— 正是本批要消灭的东西。
8+
*
9+
* 副作用:无。边界:只描述**主窗**;采集浮窗由 Rust 侧建(360×240,resizable=false),不在本文件表达。
10+
*/
11+
export const WINDOW_SIZE = {
12+
defaultWidth: 1280,
13+
defaultHeight: 800,
14+
minWidth: 1024,
15+
minHeight: 640,
16+
} as const;
17+
18+
/** 顶栏溢出策略的下限(= 最小窗宽);规格 §6.1「<1024 由最小窗兜底」 */
19+
export const NAV_MIN_WIDTH = WINDOW_SIZE.minWidth;

0 commit comments

Comments
 (0)