zentao-api 0.6.7 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -236,13 +236,20 @@ const config = await client.getZentaoConfig(); // 复用有效缓存,缺失或
236
236
  const freshConfig = await client.getZentaoConfig({ forceRefresh: true });
237
237
  ```
238
238
 
239
+ `getZentaoConfig()` 只需站点地址,无需登录或 profile;未提供 Token 或 Token 已过期时都可调用。请求不发送 API Token,浏览器中还会显式省略 Cookie 等凭据,因此可以在登录前查询版本:
240
+
241
+ ```ts
242
+ const siteClient = new ZentaoClient('https://zentao.example.com');
243
+ const { version } = await siteClient.getZentaoConfig();
244
+ ```
245
+
239
246
  强制刷新不会改写全局 `version`。未指定全局版本时,使用不超过 24 小时的缓存;缓存缺失、过期或时间异常时访问站点根地址的 `/?mode=getconfig`。登录验证成功后也会强制获取一次,即使已设置全局版本。
240
247
 
241
248
  配置获取失败默认停止调用;可以通过全局或单次 `skipVersionCheckOnConfigError: true` 跳过本次检查。该选项不忽略版本不匹配、版本格式错误、取消或 profile 存储错误。版本不匹配抛出 `E_UNSUPPORTED_ZENTAO_VERSION`。
242
249
 
243
250
  ### 持久化 Profile
244
251
 
245
- Profile 默认不会写入。先启用 `persistProfiles`,登录成功后才会保存站点、账号、token、客户端配置,以及 `serverConfig` 和获取时间 `serverConfigFetchedAt`:
252
+ `login()` 默认不会自动写入 Profile。先启用 `persistProfiles`,登录成功后才会保存站点、账号、token、客户端配置,以及 `serverConfig` 和获取时间 `serverConfigFetchedAt`:
246
253
 
247
254
  ```ts
248
255
  import { ZentaoClient, setGlobalOptions } from 'zentao-api';
@@ -266,6 +273,11 @@ setGlobalOptions({ client });
266
273
  const another = await ZentaoClient.fromProfile(
267
274
  'admin@https://zentao.example.com',
268
275
  );
276
+
277
+ // 只读取并恢复,不切换当前 Profile、不更新使用时间、不写存储。
278
+ const isolated = await ZentaoClient.fromProfile(
279
+ 'admin@https://zentao.example.com', { activate: false },
280
+ );
269
281
  ```
270
282
 
271
283
  | 环境 | 存储位置 |