Skip to content

Commit bddc496

Browse files
committed
chore: 处理环境判断
1 parent 1a8c18c commit bddc496

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
electron_mirror=https://npmmirror.com/mirrors/electron/
22
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
3+
msvs_version=2022

src/main/child_server/h5_server/server.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import fs from 'node:fs' // 添加fs模块用于读取证书文件
99
import path from 'node:path'
1010
import zlib from 'node:zlib'
1111
import { fileURLToPath } from 'node:url'
12-
import { getLocalIP, findAvailablePort, generateSelfSignedCert } from '../../utils/utils.mjs' // 添加证书生成函数
12+
import { getLocalIP, findAvailablePort, generateSelfSignedCert, isDev } from '../../utils/utils.mjs' // 添加证书生成函数
1313
import useApi from './api/index.mjs'
1414
import { t } from '../../../i18n/server.js'
1515
import setupSocketIO from './socket/index.mjs'
@@ -32,7 +32,6 @@ export default async ({
3232
let ioServer
3333
try {
3434
const __dirname = path.dirname(fileURLToPath(import.meta.url))
35-
const isProduction = process.env.NODE_ENV === 'production'
3635
port = await findAvailablePort(port)
3736
host = getLocalIP()
3837

@@ -130,9 +129,9 @@ export default async ({
130129
})
131130
)
132131
// 处理H5静态资源地址
133-
const staticPath = isProduction
134-
? path.resolve(process.env.FBW_RESOURCES_PATH, './h5')
135-
: path.resolve(__dirname, '../h5')
132+
const staticPath = isDev()
133+
? path.resolve(__dirname, '../h5')
134+
: path.resolve(process.env.FBW_RESOURCES_PATH, './h5')
136135
logger.info(`[H5Server] INFO => H5静态资源路径: ${staticPath}`)
137136
// 提供静态资源服务
138137
app.use(

0 commit comments

Comments
 (0)