🐛 修复window运行
This commit is contained in:
parent
563374a4be
commit
ac19bc8aca
@ -157,10 +157,18 @@ export const initFrpcApi = () => {
|
|||||||
config.currentVersion,
|
config.currentVersion,
|
||||||
(frpcVersionPath: string) => {
|
(frpcVersionPath: string) => {
|
||||||
generateConfig(config, configPath => {
|
generateConfig(config, configPath => {
|
||||||
|
const platform = process.platform;
|
||||||
|
if (platform === 'win32') {
|
||||||
|
startFrpcProcess(
|
||||||
|
path.join(frpcVersionPath, "frpc.exe"),
|
||||||
|
configPath
|
||||||
|
);
|
||||||
|
}else {
|
||||||
startFrpcProcess(
|
startFrpcProcess(
|
||||||
path.join(frpcVersionPath, "frpc"),
|
path.join(frpcVersionPath, "frpc"),
|
||||||
configPath
|
configPath
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -5,6 +5,7 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const zlib = require("zlib");
|
const zlib = require("zlib");
|
||||||
const {download} = require("electron-dl");
|
const {download} = require("electron-dl");
|
||||||
|
const unzipper = require('unzipper');
|
||||||
|
|
||||||
|
|
||||||
const versionRelation = {
|
const versionRelation = {
|
||||||
@ -12,12 +13,12 @@ const versionRelation = {
|
|||||||
"win32_arm64": ["window", "arm64"],
|
"win32_arm64": ["window", "arm64"],
|
||||||
"win32_ia32": ["window", "386"],
|
"win32_ia32": ["window", "386"],
|
||||||
"darwin_arm64": ["darwin", "arm64"],
|
"darwin_arm64": ["darwin", "arm64"],
|
||||||
|
// "darwin_arm64": ["window", "amd64"],
|
||||||
"darwin_amd64": ["darwin", "amd64"],
|
"darwin_amd64": ["darwin", "amd64"],
|
||||||
}
|
}
|
||||||
|
|
||||||
const unTarGZ = tarGzPath => {
|
const unTarGZ = (tarGzPath: string, targetPath: string) => {
|
||||||
const tar = require("tar");
|
const tar = require("tar");
|
||||||
const targetPath = path.resolve(path.join(app.getPath("userData"), "frp"));
|
|
||||||
const unzip = zlib.createGunzip();
|
const unzip = zlib.createGunzip();
|
||||||
const readStream = fs.createReadStream(tarGzPath);
|
const readStream = fs.createReadStream(tarGzPath);
|
||||||
if (!fs.existsSync(unzip)) {
|
if (!fs.existsSync(unzip)) {
|
||||||
@ -34,6 +35,23 @@ const unTarGZ = tarGzPath => {
|
|||||||
// console.log("解压完成!");
|
// console.log("解压完成!");
|
||||||
// });
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unZip = (zipPath: string, targetPath: string) => {
|
||||||
|
if (!fs.existsSync(path.join(targetPath, path.basename(zipPath, ".zip")))) {
|
||||||
|
fs.mkdirSync(path.join(targetPath, path.basename(zipPath, ".zip")), {recursive: true});
|
||||||
|
}
|
||||||
|
fs.createReadStream(zipPath)
|
||||||
|
.pipe(unzipper.ParseOne('frpc'))
|
||||||
|
.pipe(fs.createWriteStream(path.join(targetPath, path.basename(zipPath, ".zip"), "frpc.exe")))
|
||||||
|
.on('finish', () => {
|
||||||
|
console.log('File extracted successfully.');
|
||||||
|
})
|
||||||
|
.on('error', (err) => {
|
||||||
|
console.error('Error extracting file:', err);
|
||||||
|
});
|
||||||
|
return path.join("frp", path.basename(zipPath, ".zip"))
|
||||||
|
}
|
||||||
|
|
||||||
export const initGitHubApi = () => {
|
export const initGitHubApi = () => {
|
||||||
// 版本
|
// 版本
|
||||||
let versions = [];
|
let versions = [];
|
||||||
@ -114,12 +132,26 @@ export const initGitHubApi = () => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onCompleted: () => {
|
onCompleted: () => {
|
||||||
const frpcVersionPath = unTarGZ(
|
const targetPath = path.resolve(path.join(app.getPath("userData"), "frp"));
|
||||||
|
const ext = path.extname(asset.name)
|
||||||
|
let frpcVersionPath = ""
|
||||||
|
if (ext === '.zip') {
|
||||||
|
frpcVersionPath = unZip(path.join(
|
||||||
|
path.join(app.getPath("userData"), "download"),
|
||||||
|
`${asset.name}`
|
||||||
|
),
|
||||||
|
targetPath)
|
||||||
|
console.log(frpcVersionPath, '1')
|
||||||
|
} else if (ext === '.gz' && asset.name.includes(".tar.gz")) {
|
||||||
|
frpcVersionPath = unTarGZ(
|
||||||
path.join(
|
path.join(
|
||||||
path.join(app.getPath("userData"), "download"),
|
path.join(app.getPath("userData"), "download"),
|
||||||
`${asset.name}`
|
`${asset.name}`
|
||||||
)
|
),
|
||||||
|
targetPath
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
version["frpcVersionPath"] = frpcVersionPath;
|
version["frpcVersionPath"] = frpcVersionPath;
|
||||||
insertVersion(version, (err, document) => {
|
insertVersion(version, (err, document) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
10
package.json
10
package.json
@ -49,14 +49,14 @@
|
|||||||
"vite": "^4.4.9",
|
"vite": "^4.4.9",
|
||||||
"vite-plugin-electron": "^0.15.3",
|
"vite-plugin-electron": "^0.15.3",
|
||||||
"vite-plugin-electron-renderer": "^0.14.5",
|
"vite-plugin-electron-renderer": "^0.14.5",
|
||||||
"vue-tsc": "^1.8.8",
|
|
||||||
"vue-types": "^5.1.1",
|
|
||||||
"electron-icon-builder": "^2.0.1",
|
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-router": "^4.2.4"
|
"vue-router": "^4.2.4",
|
||||||
|
"vue-tsc": "^1.8.8",
|
||||||
|
"vue-types": "^5.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"electron-dl": "^3.5.1",
|
"electron-dl": "^3.5.1",
|
||||||
"tar": "^6.2.0"
|
"tar": "^6.2.0",
|
||||||
|
"unzipper": "^0.10.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ onUnmounted(() => {
|
|||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<el-tag>{{ version.name }}</el-tag>
|
<el-tag>{{ version.name }}</el-tag>
|
||||||
<el-tag class="ml-2">原文件名:{{ version.assets[0]?.name }}</el-tag>
|
<!-- <el-tag class="ml-2">原文件名:{{ version.assets[0]?.name }}</el-tag>-->
|
||||||
</div>
|
</div>
|
||||||
<div class="text-sm">
|
<div class="text-sm">
|
||||||
发布时间:<span class="text-gray-00">{{
|
发布时间:<span class="text-gray-00">{{
|
||||||
|
Loading…
Reference in New Issue
Block a user