Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fix. 重写代理,读写配置模块 & feat. 下载/打开compass
Browse files Browse the repository at this point in the history
  • Loading branch information
btjawa committed Nov 3, 2023
1 parent 3701e89 commit cc3ac5a
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 379 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ BTJGenshinPS-1.0.2-win32-ia32-release
GateServer
release.md
app.config.json
config.json
BGP-docs
BTJGenshinPS.iss
logs
logs
.vscode
data/MongoDB Compass
Binary file added data/keystore.p12
Binary file not shown.
Binary file removed data/keystore_local.p12
Binary file not shown.
22 changes: 21 additions & 1 deletion dist/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ input[type="checkbox"] {
display: none;
}

input:focus,
button:focus {
border: 2px solid #007BFF;
outline: none;
box-shadow: 0 0 5px rgba(0, 123, 255, 1);
color: #fff;
background-color: #007bff88;
}

::selection {
background-color: #007BFF;
}

.ssl_ver_0, .ssl_ver_1 , .ssl_ver_2,
.proxy_using_ssl {
display: flex;
Expand Down Expand Up @@ -174,7 +187,7 @@ button[name="edit_config"] {

button[name="gctools_btn"].disabled,
button[name="choose_3dmigoto_path"].disabled,
button[name="compass_btn"] {
button[name="compass_btn"].disabled {
background-color: #80808860;
color: #e4e4e456;
}
Expand Down Expand Up @@ -667,6 +680,12 @@ button[name="clear_data"] {
.res_version {
cursor: pointer;
text-decoration: underline;
transition: color 0.1s ease-in-out, border 0.1s ease-in-out;
}

.gc_version:hover,
.res_version:hover {
color: #999696;
}

.page_0_version_title { bottom: 45px; }
Expand Down Expand Up @@ -815,6 +834,7 @@ button[name="clear_data"] {
}

.page_log_text_0 {
user-select:text;
display:block;
position: relative;
top: 6px;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
</div>
</div>
<input type="text" name="mongo_port" value="27017" disabled="disabled">
<input type="text" name="mongo_data_folder" value=".\data" disabled="disabled">
<input type="text" name="mongo_data_folder" value="data" disabled="disabled">
<div class="page_0_text_5">
<div class="page_0_text_5_flex_0"><i class="fa-solid fa-fire"></i>&ensp;客户端代理
<div class="page_0_text_5_flex_sub_0">
Expand Down
34 changes: 16 additions & 18 deletions dist/js/ipc.renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ const elems = {
gcDispatchPort: $('input[name=gc_dispatch_port]'),
proxyIP: $('input[name=proxy_ip]'),
proxyPort: $('input[name=proxy_port]'),
proxyUsingSSLCheckbox: $(".proxy_using_ssl input[type='checkbox']")
proxyUsingSSLCheckbox: $(".proxy_using_ssl input[type='checkbox']"),
remoteMitmGuide: $('button[name="remote_mitm_guide"]')
};

const izi_notify_mp3 = new Audio("sounds/izi_notify.mp3");

let gcInputRender = new Array(4);
let proxyInputRender = new Array(2);
let gcSSLStatus;
let gc_latestCommitSha;
let gc_latestReleaseTagName;
let res_latestCommitSha;
Expand All @@ -68,14 +70,7 @@ function izi_notify() {
}

function save_settings() {
gcInputRender = [elems.gcIp.val(), elems.gcGamePort.val(), elems.gcDispatchPort.val()];
if (elems.gcIp.val() !== "127.0.0.1" && elems.gcIp.val() !== "localhost" && elems.gcIp.val() !== "0.0.0.0") {
if (elems.selfSignedKeystoreBox.prop('checked')) {
elems.pageLogText0.append(`检测到监听IP不为本地,且启用了SSL,请确保服务器同样开启代理,并在用户系统设置代理为&nbsp;${elems.gcIp.val()}:54321<br>`);
} else {
elems.pageLogText0.append(`检测到监听IP不为本地<br>`);
}
}
gcInputRender = [elems.gcIp.val(), elems.gcGamePort.val(), elems.gcDispatchPort.val(), elems.gcIp.val()];
proxyInputRender = [elems.proxyIP.val(), elems.proxyPort.val()];
}

Expand Down Expand Up @@ -274,6 +269,7 @@ function selfSignedKeystoreBox_ClickHandler() {
return;
}
ipcRenderer.send('selfSignedKeystoreBox-set');
gcSSLStatus = true;
iziToast.info({
icon: 'fa-solid fa-circle-info',
layout: '2',
Expand All @@ -295,6 +291,7 @@ function noKeystoreBox_ClickHandler() {
return;
}
ipcRenderer.send('noKeystoreBoxBox-set');
gcSSLStatus = false;
iziToast.info({
icon: 'fa-solid fa-circle-info',
layout: '2',
Expand Down Expand Up @@ -338,7 +335,7 @@ elems.proxyUsingSSLCheckbox.on('click', proxyUsingSSLCheckbox_ClickHandler);

function operationBoxBtn_0_ClickHandler() {
save_settings();
ipcRenderer.send('operationBoxBtn_0-run-main-service', gcInputRender, proxyInputRender);
ipcRenderer.send('operationBoxBtn_0-run-main-service', gcInputRender, proxyInputRender, gcSSLStatus);
iziToast.info({
icon: 'fa-solid fa-circle-info',
layout: '2',
Expand All @@ -354,7 +351,7 @@ function operationBoxBtn_0_ClickHandler() {

function operationBoxBtn_proxy_ClickHandler() {
save_settings();
ipcRenderer.send('operationBoxBtn_proxy-run-proxy-service', gcInputRender, proxyInputRender);
ipcRenderer.send('operationBoxBtn_proxy-run-proxy-service', gcInputRender, proxyInputRender, gcSSLStatus);
iziToast.info({
icon: 'fa-solid fa-circle-info',
layout: '2',
Expand Down Expand Up @@ -542,11 +539,10 @@ ipcRenderer.on('openHandbookTXTBtn_not-found', (event) => {


.on('operationBoxBtn_proxy-msg', (event, msg, err) => {
if (err) {
elems.pageLogText0.append(`遇到错误:${err}<br>将尝试使用本地代理<br>`);
} else {
elems.pageLogText0.append(msg);
}
elems.pageLogText0.append(err ? `遇到错误:${err}<br>请检查端口开放、IP是否正确等,并尝试重新启动服务,报错详情请看日志`: msg, "<br>");
elems.remoteMitmGuide.on('click', () => {
toggleMenuState('menu_selector_2');
})
})

.on('update_complete', (event) => {
Expand Down Expand Up @@ -576,9 +572,11 @@ ipcRenderer.on('openHandbookTXTBtn_not-found', (event) => {
if (ver === "selfSignedKeystore") {
elems.selfSignedKeystoreBox.prop('checked', true);
elems.noKeystoreBox.prop('checked', false);
gcSSLStatus = true;
} else if (ver === "noKeystore") {
elems.selfSignedKeystoreBox.prop('checked', false);
elems.noKeystoreBox.prop('checked', true);
gcSSLStatus = false;
}
})

Expand All @@ -596,7 +594,7 @@ ipcRenderer.on('openHandbookTXTBtn_not-found', (event) => {
elems.gcDispatchPort.val(input[2]);
})

.on('proxy_text', (event, input, status) => {
.on('proxy_text', (event, input) => {
elems.proxyIP.val(input[0]);
elems.proxyPort.val(input[1]);
})
Expand Down Expand Up @@ -678,7 +676,7 @@ ipcRenderer.on('openHandbookTXTBtn_not-found', (event) => {
icon: 'fa-solid fa-circle-info',
layout: '2',
title: 'MongoDB&nbsp;Compass',
message: 'MongoDB&nbsp;Compass下载成功!尝试打开...',
message: 'MongoDB&nbsp;Compass下载成功!正在解压...',
onOpening: function() {
izi_notify()
}
Expand Down
30 changes: 12 additions & 18 deletions dist/js/render.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
$(document).ready(function () {
const $DocsIframe = $('#doc_iframe');

$DocsIframe.on('load', setIframeListeners);

iziToast.settings({
timeout: 2500,
icon: 'Fontawesome',
Expand All @@ -14,7 +12,6 @@ $(document).ready(function () {
backgroundColor: '#686b80',
theme: 'dark'
});

$(document.body).on('copy', function () {
iziToast.info({
icon: 'fa-regular fa-copy',
Expand All @@ -25,45 +22,42 @@ $(document).ready(function () {
}
});
});

function setIframeListeners() {
const iframe = $DocsIframe[0].contentWindow.document;
$(iframe).on('click', function(event) {
let element = $(event.target);
while (element && element[0] !== iframe.body && !element.attr('href')) {
element = element.parent();
}
if (element && element.attr('href')) {
const link = element.attr('href');
const regex = /(http|https):\/\/([\w.]+\/?)\S*/ig;
if (regex.test(link)) {
event.preventDefault();
ipcRenderer.send('open-url', link);
let element = event.target;
while (element && element !== iframe.body) {
if (element.tagName === 'A' && element.hasAttribute('href')) {
const link = element.getAttribute('href');
const regex = /^(http|https):\/\/([\w.]+\/?)\S*/ig;
if (regex.test(link)) {
event.preventDefault();
ipcRenderer.send('open-url', link);
return;
}
}
element = element.parentElement;
}
});
$(iframe).on('auxclick', function(event) {
event.preventDefault();
});
}

$('#refresh_iframe').on('click', function() {
$DocsIframe[0].contentWindow.location.reload();
});

$('#backward_page_iframe').on('click', function() {
$DocsIframe[0].contentWindow.history.back();
$DocsIframe.on('load', function() {
setIframeListeners();
$DocsIframe.off('load');
});
});

$('#home_page_iframe').on('click', function() {
$DocsIframe.attr('src', "http://localhost:52805/BGP-docs");
$DocsIframe.on('load', function() {
setIframeListeners();
$DocsIframe.off('load');
});
});
});
});
Loading

0 comments on commit cc3ac5a

Please sign in to comment.