@@ -54,7 +54,7 @@ SimApiBusinessCallback // { [code]: (data) => void },支持数字码或 'co
5454- 改 Token 存储:替换 ` localStorage ` 为 ` sessionStorage ` 或内存变量,修改 ` getToken() ` /` setToken() ` /` removeToken() `
5555- 改登录/登出逻辑:修改 ` login() ` /` logout() ` 方法
5656- 改超时处理:修改 ` fetchWithTimeout() ` 函数
57- - 版本管理:版本号在库构建时通过 ` scripts/replace-version.js ` 注入,源码中使用占位符 ` 0.0.0-version-placeholder `
57+ - ** 版本管理** :版本号通过 ` declare const ` 声明常量,构建时通过 Vite 的 ` define ` 注入。未指定时默认为 ` 0.0.0-dev `
5858
5959** autoInit 设计约束** :
6060
@@ -104,11 +104,34 @@ npm run build
104104 → vite build vite.core.config.ts 输出 dist/index.mjs / index.cjs
105105 → vite build vite.pinia.config.ts 输出 dist/pinia.mjs
106106 → tsc -p tsconfig.build.json 输出 *.d.ts 类型声明
107+ ```
108+
109+ ** 版本号注入:**
110+
111+ 版本号通过 ` vite.core.config.ts ` 的 ` define ` 配置注入,从环境变量读取:
112+
113+ ``` typescript
114+ define : {
115+ ' AppVersion' : JSON .stringify (process .env .AppVersion || process .env .npm_config_AppVersion || ' 0.0.0-develop' ),
116+ ' SimApiVersion' : JSON .stringify (process .env .SimApiVersion || process .env .npm_config_SimApiVersion || ' 0.0.0-develop' ),
117+ }
118+ ```
119+
120+ ** 本地构建示例:**
121+ ``` bash
122+ # Windows PowerShell
123+ $env :AppVersion=" 1.0.0" ; $env :SimApiVersion=" 1.0.0" ; npm run build
124+
125+ # Linux/Mac
126+ AppVersion=1.0.0 SimApiVersion=1.0.0 npm run build
127+ ```
107128
108- npm run build:version
109- → node scripts/replace-version.js 替换版本占位符
110- → npm run build 构建
111- → node scripts/restore-version.js 恢复占位符
129+ ** GitHub Actions 自动发布:**
130+ ``` yaml
131+ env :
132+ AppVersion : ${{ github.ref_name }}
133+ SimApiVersion : ${{ github.ref_name }}
134+ run : npm run build
112135` ` `
113136
114137**dist 输出是平铺的**,core 和 pinia 的编译产物全部在同一目录:
@@ -142,4 +165,4 @@ dist/
142165- ** 无 Cookie** :所有请求不发送 Cookie,Token 通过请求头传递
143166- ** 零依赖** :不需要安装 axios,使用原生 fetch
144167- 删除了 Angular 支持,如需恢复参考 git 历史
145- - 版本号通过构建脚本注入,GitHub Actions 发布时会自动替换 ` 0.0.0-version-placeholder ` 占位符
168+ - ** 版本号管理 ** :使用 ` declare const ` + Vite ` define ` 注入,不再需要 sed 替换脚本
0 commit comments