fix ci
Publish to npm / publish (push) Failing after 29s
Publish to npm / publish (push) Failing after 29s
This commit is contained in:
+8
-1
@@ -54,10 +54,11 @@ SimApiBusinessCallback // { [code]: (data) => void },支持数字码或 'co
|
||||
- 改 Token 存储:替换 `localStorage` 为 `sessionStorage` 或内存变量,修改 `getToken()`/`setToken()`/`removeToken()`
|
||||
- 改登录/登出逻辑:修改 `login()`/`logout()` 方法
|
||||
- 改超时处理:修改 `fetchWithTimeout()` 函数
|
||||
- 版本管理:版本号在库构建时通过 `scripts/replace-version.js` 注入,源码中使用占位符 `0.0.0-version-placeholder`
|
||||
|
||||
**autoInit 设计约束**:
|
||||
|
||||
- 仅读取 `window.simapi` 的三个顶级字段:`endpoints`、`defaultEndpoint`、`debug`
|
||||
- 仅读取 `window.simapi` 的顶级字段:`endpoints`、`defaultEndpoint`、`debug`、`uiAppVersion`
|
||||
- 业务回调(`businessCallback`/`responseCallback`)不支持从 window 读取,必须在代码中通过 `setBusinessCallback` 注册
|
||||
|
||||
---
|
||||
@@ -103,6 +104,11 @@ npm run build
|
||||
→ vite build vite.core.config.ts 输出 dist/index.mjs / index.cjs
|
||||
→ vite build vite.pinia.config.ts 输出 dist/pinia.mjs
|
||||
→ tsc -p tsconfig.build.json 输出 *.d.ts 类型声明
|
||||
|
||||
npm run build:version
|
||||
→ node scripts/replace-version.js 替换版本占位符
|
||||
→ npm run build 构建
|
||||
→ node scripts/restore-version.js 恢复占位符
|
||||
```
|
||||
|
||||
**dist 输出是平铺的**,core 和 pinia 的编译产物全部在同一目录:
|
||||
@@ -136,3 +142,4 @@ dist/
|
||||
- **无 Cookie**:所有请求不发送 Cookie,Token 通过请求头传递
|
||||
- **零依赖**:不需要安装 axios,使用原生 fetch
|
||||
- 删除了 Angular 支持,如需恢复参考 git 历史
|
||||
- 版本号通过构建脚本注入,GitHub Actions 发布时会自动替换 `0.0.0-version-placeholder` 占位符
|
||||
|
||||
@@ -105,7 +105,7 @@ await api.query('/stats', {}, 'admin')
|
||||
|
||||
## autoInit — 从 window 读取配置
|
||||
|
||||
仅支持三个字段:`endpoints`、`defaultEndpoint`、`debug`。业务回调需在代码中通过 `setBusinessCallback` 处理。
|
||||
支持字段:`endpoints`、`defaultEndpoint`、`debug`、`uiAppVersion`。业务回调需在代码中通过 `setBusinessCallback` 处理。
|
||||
|
||||
```html
|
||||
<script>
|
||||
@@ -153,6 +153,9 @@ interface SimApiOptions {
|
||||
/** 调试模式,默认 true */
|
||||
debug?: boolean
|
||||
|
||||
/** UI 应用版本,如果不指定则使用库内置的版本号 */
|
||||
uiAppVersion?: string
|
||||
|
||||
/** 认证相关配置 */
|
||||
auth?: Partial<SimApiAuthConfig>
|
||||
|
||||
@@ -305,21 +308,21 @@ api.configure({
|
||||
| 方法/属性 | 说明 |
|
||||
|-----------|------|
|
||||
| `configure(options)` | 批量配置(深合并) |
|
||||
| `autoInit()` | 从 `window.simapi` 读取配置(endpoints、defaultEndpoint、debug) |
|
||||
| `setEndpoints(map)` | 设置端点,自动触发版本检查 |
|
||||
| `autoInit()` | 从 `window.simapi` 读取配置(endpoints、defaultEndpoint、debug、uiAppVersion) |
|
||||
| `setEndpoints(map)` | 设置端点 |
|
||||
| `setBusinessCallback(code, fn)` | 注册业务错误码回调 |
|
||||
| `setDebug(debug)` | 设置调试模式 |
|
||||
| `query(uri, params?, endpointKey?, headers?)` | POST 请求,返回 `Promise<SimApiBaseResponse<T>>` |
|
||||
| `login(request)` | 登录,自动存 Token |
|
||||
| `logout(url?)` | 登出,清除 Token |
|
||||
| `checkLogin(url?)` | 主动检查登录状态 |
|
||||
| `getVersion(endpointName?)` | 获取版本信息,返回 `Promise<SimApiVersions>` |
|
||||
| `getToken()` | 获取 Token |
|
||||
| `setToken(token)` | 手动设置 Token |
|
||||
| `removeToken()` | 清除 Token |
|
||||
| `isLoggedIn` | getter,是否已登录 |
|
||||
| `token` | getter,获取当前 Token |
|
||||
| `debug` | boolean,调试模式 |
|
||||
| `versions` | 版本信息对象 |
|
||||
| `uiAppVersion` | UI 应用版本号(可选配置) |
|
||||
| `logDebug(...args)` | 日志工具(仅在 debug 模式输出) |
|
||||
|
||||
## 构建
|
||||
|
||||
|
||||
+1
-4
@@ -12,14 +12,11 @@
|
||||
"simapi",
|
||||
"vue3",
|
||||
"pinia",
|
||||
"rxjs",
|
||||
"http",
|
||||
"fetch"
|
||||
],
|
||||
"files": [
|
||||
"dist",
|
||||
"simapi.core.ts",
|
||||
"simapi.pinia.ts",
|
||||
"README.md",
|
||||
"package.json"
|
||||
],
|
||||
@@ -41,6 +38,7 @@
|
||||
"build": "npm run build:core && npm run build:pinia && npm run types",
|
||||
"build:core": "vite build --config vite.core.config.ts",
|
||||
"build:pinia": "vite build --config vite.pinia.config.ts",
|
||||
"build:version": "node scripts/replace-version.js && npm run build && node scripts/restore-version.js",
|
||||
"dev": "vite build --config vite.core.config.ts --watch",
|
||||
"types": "tsc --declaration --emitDeclarationOnly --project tsconfig.build.json",
|
||||
"lint": "tsc --noEmit"
|
||||
@@ -49,7 +47,6 @@
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.0",
|
||||
"pinia": "^2.2.0",
|
||||
"typescript": "~5.9.3",
|
||||
"vite": "^5.0.0",
|
||||
|
||||
Reference in New Issue
Block a user