Files
NoticeFront/plugins/vite-plugin-theme/lib/index.d.ts
T
chenxing 21a0bd36b6
build / build (push) Successful in 2m34s
fix(ci): vendor @yunhai/vite-plugin-theme 进仓,修 CI npm ci 解析不到 file:../../YschTheme
- CI 只 clone NoticeFront,file:../../YschTheme/packages/vite-plugin 在容器里不存在 → npm ci 秒失败(run#13)。
- 改为仓内 plugins/vite-plugin-theme(拷构建产物,dist→lib 规避 .gitignore 的 dist 规则;剥离 devDeps 防嵌套安装)。
- package.json 消费改 file:./plugins/vite-plugin-theme,重生成 lock(已清 extraneous 孤儿)。
- 本地 npm run build 通过。待 Nexus npm 仓就绪后再迁回版本号消费(方案 B)。
2026-09-24 12:22:09 +08:00

45 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Plugin } from 'vite';
/**
* @yunhai/vite-plugin-theme — 云海管理端远程主题接入插件。
*
* 接入面收敛成一行:plugins: [vue(), yhTheme()]。插件负责四件事:
* 1. transformIndexHtml:<head> 内注入 yh-theme-init.js(在 env-config bootstrap 之后)+ 首帧兜底 inline style;
* 刻意不静态注入 preload——构建期 URL 没有 ?v=,与 loader 运行时版本化 URL 永不匹配(缓存键含 query)。
* 2. virtual:yh-theme-loader:入口末位运行时 append <link>,保证远程 CSS 排在 viewuiplus.css 之后(dev/build 同构)。
* 3. transform:自动在入口末位 import 该虚拟模块,应用侧不用手改 main.ts。
* 4. /static dev proxy:本地联调不必装内网 DNS;环境变量 YH_THEME_PROXY_TARGET 可指向模拟通道。
*/
interface YhThemeOptions {
/** 产物档:pc 为第一波实现,app 占位 */
target?: "pc" | "app";
/** 静态通道前缀:'' 同源根相对(默认)| '/xxx' | 'http(s)://…'。禁止传 vite base(如 './') */
staticBase?: string;
/** dev /static proxy 目标;环境变量 YH_THEME_PROXY_TARGET 优先 */
proxyTarget?: string;
/** 入口匹配(相对路径正则),默认 src/main.(ts|js) */
entry?: RegExp;
}
declare const DEFAULT_PROXY_TARGET = "http://base.yunhaixingtong.com";
declare const VIRTUAL_ID = "virtual:yh-theme-loader";
declare const RESOLVED_VIRTUAL_ID = "\0virtual:yh-theme-loader";
declare const MANIFEST = "manifest.json";
declare const FALLBACK_STYLE = "html:not(.yh-theme-ready) body { opacity: 0; }\nhtml.yh-theme-ready body { opacity: 1; transition: opacity .15s; }";
/** staticBase 只接受根相对绝对前缀或完整 URL:vite base(Notice 是 './')会让 /static 解析成 /notice/front/static/… */
declare function isValidStaticBase(v: string): boolean;
/**
* loader 运行时实现 —— 基准为《第一波实施清单》§B3 代码块,语义一字不改。
* 复用 init 已启动的 manifest 预取;URL 与 init 的带版本 preload 一字不差;500ms 兜底;失败挂双类。
*/
declare function loaderSource(staticBase: string): string;
/**
* init 用 document.write 挂:直接写 <script src="/static/…"> 会让 vite:build-html 把这条绝对路径
* 当本仓资源解析(构建报 "Failed to resolve"),而远程通道的文件根本不在应用构建图里。
* document.write 在 <head> 内是 parser-blocking 的,恰好保住 init 必须先于首帧执行的语义。
*/
declare function initBootstrap(staticBase: string): string;
declare function yhTheme(options?: YhThemeOptions): Plugin;
export { DEFAULT_PROXY_TARGET, FALLBACK_STYLE, MANIFEST, RESOLVED_VIRTUAL_ID, VIRTUAL_ID, type YhThemeOptions, yhTheme as default, initBootstrap, isValidStaticBase, loaderSource, yhTheme };