🏗️ refactor ServerService and index.vue to enhance HTTPS to HTTP handling and improve local file selection process
This commit is contained in:
parent
50adc33aef
commit
2238afa420
@ -67,6 +67,10 @@ class ServerService extends BaseService<OpenSourceFrpcDesktopServer> {
|
||||
return proxy.status === 1;
|
||||
}
|
||||
|
||||
private isHttps2http(proxy: FrpcProxy) {
|
||||
return proxy.https2http;
|
||||
}
|
||||
|
||||
async genTomlConfig(outputPath: string) {
|
||||
if (!outputPath) {
|
||||
return;
|
||||
@ -107,6 +111,24 @@ remotePort = {{ $v.Second }}
|
||||
remotePort: remotePort
|
||||
};
|
||||
} else if (proxy.type === "http" || proxy.type === "https") {
|
||||
if (this.isHttps2http(proxy) && proxy.type === "https") {
|
||||
return {
|
||||
name: proxy.name,
|
||||
type: proxy.type,
|
||||
customDomains: proxy.customDomains,
|
||||
subdomain: proxy.subdomain,
|
||||
...(proxy.https2http
|
||||
? {
|
||||
plugin: {
|
||||
type: "https2http",
|
||||
localAddr: `${proxy.localIP}:${proxy.localPort}`,
|
||||
crtPath: proxy.https2httpCaFile,
|
||||
keyPath: proxy.https2httpKeyFile
|
||||
}
|
||||
}
|
||||
: {})
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
name: proxy.name,
|
||||
type: proxy.type,
|
||||
@ -118,6 +140,7 @@ remotePort = {{ $v.Second }}
|
||||
? { httpUser: proxy.httpUser, httpPassword: proxy.httpPassword }
|
||||
: {})
|
||||
};
|
||||
}
|
||||
} else if (
|
||||
proxy.type === "stcp" ||
|
||||
proxy.type === "xtcp" ||
|
||||
|
@ -9,7 +9,6 @@ import {
|
||||
} from "vue";
|
||||
import Breadcrumb from "@/layout/compoenets/Breadcrumb.vue";
|
||||
import { ElMessage, FormInstance, FormRules } from "element-plus";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { useClipboard, useDebounceFn } from "@vueuse/core";
|
||||
import IconifyIconOffline from "@/components/IconifyIcon/src/iconifyIconOffline";
|
||||
import commonIps from "./commonIp.json";
|
||||
@ -83,6 +82,7 @@ const editForm = ref<FrpcProxy>(_.cloneDeep(defaultForm));
|
||||
* 代理类型
|
||||
*/
|
||||
const proxyTypes = ref(["http", "https", "tcp", "udp", "stcp", "xtcp", "sudp"]);
|
||||
const currSelectLocalFileType = ref();
|
||||
|
||||
const visitorsModels = ref([
|
||||
{
|
||||
@ -157,6 +157,7 @@ const editFormRules = reactive<FormRules>({
|
||||
httpPassword: [{ required: true, message: "请输入认证密码", trigger: "blur" }]
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 表单dom
|
||||
*/
|
||||
@ -506,17 +507,22 @@ const normalizePath = (filePath: string) => {
|
||||
};
|
||||
|
||||
const handleSelectFile = (type: number, ext: string[]) => {
|
||||
ipcRenderer.invoke("file.selectFile", ext).then(r => {
|
||||
switch (type) {
|
||||
case 1:
|
||||
editForm.value.https2httpCaFile = normalizePath(r[0]);
|
||||
break;
|
||||
case 2:
|
||||
editForm.value.https2httpKeyFile = normalizePath(r[0]);
|
||||
break;
|
||||
}
|
||||
console.log(r);
|
||||
currSelectLocalFileType.value = type;
|
||||
send(ipcRouters.SYSTEM.selectLocalFile, {
|
||||
name: "",
|
||||
extensions: ext
|
||||
});
|
||||
// ipcRenderer.invoke("file.selectFile", ext).then(r => {
|
||||
// switch (type) {
|
||||
// case 1:
|
||||
// editForm.value.https2httpCaFile = normalizePath(r[0]);
|
||||
// break;
|
||||
// case 2:
|
||||
// editForm.value.https2httpKeyFile = normalizePath(r[0]);
|
||||
// break;
|
||||
// }
|
||||
// console.log(r);
|
||||
// });
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@ -528,6 +534,20 @@ onMounted(() => {
|
||||
proxys.value = data;
|
||||
});
|
||||
|
||||
on(ipcRouters.SYSTEM.selectLocalFile, data => {
|
||||
console.log("data", data);
|
||||
if (!data.canceled) {
|
||||
switch (currSelectLocalFileType.value) {
|
||||
case 1:
|
||||
editForm.value.https2httpCaFile = data.path as string;
|
||||
break;
|
||||
case 2:
|
||||
editForm.value.https2httpKeyFile = data.path as string;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const insertOrUpdateHook = (message: string) => {
|
||||
loading.value.form--;
|
||||
// const { err } = args;
|
||||
@ -601,6 +621,7 @@ onUnmounted(() => {
|
||||
removeRouterListeners(ipcRouters.PROXY.getAllProxies);
|
||||
removeRouterListeners(ipcRouters.PROXY.modifyProxyStatus);
|
||||
removeRouterListeners(ipcRouters.PROXY.getLocalPorts);
|
||||
removeRouterListeners(ipcRouters.SYSTEM.selectLocalFile);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
|
Loading…
Reference in New Issue
Block a user