feat: change query-config

This commit is contained in:
xion 2025-04-03 15:35:50 +08:00
parent 20688920b8
commit 862b29cfa4
2 changed files with 24 additions and 9 deletions

View File

@ -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",

View File

@ -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,
});
}
}