Skip to content

Fix: Fix build error and /tmp/anonymous_token not exist. #2187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: fix build && adapte for bugs in NeteasyCloudMusicAPI
  • Loading branch information
DaiQiangReal committed Mar 4, 2024
commit a18e093d4adf29a207c767da256d1ce45adc2baf
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