Skip to content

Commit

Permalink
fix: fix build && adapte for bugs in NeteasyCloudMusicAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiQiangReal committed Mar 4, 2024
1 parent 1a2c3e2 commit a18e093
Show file tree
Hide file tree
Showing 5 changed files with 4,473 additions and 4,061 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"electron-log": "^4.3.0",
"electron-store": "^8.0.1",
"electron-updater": "^5.0.1",
"esbuild": "^0.20.1",
"esbuild-loader": "^4.0.3",
"express": "^4.17.1",
"express-fileupload": "^1.2.0",
"express-http-proxy": "^1.6.2",
Expand Down Expand Up @@ -85,11 +87,11 @@
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"prettier": "2.5.1",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.9.0",
"husky": "^4.3.0",
"prettier": "2.5.1",
"sass": "^1.26.11",
"sass-loader": "^10.0.2",
"vue-cli-plugin-electron-builder": "~2.1.1",
Expand Down
3 changes: 2 additions & 1 deletion src/electron/services.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import clc from 'cli-color';
import checkAuthToken from "../utils/checkAuthToken"
import server from 'NeteaseCloudMusicApi/server';

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

// Load the NCM API.
Expand Down
8 changes: 8 additions & 0 deletions src/utils/checkAuthToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os from 'os'
import fs from "fs"
import path from 'path'

// extract from NeteasyCloudMusicAPI/generateConfig.js and avoid bugs in there (generateConfig require main.js but the main.js has bugs)
if (!fs.existsSync(path.resolve(os.tmpdir(), 'anonymous_token'))) {
fs.writeFileSync(path.resolve(os.tmpdir(), 'anonymous_token'), '', 'utf-8')
}
20 changes: 20 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ module.exports = {
.loader('node-loader')
.end();

config.module
.rule('webpack4_es_fallback')
.test(/\.js$/)
.include.add(/node_modules/)
.end()
.use('esbuild-loader')
.loader('esbuild-loader')
.options({ target: 'es2015', format: "cjs" })
.end();

// LimitChunkCountPlugin 可以通过合并块来对块进行后期处理。用以解决 chunk 包太多的问题
config.plugin('chunkPlugin').use(webpack.optimize.LimitChunkCountPlugin, [
{
Expand Down Expand Up @@ -169,6 +179,16 @@ module.exports = {
'jsbi',
path.join(__dirname, 'node_modules/jsbi/dist/jsbi-cjs.js')
);

config.module
.rule('webpack4_es_fallback')
.test(/\.js$/)
.include.add(/node_modules/)
.end()
.use('esbuild-loader')
.loader('esbuild-loader')
.options({ target: 'es2015', format: "cjs" })
.end();
},
// 渲染线程的配置文件
chainWebpackRendererProcess: config => {
Expand Down
Loading

0 comments on commit a18e093

Please sign in to comment.