Skip to content

Commit

Permalink
增加网络差的情况下的下载引导 / 增加自动加载 mitm 插件的服务
Browse files Browse the repository at this point in the history
  • Loading branch information
v1ll4n committed Jan 25, 2022
1 parent 4feacdc commit c960f88
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
20 changes: 10 additions & 10 deletions app/main/handlers/mitm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ const {ipcMain} = require("electron");
const DNS = require("dns");


module.exports = (win, originGetClient) => {
let mitmClient = undefined;

function getClient() {
if (!mitmClient) {
mitmClient = originGetClient(true)
return mitmClient
}
return mitmClient
}
// module.exports = (win, originGetClient) => {
module.exports = (win, getClient) => {
// let mitmClient = undefined;
// function getClient() {
// if (!mitmClient) {
// mitmClient = originGetClient(true)
// return mitmClient
// }
// return mitmClient
// }

let stream;
let currentPort;
Expand Down
40 changes: 37 additions & 3 deletions app/renderer/src/main/src/components/YakUpgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useEffect, useState} from "react";
import {Alert, Button, Card, Modal, Popconfirm, Popover, Progress, Space, Spin, Tag, Typography} from "antd";
import {failed, info, success} from "../utils/notification";
import {yakProcess} from "../protected/YakLocalProcess";
import {showModal} from "../utils/showModal";

const {ipcRenderer} = window.require("electron");

Expand Down Expand Up @@ -40,6 +41,8 @@ export const YakUpgrade: React.FC<YakUpgradeProp> = (props) => {
const [winPath, setWinPath] = useState("");
const [platformArch, setPlatformArch] = useState("");

const latestVersionWithoutV = latestVersion.startsWith("v") ? latestVersion.slice(1) : latestVersion;

const queryLatestVersion = () => {
setLatestLoading(true)
ipcRenderer.invoke("query-latest-yak-version").then((data: string) => {
Expand Down Expand Up @@ -158,9 +161,11 @@ export const YakUpgrade: React.FC<YakUpgradeProp> = (props) => {
<Spin spinning={loading}>
<Alert
type={"success"}
message={<Space>
当前最新的 Yak 引擎版本为
<Tag color={"green"}>{latestVersion}</Tag>
message={<Space direction={"vertical"}>
<Space>
当前最新的 Yak 引擎版本为
<Tag color={"green"}>{latestVersion}</Tag>
</Space>
</Space>}/>
</Spin>
<Spin spinning={downloading}>
Expand Down Expand Up @@ -189,6 +194,35 @@ export const YakUpgrade: React.FC<YakUpgradeProp> = (props) => {
<Button type={"link"} onClick={() => {
install(latestVersion)
}}>我已经下载,点此安装</Button>
<Button danger={true} size={"small"} onClick={() => {
showModal({
title: "yak 核心引擎下载链接",
width: "60%",
content: <Space direction={"vertical"}>
<Space>
Windows(x64) 下载:
<div>https://yaklang.oss-cn-beijing.aliyuncs.com/yak/{latestVersionWithoutV}/yak_windows_amd64.exe</div>
</Space>
<Space>
MacOS(intel/m1) 下载:
<div>https://yaklang.oss-cn-beijing.aliyuncs.com/yak/{latestVersionWithoutV}/yak_darwin_amd64</div>
</Space>
<Space>
Linux(x64) 下载:
<div>https://yaklang.oss-cn-beijing.aliyuncs.com/yak/{latestVersionWithoutV}/yak_linux_amd64</div>
</Space>
<Alert message={<div>
手动下载完成后 Windows 用户可以把引擎放在 %HOME%/yakit-projects/yak-engine/yak.exe 即可识别
<br/>
MacOS / Linux 用户可以把引擎放在 ~/yakit-projects/yak-engine/yak 即可识别
</div>}>

</Alert>
</Space>
})
}}>
网络问题无法下载?手动下载
</Button>
</Space>
</Spin>
{downloadProgress && <Progress percent={
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/src/main/src/pages/mitm/MITMPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const MITMPage: React.FC<MITMPageProp> = (props) => {
failed("MITM 劫持服务器异常或被关闭")
Modal.error({
mask: true, title: "启动 MITM 服务器 ERROR!",
content: <>{error}</>
content: <>{msg}</>
})
}
ipcRenderer.invoke("mitm-stop-call")
Expand Down

0 comments on commit c960f88

Please sign in to comment.