Skip to content

Commit 68faca6

Browse files
committed
chore: 更新 main.ts 檔案以使用 app.getAppPath() 取代 ROOT_PATH,並調整 GitHub Actions 工作流程以新增 .env 檔案的生成步驟
1 parent b558094 commit 68faca6

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

.github/workflows/dev-release.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Release Test Version
22

33
on:
44
push:
5-
tags: ['*']
6-
branches: ['dev']
5+
tags: ['dev-*']
76

87
permissions:
98
contents: write
@@ -37,6 +36,12 @@ jobs:
3736
- name: Install dependencies
3837
run: yarn install --frozen-lockfile
3938

39+
- name: Make .env file
40+
run: |
41+
echo "NEXT_PUBLIC_API_URL=${{ secrets.API_URL }}" > .env
42+
echo "NEXT_PUBLIC_WS_URL=${{ secrets.WS_URL }}" >> .env
43+
echo "NEXT_PUBLIC_CROWDIN_DISTRIBUTION_HASH=${{ secrets.CROWDIN_DISTRIBUTION_HASH }}" >> .env
44+
4045
- name: Build electron
4146
uses: samuelmeuli/action-electron-builder@v1
4247
env:

main.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import net from 'net';
33
import path from 'path';
44
import fontList from 'font-list';
5-
import { fileURLToPath } from 'url';
65
import { io, Socket } from 'socket.io-client';
76
import DiscordRPC from 'discord-rpc';
87
import dotenv from 'dotenv';
@@ -220,26 +219,22 @@ export const PopupSize = {
220219

221220
// Constants
222221
const DEV = process.argv.includes('--dev');
223-
const WS_URL = process.env.NEXT_PUBLIC_WS_URL;
224222
const PORT = 3000;
225223
const BASE_URI = DEV ? `http://localhost:${PORT}` : 'app://-';
226-
const FILE_PATH = fileURLToPath(import.meta.url);
227-
const DIR_PATH = path.dirname(FILE_PATH);
228-
const ROOT_PATH = DEV ? DIR_PATH : path.join(DIR_PATH, '../');
229224
const DISCORD_RPC_CLIENT_ID = '1242441392341516288';
230225
const APP_ICON =
231226
process.platform === 'win32'
232-
? path.join(ROOT_PATH, 'resources', 'icon.ico')
233-
: path.join(ROOT_PATH, 'resources', 'icon.png');
227+
? path.join(app.getAppPath(), 'resources', 'icon.ico')
228+
: path.join(app.getAppPath(), 'resources', 'icon.png');
234229
const APP_TRAY_ICON = {
235230
gray:
236231
process.platform === 'win32'
237-
? path.join(ROOT_PATH, 'resources', 'tray_gray.ico')
238-
: path.join(ROOT_PATH, 'resources', 'tray_gray.png'),
232+
? path.join(app.getAppPath(), 'resources', 'tray_gray.ico')
233+
: path.join(app.getAppPath(), 'resources', 'tray_gray.png'),
239234
normal:
240235
process.platform === 'win32'
241-
? path.join(ROOT_PATH, 'resources', 'tray.ico')
242-
: path.join(ROOT_PATH, 'resources', 'tray.png'),
236+
? path.join(app.getAppPath(), 'resources', 'tray.ico')
237+
: path.join(app.getAppPath(), 'resources', 'tray.png'),
243238
};
244239

245240
// Windows
@@ -248,7 +243,7 @@ let authWindow: BrowserWindow;
248243
let popups: Record<string, BrowserWindow> = {};
249244

250245
// Socket
251-
const websocketUrl = WS_URL;
246+
const websocketUrl = process.env.NEXT_PUBLIC_WS_URL;
252247
let socketInstance: Socket | null = null;
253248

254249
// Discord RPC
@@ -271,7 +266,7 @@ const defaultPrecence = {
271266
],
272267
};
273268

274-
const appServe = serve({ directory: path.join(ROOT_PATH, 'out') });
269+
const appServe = serve({ directory: path.join(app.getAppPath(), 'out') });
275270

276271
// Functions
277272
// async function checkIsHinet() {
@@ -669,7 +664,7 @@ function configureAutoUpdater() {
669664

670665
if (DEV) {
671666
autoUpdater.forceDevUpdateConfig = true;
672-
autoUpdater.updateConfigPath = path.join(ROOT_PATH, 'dev-app-update.yml');
667+
autoUpdater.updateConfigPath = path.join(app.getAppPath(), 'dev-app-update.yml');
673668
}
674669

675670
autoUpdater.on('error', (error: any) => {

0 commit comments

Comments
 (0)