feat: change query-config
This commit is contained in:
parent
20688920b8
commit
862b29cfa4
@ -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",
|
||||
|
@ -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<T = Config>(data: any) {
|
||||
return this.query.post<T>({ 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<Result<Config<UploadConfig>>>({
|
||||
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<Result<Config<UploadConfig>>>({
|
||||
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<Result<Config>>({
|
||||
key: 'defaultConfig',
|
||||
configKey: key,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user