搜索结果列表页面开发
This commit is contained in:
47
src/api/labels/index.ts
Normal file
47
src/api/labels/index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import request from '@/utils/request';
|
||||
import { reqCatch } from '@/utils/catch';
|
||||
|
||||
import type { ProjectLabelsReqType, LabelsReqType } from './types';
|
||||
|
||||
const defaultPages = {
|
||||
page: 1,
|
||||
per_page: 10
|
||||
};
|
||||
|
||||
/** 获取项目labels */
|
||||
export function getProLabels(params: ProjectLabelsReqType): Promise<any> {
|
||||
const { project_id, ...conf } = params;
|
||||
return reqCatch(() => request({
|
||||
url: `/api/v1/projects/${project_id}/labels`,
|
||||
params: Object.assign({ ...defaultPages }, conf)
|
||||
}), params);
|
||||
}
|
||||
|
||||
/** 新增项目label */
|
||||
export function createProjectLabels(data: LabelsReqType) {
|
||||
const { project_id, ...conf } = data;
|
||||
return reqCatch(() => request({
|
||||
url: `/api/v1/projects/${project_id}/labels`,
|
||||
data: Object.assign({ ...conf }),
|
||||
method: 'post'
|
||||
}), data);
|
||||
}
|
||||
|
||||
/** 编辑项目标签 */
|
||||
export function editProjectLabels(data: LabelsReqType & { new_name: string }) {
|
||||
const { project_id, ...conf } = data;
|
||||
return reqCatch(() => request({
|
||||
url: `/api/v1/projects/${project_id}/labels`,
|
||||
data: conf,
|
||||
method: 'put'
|
||||
}), data);
|
||||
}
|
||||
|
||||
/** 删除标签 */
|
||||
export function deleteProjectLabels(data: { project_id: string, name: string }) {
|
||||
const { project_id, name } = data;
|
||||
return reqCatch(() => request({
|
||||
url: `/api/v1/projects/${project_id}/labels?name=${name}`,
|
||||
method: 'delete'
|
||||
}));
|
||||
}
|
||||
19
src/api/labels/types.ts
Normal file
19
src/api/labels/types.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export interface ProjectLabelsReqType {
|
||||
project_id: string;
|
||||
search?: string
|
||||
sort?: 'asc' | 'desc'
|
||||
include_expired?: boolean
|
||||
most_active_ones?: boolean
|
||||
view?: 'simple' | 'basic' | 'detail'
|
||||
page?: number
|
||||
per_page?: number
|
||||
}
|
||||
|
||||
export interface LabelsReqType {
|
||||
project_id: string;
|
||||
name: string
|
||||
color: string
|
||||
description: string
|
||||
priority?: number // 优先级
|
||||
expires_at?: string // 过期时间
|
||||
}
|
||||
Reference in New Issue
Block a user