| 1234567891011121314151617 |
- /**
- * config.js —— 全站唯一「部署基址」变量。
- * <base href>、importmap 前缀、renderBase、路由 base 都由这里派生(规则:三处同源)。
- * 部署到 OBS 子目录时只改这一处(改成带结尾斜杠的前缀,如 '../hardware-lab/')。
- */
- export const APP_BASE = './';
- /** 从当前文档的 <base href> 得到绝对基址(末尾带 /) */
- export function docBase() {
- const b = (typeof document !== 'undefined' && document.baseURI) || '';
- return b.endsWith('/') ? b : b + '/';
- }
- /** 应用内路径 → 可 ESM import 的模块 URL(相对基址,绝不丢部署前缀) */
- export function moduleUrl(path) {
- return new URL(path.replace(/^\.?\//, ''), docBase()).href;
- }
|