Browse Source

证书接口完成

main
lk 3 months ago
parent
commit
c41a6cbddc
  1. 9
      src/service/websites.ts
  2. 30
      src/store/websites/cert.ts
  3. 57
      vite.config.ts

9
src/service/websites.ts

@ -15,7 +15,7 @@ const websitesServ = {
getCertConfig: async () => {
return request.get<any, any>("/cert/apply/acme/key");
},
// 申请list
// 证书list
getCertList: async (params: any) => {
return request.post<any, any>("/cert/apply/list", params);
},
@ -33,15 +33,20 @@ const websitesServ = {
},
// 下载证书
downloadCertificate: async (params: any) => {
return request.post<any, any>("/cert/apply/download", params);
return request.get<any, any>("/cert/apply/download", params);
},
// 获取证书申请日志
getCertificateLogs: async (params: any) => {
return request.post<any, any>("/cert/log", params);
},
//申请证书
applyTxtCertificate: async (params: any) => {
return request.post<any, any>("/cert/apply/resolve", params);
},
//编辑证书
editCertificate: async (params: any) => {
return request.post<any, any>("/cert/apply/remark", params);
},
},
ssl: {
...createCURD<any, WebSite.ISSL>("/website/ssl"),

30
src/store/websites/cert.ts

@ -67,7 +67,11 @@ export type Req_DownloadCert = {
export type Req_DeletesCert = {
ids: number[];
};
//=========================更新证书
export interface Req_UpdateCert {
id: 0;
remark: string;
}
export const algorithmTypes = [
{ label: "RSA", value: "RSA" },
{ label: "ECC", value: "ECC" },
@ -196,13 +200,9 @@ export const getCertificateLogsAtom = (data: req_CertLogs) =>
};
});
export const downloadCertificateAtom = (
params: Req_DownloadCert,
enableFetchAtom: boolean
) => {
export const downloadCertificateAtom = (params: Req_DownloadCert, enableFetchAtom: boolean) => {
return atomWithQuery(() => ({
queryKey: ['downloadCertificate', params],
queryKey: ["downloadCertificate", params],
queryFn: async ({ queryKey: [, params] }) => {
return await websitesServ.cert.downloadCertificate(params);
},
@ -210,8 +210,6 @@ export const downloadCertificateAtom = (
}));
};
export const deletesCertificateAtom = (params: Req_DeletesCert) =>
atomWithQuery<IApiResult, any>(() => {
return {
@ -224,6 +222,20 @@ export const deletesCertificateAtom = (params: Req_DeletesCert) =>
},
};
});
export const editCertificateAtom = atomWithMutation<IApiResult, Req_UpdateCert>(() => {
// status 3:进行中,5:失败,9:成功
return {
mutationKey: ["editCertificate"],
mutationFn: async (data: Req_UpdateCert) => {
return await websitesServ.cert.editCertificate(data);
},
onSuccess: (res) => {
return res;
},
};
});
//==================================================================================================================================================kelis
// //certApple

57
vite.config.ts

@ -1,65 +1,66 @@
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { viteMockServe } from 'vite-plugin-mock'
import jotaiDebugLabel from 'jotai/babel/plugin-debug-label'
import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh'
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import { viteMockServe } from "vite-plugin-mock";
import jotaiDebugLabel from "jotai/babel/plugin-debug-label";
import jotaiReactRefresh from "jotai/babel/plugin-react-refresh";
//import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
export const downLoadUrl = "http://127.0.0.1:8000";
const proxyMap = {
'/api/v1/package': 'http://154.88.7.8:45321',
'/api/v1/movie': 'http://47.113.117.106:10000',
"/api/v1/package": "http://154.88.7.8:45321",
"/api/v1/movie": "http://47.113.117.106:10000",
//'/api/v1/certold': 'http://192.168.31.41:8000',
'/api/v1/cert': 'http://127.0.0.1:8000',
"/api/v1/cert": "http://127.0.0.1:8000",
//'/api/v1/cert': 'http://192.168.31.41:8000',
} as Record<any, string>
} as Record<any, string>;
const proxyConfig = Object.keys(proxyMap).reduce((acc, key) => {
const proxyConfig = Object.keys(proxyMap).reduce(
(acc, key) => {
acc[key] = {
target: proxyMap[key],
changeOrigin: true,
rewrite: (path: string) => path,
}
return acc
}, {} as Record<any, any>)
};
return acc;
},
{} as Record<any, any>,
);
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// 根据当前工作目录中的 `mode` 加载 .env 文件
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
// @ts-ignore fix process
const env = loadEnv(mode, process.cwd(), '')
const env = loadEnv(mode, process.cwd(), "");
// 你可以在这里打印出 env 变量来检查加载的内容
return {
//定义别名的路径
resolve: {
alias: {
'@': '/src',
"@": "/src",
},
},
server: {
cors: {
origin: '*'
origin: "*",
},
proxy: {
...proxyConfig,
'/api': {
"/api": {
target: env.API_URL,
changeOrigin: true,
rewrite: (path) => {
return path
}
}
return path;
},
},
},
},
plugins: [
react({
babel: {
presets: [ 'jotai/babel/preset' ],
plugins: [ jotaiDebugLabel, jotaiReactRefresh ]
presets: ["jotai/babel/preset"],
plugins: [jotaiDebugLabel, jotaiReactRefresh],
},
}),
viteMockServe({
@ -67,10 +68,10 @@ export default defineConfig(({ mode }) => {
enable: false,
// mock 文件的根路径,默认值:'mocks'
mockPath: 'mock',
mockPath: "mock",
logger: true,
}),
//TanStackRouterVite(),
],
}
})
};
});
Loading…
Cancel
Save