fix: use site favicon in HiCAD

This commit is contained in:
134 2026-07-27 19:41:51 +08:00
parent 957192cc5c
commit c2bc6147c8
2 changed files with 48 additions and 0 deletions

View File

@ -30,6 +30,7 @@ const sourceRefFile = path.join(sourceDir, ".hicad-source-ref");
const outputDir = path.join(root, "public/vendor/zoo-modeling-app");
const customizationDir = path.join(root, "vendor/zoo-modeling-app");
const proxyToken = "hicad-session";
const brandedFaviconUrl = "/api/favicon?surface=hicad";
function run(command, args, options = {}) {
const result = spawnSync(command, args, {
@ -112,6 +113,22 @@ function replaceSource(relativePath, before, after) {
writeFileSync(filePath, source.replace(before, after));
}
function patchOfficialManifest() {
const manifestPath = path.join(sourceDir, "public/manifest.json");
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
manifest.short_name = "HiCAD";
manifest.name = "HiCAD";
manifest.icons = [
{
src: brandedFaviconUrl,
sizes: "any",
},
];
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
}
function patchOfficialSource() {
copyFileSync(
path.join(customizationDir, "Logo.tsx"),
@ -130,6 +147,17 @@ function patchOfficialSource() {
' <meta name="description" content="An open-source CAD modeling tool from the future by Zoo." />',
' <meta name="description" content="HiCAD browser-based CAD workspace." />'
);
replaceSource(
"index.html",
' <link rel="icon" href="/favicon.ico" />',
` <link rel="icon" href="${brandedFaviconUrl}" />`
);
replaceSource(
"index.html",
' <link rel="apple-touch-icon" href="/logo192.png" />',
` <link rel="apple-touch-icon" href="${brandedFaviconUrl}" />`
);
patchOfficialManifest();
replaceSource(
"index.html",
' <script defer data-domain="app.zoo.dev" src="https://plausible.corp.zoo.dev/js/script.tagged-events.js"></script>\n',

View File

@ -16,6 +16,26 @@ test.describe("HiCAD embedded startup", () => {
expect(vendorScript).toContain(latestReviewedOfficialCommit);
});
test("uses the website favicon across embedded browser surfaces", () => {
const vendorScript = fs.readFileSync(
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),
"utf8"
);
expect(vendorScript).toContain(
'const brandedFaviconUrl = "/api/favicon?surface=hicad"'
);
expect(vendorScript).toContain(
'` <link rel="icon" href="${brandedFaviconUrl}" />`'
);
expect(vendorScript).toContain(
'` <link rel="apple-touch-icon" href="${brandedFaviconUrl}" />`'
);
expect(vendorScript).toMatch(
/manifest\.icons = \[\s*\{\s*src: brandedFaviconUrl,\s*sizes: "any",/
);
});
test("suppresses the upstream onboarding chooser in embedded mode", () => {
const vendorScript = fs.readFileSync(
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),