Skip to content

Commit

Permalink
Vanilla mode now should not use local server at all
Browse files Browse the repository at this point in the history
Removed excessive user-agent modifications
i18n: zh-TW translation, zh-CN typos
  • Loading branch information
iamtakingiteasy committed Oct 30, 2023
1 parent 99ea6f1 commit 6695620
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion i18n/en-US/manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"useHttpServer": "User http server(avoid certificate error)",
"serverToPlay": "Server to play (0 is China server, 1 is Japan server, 2 is America server)",
"proxyUrl": "Proxy server address (leave it empty if you don't want to use it)",
"userAgent": "Useragent",
"userAgent": "User-Agent",
"vanillaMode": "Vanilla mode (no extensions)",
"userLibPath": "'User Library' Path",
"localVersion": "Version",
Expand Down
2 changes: 1 addition & 1 deletion i18n/zh-CN/manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"serverToPlay": "游戏服务器(0为国服,1为日服,2为美服)",
"proxyUrl": "代理服务器地址(留空为不使用代理)",
"userAgent": "User-Agent",
"vanillaMode": "纯洁模式(停用所有扩展)",
"vanillaMode": "纯净模式(停用所有扩展)",
"userLibPath": "用户库目录",
"localVersion": "版本",
"isManagerHide": "退出游戏后回到管理器界面",
Expand Down
4 changes: 2 additions & 2 deletions i18n/zh-TW/manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"useHttpServer": "\u4f7f\u7528 http \u670d\u52d9\u5668\uff08\u4e0d\u5b58\u5728\u8b49\u66f8\u932f\u8aa4\uff09",
"serverToPlay": "\u904a\u6232\u4f3a\u670d\u5668\uff080\u70ba\u570b\u4f3a\uff0c1\u70ba\u65e5\u4f3a\uff0c2\u70ba\u7f8e\u4f3a\uff09",
"proxyUrl": "\u4ee3\u7406\u4f3a\u670d\u5668\u5730\u5740\uff08\u7559\u7a7a\u70ba\u4e0d\u4f7f\u7528\u4ee3\u7406\uff09",
"userAgent": "\u7528\u6236\u4ee3\u7406",
"vanillaMode": "Vanilla mode (no extensions)",
"userAgent": "User-Agent",
"vanillaMode": "\u7d14\u6de8\u6a21\u5f0f\uff08\u505c\u7528\u6240\u6709\u64f4\u5c55\uff09",
"userLibPath": "\u8cc7\u6599\u593e\u76ee\u9304",
"localVersion": "\u7248\u672c",
"isManagerHide": "\u9000\u51fa\u904a\u6232\u5f8c\uff0c\u8fd4\u56de\u6a94\u6848\u7e3d\u7ba1",
Expand Down
4 changes: 1 addition & 3 deletions src/bin/main/mainLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function redirectGameWindow(url: string, gameWindow: Electron.WebviewTag) {
const localUrl = getLocalUrlWithParams(url)
console.log('[Majsoul Plus] Redirect Target:' + localUrl)

gameWindow.loadURL(localUrl, {userAgent: navigator.userAgent})
gameWindow.loadURL(localUrl)
}

function scaleWindow(percent = scalePercent) {
Expand Down Expand Up @@ -140,8 +140,6 @@ mainWindow.addEventListener('dom-ready', () => {
} else {
scaleWindow(100)
}

mainWindow.useragent = navigator.userAgent
})

ipcRenderer.on(
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ app.on('ready', () => {

// 资源管理器通知启动游戏
ipcMain.on('start-game', () => {
// 加载服务器路由规则
LoadServer()
if (!UserConfigs.userData.vanillaMode) {
// 加载服务器路由规则
LoadServer()

// 启动服务器
ListenServer(Global.ServerPort)
// 启动服务器
ListenServer(Global.ServerPort)
}

if (!process.env.SERVER_ONLY) {
GameWindows.newWindow()
Expand Down
27 changes: 17 additions & 10 deletions src/windows/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ListenServer,
LoadServer
} from '../server'
import { getRemoteUrl } from '../utils';
import { ToolManager } from '../tool/tool'
import { AudioPlayer, initPlayer, shutoffPlayer } from './audioPlayer'
import { ManagerWindow } from './manager'
Expand Down Expand Up @@ -103,15 +104,21 @@ export function newGameWindow(id: number) {
window.setMenu(getGameWindowMenu(id))

window.webContents.on('dom-ready', () => {
// 加载本地服务器地址
const http = UserConfigs.userData.useHttpServer
const port = (UserConfigs.userData.useHttpServer
? (httpServer.address() as AddressInfo)
: (httpsServer.address() as AddressInfo)
).port
const url = `http${
UserConfigs.userData.useHttpServer ? '' : 's'
}://localhost:${port}/`
let url, port, http

if (UserConfigs.userData.vanillaMode) {
url = getRemoteUrl('/')
} else {
// 加载本地服务器地址
http = UserConfigs.userData.useHttpServer
port = (UserConfigs.userData.useHttpServer
? (httpServer.address() as AddressInfo)
: (httpsServer.address() as AddressInfo)
).port
url = `http${
UserConfigs.userData.useHttpServer ? '' : 's'
}://localhost:${port}/`
}

window.webContents.send(
'load-url',
Expand Down Expand Up @@ -165,7 +172,7 @@ export function newGameWindow(id: number) {
window.webContents.userAgent = UserConfigs.window.userAgent

// 载入本地启动器
window.loadURL('file://' + path.join(__dirname, '../bin/main/index.html'), {userAgent: UserConfigs.window.userAgent})
window.loadURL('file://' + path.join(__dirname, '../bin/main/index.html'))

// 在 debug 启动环境下打开开发者工具
if (process.env.NODE_ENV === 'development') {
Expand Down

0 comments on commit 6695620

Please sign in to comment.