2024-06-18 00:35:45 +08:00
|
|
|
import axios from 'axios';
|
2025-01-07 00:08:33 +08:00
|
|
|
import { dateFormat } from '@/utils';
|
2024-06-18 00:35:45 +08:00
|
|
|
|
2024-10-10 18:32:40 +08:00
|
|
|
/**
|
|
|
|
|
* 系统配置类型
|
|
|
|
|
*/
|
|
|
|
|
export type SystemSettingType = 'SFTP';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 系统设置更新请求
|
|
|
|
|
*/
|
|
|
|
|
export interface SystemSettingUpdateRequest {
|
|
|
|
|
type?: SystemSettingType;
|
|
|
|
|
item?: string;
|
|
|
|
|
value?: any;
|
|
|
|
|
settings?: Record<string, any>;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 18:26:26 +08:00
|
|
|
/**
|
|
|
|
|
* 应用信息查询响应
|
|
|
|
|
*/
|
|
|
|
|
export interface SystemLicenseResponse {
|
|
|
|
|
userCount: number;
|
|
|
|
|
hostCount: number;
|
|
|
|
|
release: string;
|
|
|
|
|
releaseName: string;
|
|
|
|
|
issueDate: number;
|
|
|
|
|
expireDate: number;
|
|
|
|
|
expireDay: number;
|
|
|
|
|
uuid: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 00:35:45 +08:00
|
|
|
/**
|
|
|
|
|
* 应用信息查询响应
|
|
|
|
|
*/
|
|
|
|
|
export interface AppInfoResponse {
|
|
|
|
|
version: string;
|
|
|
|
|
uuid: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-08-29 18:26:26 +08:00
|
|
|
* 应用最新版本信息
|
2024-06-18 00:35:45 +08:00
|
|
|
*/
|
2024-08-29 18:26:26 +08:00
|
|
|
export interface AppReleaseResponse {
|
|
|
|
|
tagName: string;
|
2024-06-18 00:35:45 +08:00
|
|
|
body: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 18:26:26 +08:00
|
|
|
/**
|
2024-10-10 18:32:40 +08:00
|
|
|
* SFTP 配置
|
2024-08-29 18:26:26 +08:00
|
|
|
*/
|
2024-10-10 18:32:40 +08:00
|
|
|
export interface SftpSetting {
|
|
|
|
|
previewSize: number;
|
2024-08-29 18:26:26 +08:00
|
|
|
}
|
|
|
|
|
|
2024-06-18 00:35:45 +08:00
|
|
|
/**
|
|
|
|
|
* 查询应用信息
|
|
|
|
|
*/
|
|
|
|
|
export function getSystemAppInfo() {
|
|
|
|
|
return axios.get<AppInfoResponse>('/infra/system-setting/app-info');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-08-29 18:26:26 +08:00
|
|
|
* 获取应用最新版本信息
|
2024-06-18 00:35:45 +08:00
|
|
|
*/
|
2024-08-29 18:26:26 +08:00
|
|
|
export function getAppLatestRelease() {
|
2025-01-07 00:08:33 +08:00
|
|
|
return axios.get<AppReleaseResponse>(`https://visor.orionsec.cn/releases-latest.json?${dateFormat(new Date(), 'yyyyMMddHH')}`, {
|
2024-06-18 00:35:45 +08:00
|
|
|
// 不添加请求头 否则会报 401
|
|
|
|
|
setAuthorization: false,
|
|
|
|
|
// 返回原始输出
|
|
|
|
|
unwrap: true,
|
|
|
|
|
// 不提示请求错误信息 可能会 403
|
|
|
|
|
promptRequestErrorMessage: false,
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-10-10 18:32:40 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新系统设置
|
|
|
|
|
*/
|
|
|
|
|
export function updateSystemSetting(request: SystemSettingUpdateRequest) {
|
|
|
|
|
return axios.put<number>('/infra/system-setting/update', request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新部分系统设置
|
|
|
|
|
*/
|
|
|
|
|
export function updatePartialSystemSetting(request: SystemSettingUpdateRequest) {
|
|
|
|
|
return axios.put<number>('/infra/system-setting/update-partial', request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询系统设置
|
|
|
|
|
*/
|
|
|
|
|
export function getSystemSetting<T>(type: SystemSettingType) {
|
|
|
|
|
return axios.get<T>('/infra/system-setting/setting', { params: { type } });
|
|
|
|
|
}
|