mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
refactor: notify/footer 持久配置收编到 config/,chrome bridge 地址固定
仓库规则要求 config/ 为唯一配置来源、不以环境变量作持久默认值: - pi-notify 改读 config/pi-notify.json(逐字段校验回退,复用原 parsers 钳制) - pi-minimal-footer 改读 config/pi-minimal-footer.json - pi-chrome 移除 PI_CHROME_BRIDGE_HOST/PORT,固定 127.0.0.1:17318 (浏览器端 service_worker.js 硬编码同一地址,单侧可配只会断连) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
0c45b1a438
commit
e996f59469
@@ -0,0 +1,30 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export interface FooterSettings {
|
||||
showCwd: boolean;
|
||||
showBranch: boolean;
|
||||
}
|
||||
|
||||
// Bundle-level `config/` is the single source of truth: the extension reads
|
||||
// `config/pi-minimal-footer.json` from inside the installed bundle (resolved
|
||||
// relative to this source file), never environment variables.
|
||||
export const FOOTER_CONFIG_PATH = fileURLToPath(
|
||||
new URL("../config/pi-minimal-footer.json", import.meta.url),
|
||||
);
|
||||
|
||||
export function readFooterSettings(configPath: string = FOOTER_CONFIG_PATH): FooterSettings {
|
||||
try {
|
||||
const parsed = JSON.parse(readFileSync(configPath, "utf8")) as unknown;
|
||||
const raw =
|
||||
parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)
|
||||
? (parsed as Record<string, unknown>)
|
||||
: {};
|
||||
return {
|
||||
showCwd: typeof raw.showCwd === "boolean" ? raw.showCwd : true,
|
||||
showBranch: typeof raw.showBranch === "boolean" ? raw.showBranch : true,
|
||||
};
|
||||
} catch {
|
||||
return { showCwd: true, showBranch: true };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user