Skip to content

Commit a18e093

Browse files
committed
fix: fix build && adapte for bugs in NeteasyCloudMusicAPI
1 parent 1a2c3e2 commit a18e093

File tree

5 files changed

+4473
-4061
lines changed

5 files changed

+4473
-4061
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
"electron-log": "^4.3.0",
4848
"electron-store": "^8.0.1",
4949
"electron-updater": "^5.0.1",
50+
"esbuild": "^0.20.1",
51+
"esbuild-loader": "^4.0.3",
5052
"express": "^4.17.1",
5153
"express-fileupload": "^1.2.0",
5254
"express-http-proxy": "^1.6.2",
@@ -85,11 +87,11 @@
8587
"@vue/cli-service": "~4.5.0",
8688
"babel-eslint": "^10.1.0",
8789
"eslint": "^6.7.2",
88-
"prettier": "2.5.1",
8990
"eslint-config-prettier": "^8.1.0",
9091
"eslint-plugin-prettier": "^3.3.1",
9192
"eslint-plugin-vue": "^7.9.0",
9293
"husky": "^4.3.0",
94+
"prettier": "2.5.1",
9395
"sass": "^1.26.11",
9496
"sass-loader": "^10.0.2",
9597
"vue-cli-plugin-electron-builder": "~2.1.1",

src/electron/services.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import clc from 'cli-color';
2+
import checkAuthToken from "../utils/checkAuthToken"
23
import server from 'NeteaseCloudMusicApi/server';
34

45
export async function startNeteaseMusicApi() {
5-
// Let user know that the service is starting
6+
// Let user know that the service is starting
67
console.log(`${clc.redBright('[NetEase API]')} initiating NCM API`);
78

89
// Load the NCM API.

src/utils/checkAuthToken.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import os from 'os'
2+
import fs from "fs"
3+
import path from 'path'
4+
5+
// extract from NeteasyCloudMusicAPI/generateConfig.js and avoid bugs in there (generateConfig require main.js but the main.js has bugs)
6+
if (!fs.existsSync(path.resolve(os.tmpdir(), 'anonymous_token'))) {
7+
fs.writeFileSync(path.resolve(os.tmpdir(), 'anonymous_token'), '', 'utf-8')
8+
}

vue.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ module.exports = {
6363
.loader('node-loader')
6464
.end();
6565

66+
config.module
67+
.rule('webpack4_es_fallback')
68+
.test(/\.js$/)
69+
.include.add(/node_modules/)
70+
.end()
71+
.use('esbuild-loader')
72+
.loader('esbuild-loader')
73+
.options({ target: 'es2015', format: "cjs" })
74+
.end();
75+
6676
// LimitChunkCountPlugin 可以通过合并块来对块进行后期处理。用以解决 chunk 包太多的问题
6777
config.plugin('chunkPlugin').use(webpack.optimize.LimitChunkCountPlugin, [
6878
{
@@ -169,6 +179,16 @@ module.exports = {
169179
'jsbi',
170180
path.join(__dirname, 'node_modules/jsbi/dist/jsbi-cjs.js')
171181
);
182+
183+
config.module
184+
.rule('webpack4_es_fallback')
185+
.test(/\.js$/)
186+
.include.add(/node_modules/)
187+
.end()
188+
.use('esbuild-loader')
189+
.loader('esbuild-loader')
190+
.options({ target: 'es2015', format: "cjs" })
191+
.end();
172192
},
173193
// 渲染线程的配置文件
174194
chainWebpackRendererProcess: config => {

0 commit comments

Comments
 (0)