mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 12:03:20 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
38
desktop/tools/generate-icon.cjs
Normal file
38
desktop/tools/generate-icon.cjs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const { Resvg } = require("@resvg/resvg-js");
|
||||
const pngToIcoModule = require("png-to-ico");
|
||||
const pngToIco = typeof pngToIcoModule === "function" ? pngToIcoModule : pngToIcoModule.default;
|
||||
|
||||
async function main() {
|
||||
const desktopRoot = path.resolve(__dirname, "..");
|
||||
const svgPath = path.resolve(desktopRoot, "..", "src", "admin", "static", "oliver.svg");
|
||||
const assetsDir = path.join(desktopRoot, "assets");
|
||||
const icoPath = path.join(assetsDir, "oclaw.ico");
|
||||
|
||||
if (!fs.existsSync(svgPath)) {
|
||||
throw new Error(`logo not found: ${svgPath}`);
|
||||
}
|
||||
fs.mkdirSync(assetsDir, { recursive: true });
|
||||
const svg = fs.readFileSync(svgPath, "utf8");
|
||||
|
||||
const sizes = [16, 24, 32, 48, 64, 128, 256];
|
||||
const pngBuffers = [];
|
||||
for (const size of sizes) {
|
||||
const resvg = new Resvg(svg, {
|
||||
fitTo: { mode: "width", value: size },
|
||||
background: "rgba(0,0,0,0)",
|
||||
});
|
||||
const pngData = resvg.render().asPng();
|
||||
pngBuffers.push(Buffer.from(pngData));
|
||||
}
|
||||
|
||||
const ico = await pngToIco(pngBuffers);
|
||||
fs.writeFileSync(icoPath, ico);
|
||||
process.stdout.write(`Generated ${icoPath}\n`);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
process.stderr.write(`${String(err && err.message ? err.message : err)}\n`);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue