- init unibest v4.4.0 base template - tabbar: 4 tabs (打卡/进度/测算/持仓) with carbon icons - pages/checkin: daily checklist, streak counter, monthly rate - pages/progress: asset snapshot, progress bar to 71万 target - pages/calculator, holdings: placeholder pages (stage 2) - store/checkin.ts + store/progress.ts with pinia persist - vite: host 0.0.0.0 for WSL2→Windows browser access Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
959 B
JavaScript
38 lines
959 B
JavaScript
/**
|
|
* @description 通过 vite 自定义条件动态导入 eruda
|
|
* @description Eruda 配置参考 https://eruda.liriliri.io/zh/docs/
|
|
* @param {object} options
|
|
* @param {boolean} [options.open] - 是否开启 eruda
|
|
* @param {object} [options.erudaOptions] - eruda 配置
|
|
* @param {string} [options.erudaUrl] - eruda 地址
|
|
*/
|
|
export default function vitePluginEruda(options = {}) {
|
|
const { open = true, erudaOptions = {}, erudaUrl = 'https://cdn.jsdelivr.net/npm/eruda' } = options
|
|
|
|
return {
|
|
name: 'vite-plugin-eruda',
|
|
|
|
transformIndexHtml(html) {
|
|
const tags = [
|
|
{
|
|
tag: 'script',
|
|
attrs: {
|
|
src: erudaUrl,
|
|
},
|
|
injectTo: 'head',
|
|
},
|
|
{
|
|
tag: 'script',
|
|
children: `eruda.init(${JSON.stringify(erudaOptions)});`,
|
|
injectTo: 'head',
|
|
},
|
|
]
|
|
|
|
if (!open) {
|
|
return html
|
|
}
|
|
return { html, tags }
|
|
},
|
|
}
|
|
}
|