diff --git a/package.json b/package.json index c0500b7..1aa8821 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/query-config", - "version": "0.0.1", + "version": "0.0.2", "description": "", "main": "dist/query-config.js", "types": "dist/query-config.d.ts", diff --git a/src/query-config.ts b/src/query-config.ts index 70933ef..7cde057 100644 --- a/src/query-config.ts +++ b/src/query-config.ts @@ -16,6 +16,9 @@ export type UploadConfig = { key?: string; version?: string; }; +type PostOpts = { + token?: string; +}; export class QueryConfig { query: Query; constructor(opts?: QueryConfigOpts) { @@ -24,39 +27,43 @@ export class QueryConfig { async post(data: any) { return this.query.post({ path: 'config', ...data }); } - async getConfig({ id, key }: { id?: string; key?: string }) { + async getConfig({ id, key }: { id?: string; key?: string }, opts?: PostOpts) { return this.post({ key: 'get', data: { id, key, }, + ...opts, }); } - async updateConfig(data: Config) { + async updateConfig(data: Config, opts?: PostOpts) { return this.post({ key: 'update', data, + ...opts, }); } - async deleteConfig(id: string) { + async deleteConfig(id: string, opts?: PostOpts) { return this.post({ key: 'delete', data: { id }, }); } - async listConfig() { + async listConfig(opts?: PostOpts) { return this.post<{ list: Config[] }>({ key: 'list', + ...opts, }); } /** * 获取上传配置 * @returns */ - async getUploadConfig() { + async getUploadConfig(opts?: PostOpts) { return this.post>>({ key: 'getUploadConfig', + ...opts, }); } /** @@ -64,10 +71,11 @@ export class QueryConfig { * @param data * @returns */ - async updateUploadConfig(data: Config) { + async updateUploadConfig(data: Config, opts?: PostOpts) { return this.post>>({ key: 'updateUploadConfig', data, + ...opts, }); } @@ -76,15 +84,22 @@ export class QueryConfig { * @param id * @returns */ - async detectConfig() { + async detectConfig(opts?: PostOpts) { return this.post<{ updateList: Config[] }>({ key: 'detect', + ...opts, }); } - async getConfigByKey(key: string) { + /** + * 获取配置, 获取默认的配置项 + * @param key + * @returns + */ + async getConfigByKey(key: string, opts?: PostOpts) { return this.post>({ key: 'defaultConfig', configKey: key, + ...opts, }); } }