refactor: 收口公共AppBar组件

This commit is contained in:
czz
2026-05-09 15:55:05 +08:00
parent f3eb25b035
commit b7fa2fce9d
25 changed files with 497 additions and 242 deletions

View File

@@ -0,0 +1,40 @@
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const appBarSource = fs.readFileSync(
path.join(__dirname, "../../src/components/app-bar/index.tsx"),
"utf8"
);
const appBarStyles = fs.readFileSync(
path.join(__dirname, "../../src/components/app-bar/index.scss"),
"utf8"
);
function run(name, fn) {
try {
fn();
console.log(`PASS ${name}`);
} catch (error) {
console.error(`FAIL ${name}`);
throw error;
}
}
run("AppBar back action uses the shared back.svg asset", () => {
assert.match(appBarSource, /back\.svg/);
assert.match(appBarSource, /<Image[\s\S]*className="app-bar__back-icon"/);
});
run("AppBar back action no longer renders a text arrow", () => {
assert.doesNotMatch(appBarSource, /&lt;|>\s*<\s*</);
});
run("AppBar back icon uses a fixed mini-program sized constraint", () => {
assert.match(appBarStyles, /\.app-bar__back-icon\s*\{[\s\S]*width:\s*32rpx;/);
assert.match(appBarStyles, /\.app-bar__back-icon\s*\{[\s\S]*height:\s*32rpx;/);
});
run("AppBar props stay focused on title and back navigation only", () => {
assert.doesNotMatch(appBarSource, /subtitle\?:|eyebrow\?:|align\?:|rightText\?:|onRightAction\?:|leftSlot\?:|rightSlot\?:|bottomSlot\?:/);
});