feat: 解决build bug

This commit is contained in:
qier222 2022-04-02 00:45:20 +08:00
parent 46fe2d734e
commit e99c4833f7
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
47 changed files with 1236 additions and 611 deletions

View file

@ -9,6 +9,11 @@ import {
getAudioCache,
} from './cache'
import fileUpload from 'express-fileupload'
import path from 'path'
logger.info('[server] starting http server')
const isDev = process.env.NODE_ENV === 'development'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const neteaseApi = require('NeteaseCloudMusicApi') as (params: any) => any[]
@ -82,7 +87,15 @@ app.post('/yesplaymusic/audio/:id', async (req: Request, res: Response) => {
}
})
const port = Number(process.env.ELECTRON_DEV_NETEASE_API_PORT ?? 3000)
if (!isDev) {
app.use(express.static(path.join(__dirname, '../renderer')))
}
const port = Number(
isDev
? process.env.ELECTRON_DEV_NETEASE_API_PORT ?? 3000
: process.env.ELECTRON_WEB_SERVER_PORT ?? 42710
)
app.listen(port, () => {
logger.info(`[server] API server listening on port ${port}`)
})