搜索结果列表页面开发
This commit is contained in:
53
src/api/settings/index.ts
Normal file
53
src/api/settings/index.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { reqCatchV2, type catchRt } from '@/utils/catch';
|
||||
import request from '@/utils/request';
|
||||
import type { userCreateSSHKeyReqType, generalSearchReqType, getUserSSHKeyResType, sshKeyid } from './types';
|
||||
import Mock from 'mockjs';
|
||||
|
||||
// 获取镜像信息
|
||||
export function getMirrorData(params: any): Promise<any> {
|
||||
return Promise.resolve([(Mock.mock({
|
||||
'isOpen': false,
|
||||
'dataList': [
|
||||
{
|
||||
type: 0,
|
||||
add: 'http:6',
|
||||
success: 1,
|
||||
time: 2
|
||||
},
|
||||
{
|
||||
type: 1,
|
||||
add: 'http:fdsjoijfsdoijdfsiojfsdiojoidsfoijfdsijo',
|
||||
success: 0,
|
||||
time: 2
|
||||
}]
|
||||
}))
|
||||
]);
|
||||
}
|
||||
|
||||
// 创建用户SSHKey
|
||||
export function createUserSSH(sshKey: userCreateSSHKeyReqType): catchRt<any> {
|
||||
const reqForm = new FormData();
|
||||
reqForm.append('key', sshKey.keyValue);
|
||||
reqForm.append('title', sshKey.keyName);
|
||||
return reqCatchV2(() => request({
|
||||
url: `/api/v1/user/keys`,
|
||||
method: 'post',
|
||||
data: reqForm
|
||||
}, { customError: true }));
|
||||
}
|
||||
// 查询用户SSHKey列表
|
||||
export function getUserSSHList(searchParams: generalSearchReqType): catchRt<getUserSSHKeyResType[]> {
|
||||
return reqCatchV2(() => request({
|
||||
url: `/api/v1/user/keys`,
|
||||
method: 'get',
|
||||
params: searchParams
|
||||
}));
|
||||
}
|
||||
// 删除用户SSHKey
|
||||
export function deleteSSHKey(key_id:sshKeyid, title:string): catchRt<any> {
|
||||
return reqCatchV2(() => request({
|
||||
url: `/api/v1/user/keys/${key_id}`,
|
||||
method: 'delete',
|
||||
params: { title: title }
|
||||
}));
|
||||
}
|
||||
51
src/api/settings/types.ts
Normal file
51
src/api/settings/types.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { SSHData } from '@/components/SecretKeyItem/types';
|
||||
export interface ITransSSHKey {
|
||||
keyName: string;
|
||||
keyValue: string;
|
||||
writable: boolean;
|
||||
}
|
||||
// 用户创建SSHKey请求参数
|
||||
export interface userCreateSSHKeyReqType {
|
||||
keyName: string;
|
||||
keyValue: string;
|
||||
permissions: string;
|
||||
expireTime: string;
|
||||
}
|
||||
// 通用列表查询参数
|
||||
export interface generalSearchReqType {
|
||||
page: number;
|
||||
per_page: number;
|
||||
search: string;
|
||||
}
|
||||
// 用户SSHKey接口返回
|
||||
export interface getUserSSHKeyResType {
|
||||
id: string | number;
|
||||
key: string;
|
||||
title: string;
|
||||
created_at: string;
|
||||
}
|
||||
export type sshKeyid = SSHData['id'];
|
||||
export interface Log {
|
||||
type: string;
|
||||
operator: string;
|
||||
logInfo: string;
|
||||
createdTime: string;
|
||||
}
|
||||
|
||||
export interface LogFilter {
|
||||
type?: string;
|
||||
operator?: string;
|
||||
logInfo?: string;
|
||||
range?: [Date | '', Date | ''];
|
||||
}
|
||||
|
||||
export interface LogSource {
|
||||
(pageSize: number, pageIndex: number, logFilter: LogFilter): Promise<Log[]>
|
||||
}
|
||||
|
||||
export interface UserRepo {
|
||||
organization: string;
|
||||
repoName: string;
|
||||
repoSize: string;
|
||||
isMine: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user