mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-08 07:41:10 +08:00
【修复】调整下载的方法
This commit is contained in:
@@ -12,8 +12,6 @@ import type {
|
||||
GetCaListResponse,
|
||||
DeleteCaParams,
|
||||
DeleteCaResponse,
|
||||
DownloadCaCertParams,
|
||||
DownloadCaCertResponse,
|
||||
CreateLeafCertParams,
|
||||
CreateLeafCertResponse,
|
||||
GetLeafCertListParams,
|
||||
@@ -22,8 +20,7 @@ import type {
|
||||
DeleteLeafCertResponse,
|
||||
} from '@/types/ca'
|
||||
|
||||
import { useApi, createApiToken } from "@api/index";
|
||||
import { isDev } from '@baota/utils/browser';
|
||||
import { useApi } from "@api/index";
|
||||
|
||||
/**
|
||||
* @description 创建根证书
|
||||
@@ -57,31 +54,6 @@ export const getCaList = (params?: GetCaListParams): useAxiosReturn<GetCaListRes
|
||||
export const deleteCa = (params?: DeleteCaParams): useAxiosReturn<DeleteCaResponse, DeleteCaParams> =>
|
||||
useApi<DeleteCaResponse, DeleteCaParams>('/v1/private_ca/del_ca', params)
|
||||
|
||||
/**
|
||||
* @description 获取下载CA证书的URL
|
||||
* @param {DownloadCaCertParams} [params] 请求参数
|
||||
* @returns {string} 拼接好的下载URL
|
||||
*/
|
||||
export const downloadCaCert = (params?: DownloadCaCertParams): string => {
|
||||
const apiParams = createApiToken()
|
||||
const finalParams = isDev() ? { ...(params || {}), ...apiParams } : params || {}
|
||||
|
||||
// 构建查询字符串
|
||||
const searchParams = new URLSearchParams()
|
||||
if (finalParams) {
|
||||
Object.entries(finalParams).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null) {
|
||||
searchParams.append(key, String(value))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const queryString = searchParams.toString()
|
||||
const baseUrl = isDev() ? '/api' : '/'
|
||||
const fullUrl = queryString ? `${baseUrl}/v1/private_ca/download_cert?${queryString}` : `${baseUrl}/v1/private_ca/download_cert`
|
||||
return fullUrl
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建叶子证书
|
||||
* @param {CreateLeafCertParams} [params] 请求参数
|
||||
|
||||
@@ -115,28 +115,4 @@ export const getVersion = (
|
||||
useApi<GetVersionResponse, GetVersionParams>(
|
||||
"/v1/setting/get_version",
|
||||
params
|
||||
);
|
||||
|
||||
/**
|
||||
* @description 获取下载数据的URL
|
||||
* @returns {string} 拼接好的下载URL
|
||||
*/
|
||||
export const downloadData = (): string => {
|
||||
const apiParams = createApiToken();
|
||||
const finalParams = isDev() ? { ...apiParams } : {};
|
||||
const searchParams = new URLSearchParams();
|
||||
if (finalParams) {
|
||||
Object.entries(finalParams).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null) {
|
||||
searchParams.append(key, String(value));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const queryString = searchParams.toString();
|
||||
const baseUrl = isDev() ? "/api" : "/";
|
||||
const fullUrl = queryString
|
||||
? `${baseUrl}/v1/setting/download_data?${queryString}`
|
||||
: `${baseUrl}/v1/setting/download_data`;
|
||||
return fullUrl;
|
||||
};
|
||||
);
|
||||
@@ -87,7 +87,7 @@ export default defineComponent({
|
||||
</div>
|
||||
<div class={styles.flowContainer}>
|
||||
{/* 左侧流程容器 */}
|
||||
<div class="flex min-w-0" >
|
||||
<div class="flex min-w-0">
|
||||
{/* 流程容器*/}
|
||||
<div
|
||||
class={styles.flowProcess}
|
||||
@@ -98,24 +98,24 @@ export default defineComponent({
|
||||
{/* 流程结束节点 */}
|
||||
<EndNode />
|
||||
</div>
|
||||
{/* 缩放控制区 */}
|
||||
<div class={styles.flowZoom}>
|
||||
<div class={styles.flowZoomIcon} onClick={() => handleZoom(1)}>
|
||||
<SvgIcon
|
||||
icon="subtract"
|
||||
class={`${flowZoom.value === 50 ? styles.disabled : ""}`}
|
||||
color="#5a5e66"
|
||||
/>
|
||||
</div>
|
||||
<span>{flowZoom.value}%</span>
|
||||
<div class={styles.flowZoomIcon} onClick={() => handleZoom(2)}>
|
||||
<SvgIcon
|
||||
icon="plus"
|
||||
class={`${flowZoom.value === 300 ? styles.disabled : ""}`}
|
||||
color="#5a5e66"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 缩放控制区 */}
|
||||
<div class={styles.flowZoom}>
|
||||
<div class={styles.flowZoomIcon} onClick={() => handleZoom(1)}>
|
||||
<SvgIcon
|
||||
icon="subtract"
|
||||
class={`${flowZoom.value === 50 ? styles.disabled : ""}`}
|
||||
color="#5a5e66"
|
||||
/>
|
||||
</div>
|
||||
<span>{flowZoom.value}%</span>
|
||||
<div class={styles.flowZoomIcon} onClick={() => handleZoom(2)}>
|
||||
<SvgIcon
|
||||
icon="plus"
|
||||
class={`${flowZoom.value === 300 ? styles.disabled : ""}`}
|
||||
color="#5a5e66"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/* 保留原有插槽 */}
|
||||
|
||||
21
frontend/apps/allin-ssl/src/types/ca.d.ts
vendored
21
frontend/apps/allin-ssl/src/types/ca.d.ts
vendored
@@ -155,27 +155,6 @@ export interface DeleteCaResponse {
|
||||
status: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载CA证书请求参数
|
||||
*/
|
||||
export interface DownloadCaCertParams {
|
||||
/** CA ID */
|
||||
id: string;
|
||||
/** 下载类型:ca-证书,key-私钥 */
|
||||
type: 'ca' | 'leaf';
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载CA证书响应数据
|
||||
*/
|
||||
export interface DownloadCaCertResponse {
|
||||
code: number;
|
||||
message: string;
|
||||
status: boolean;
|
||||
/** 下载文件数据 */
|
||||
data: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建叶子证书请求参数
|
||||
*/
|
||||
|
||||
@@ -23,8 +23,8 @@ import type {
|
||||
KeyLengthOption,
|
||||
ValidityUnit
|
||||
} from './types';
|
||||
import { createLeafCert, deleteLeafCert, downloadCaCert } from '@/api/ca';
|
||||
import type { CreateLeafCertParams, DeleteLeafCertParams, DownloadCaCertParams } from '@/types/ca';
|
||||
import { createLeafCert, deleteLeafCert } from '@/api/ca';
|
||||
import type { CreateLeafCertParams, DeleteLeafCertParams } from '@/types/ca';
|
||||
import type { GetLeafCertListParams } from '@/types/ca';
|
||||
|
||||
const { handleError } = useError();
|
||||
@@ -261,11 +261,10 @@ export const useController = () => {
|
||||
// 下载证书
|
||||
const handleDownload = (cert: CertItem) => {
|
||||
try {
|
||||
const downloadUrl = downloadCaCert({
|
||||
id: cert.id.toString(),
|
||||
type: "leaf",
|
||||
} as DownloadCaCertParams);
|
||||
window.open(downloadUrl, "_blank");
|
||||
const link = document.createElement("a");
|
||||
link.href = `/v1/private_ca/download_cert?id=${cert.id.toString()}&type=leaf`;
|
||||
link.target = "_blank";
|
||||
link.click();
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { useError } from "@baota/hooks/error";
|
||||
import { useStore } from './useStore';
|
||||
import type { PrivateCaItem } from './types';
|
||||
import { getCaList, downloadCaCert, deleteCa as deleteCaApi, createRootCa, createIntermediateCa } from '@/api/ca';
|
||||
import { getCaList, deleteCa as deleteCaApi, createRootCa, createIntermediateCa } from '@/api/ca';
|
||||
import type { GetCaListParams } from '@/types/ca';
|
||||
import { onMounted } from 'vue';
|
||||
import AddCaModal from './components/AddCaModal';
|
||||
@@ -292,9 +292,10 @@ export const useController = () => {
|
||||
*/
|
||||
const handleDownload = (row: PrivateCaItem) => {
|
||||
try {
|
||||
const downloadUrl = downloadCaCert({ id: row.id.toString(), type: 'ca' });
|
||||
console.log('download_url', downloadUrl);
|
||||
window.open(downloadUrl, '_blank');
|
||||
const link = document.createElement("a");
|
||||
link.href = `/v1/private_ca/download_cert?id=${row.id.toString()}&type=ca`;
|
||||
link.target = "_blank";
|
||||
link.click();
|
||||
} catch (error: any) {
|
||||
handleError(error);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import { clearCookie, clearSession } from "@baota/utils/browser";
|
||||
import { useError } from "@baota/hooks/error";
|
||||
import { $t } from "@locales/index";
|
||||
import { useStore } from "./useStore";
|
||||
import { downloadData } from "@/api/setting";
|
||||
|
||||
import EmailChannelModel from "./components/channel/EmailChannelModel";
|
||||
import FeishuChannelModel from "./components/channel/FeishuChannelModel";
|
||||
@@ -131,13 +130,14 @@ export const useController = () => {
|
||||
*/
|
||||
const handleDownloadData = async () => {
|
||||
try {
|
||||
const url = await downloadData();
|
||||
window.open(url, "_blank");
|
||||
const link = document.createElement("a");
|
||||
link.href = "/v1/setting/download_data";
|
||||
link.target = "_blank";
|
||||
link.click();
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开添加邮箱通知渠道弹窗
|
||||
* @function openAddEmailChannelModal
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
deleteReport,
|
||||
addReport,
|
||||
testReport,
|
||||
downloadData,
|
||||
} from '@/api/setting'
|
||||
import type {
|
||||
SaveSettingParams,
|
||||
|
||||
Reference in New Issue
Block a user