feat: monorepo
46
.gitignore
vendored
|
@ -11,21 +11,9 @@ pids
|
||||||
*.seed
|
*.seed
|
||||||
*.pid.lock
|
*.pid.lock
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
coverage
|
coverage
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
# node-waf configuration
|
||||||
.lock-wscript
|
.lock-wscript
|
||||||
|
|
||||||
|
@ -36,9 +24,6 @@ build/Release
|
||||||
node_modules/
|
node_modules/
|
||||||
jspm_packages/
|
jspm_packages/
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
|
||||||
typings/
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
# Optional npm cache directory
|
||||||
.npm
|
.npm
|
||||||
|
|
||||||
|
@ -57,37 +42,12 @@ typings/
|
||||||
# dotenv environment variables file
|
# dotenv environment variables file
|
||||||
.env.test
|
.env.test
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# next.js build output
|
|
||||||
.next
|
|
||||||
|
|
||||||
# nuxt.js build output
|
|
||||||
.nuxt
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# ----
|
# ----
|
||||||
dist
|
**/dist
|
||||||
**/.tmp
|
**/.tmp
|
||||||
/tmp
|
/tmp
|
||||||
release
|
release
|
||||||
.DS_Store
|
**/.DS_Store
|
||||||
dist-ssr
|
|
||||||
*.local
|
*.local
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
bundle-stats-main.html
|
.turbo
|
||||||
bundle-stats-preload.html
|
|
||||||
bundle-stats-renderer.html
|
|
||||||
tailwind-output.css
|
|
||||||
|
|
39
.vscode/launch.json
vendored
|
@ -1,39 +0,0 @@
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Main(inspector)",
|
|
||||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
|
||||||
"runtimeArgs": [
|
|
||||||
"--remote-debugging-port=9222",
|
|
||||||
"${workspaceFolder}/dist/main/index.cjs",
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"DEBUG": "true",
|
|
||||||
},
|
|
||||||
"windows": {
|
|
||||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
|
||||||
},
|
|
||||||
"sourceMaps": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Main(vite)",
|
|
||||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
|
||||||
"runtimeArgs": [
|
|
||||||
"${workspaceFolder}/dist/main/index.cjs",
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"VITE_DEV_SERVER_HOST": "127.0.0.1",
|
|
||||||
"VITE_DEV_SERVER_PORT": "3344",
|
|
||||||
},
|
|
||||||
"windows": {
|
|
||||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
|
||||||
},
|
|
||||||
"sourceMaps": true
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
13
.vscode/task.json
vendored
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"type": "npm",
|
|
||||||
"script": "debug",
|
|
||||||
"problemMatcher": [],
|
|
||||||
"label": "npm: debug",
|
|
||||||
"detail": "cross-env-shell NODE_ENV=debug \"npm run typecheck && node scripts/build.main.mjs && vite ./src/renderer\"",
|
|
||||||
"group": "build"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
34
auto-imports.d.ts
vendored
|
@ -1,34 +0,0 @@
|
||||||
// Generated by 'unplugin-auto-import'
|
|
||||||
// We suggest you to commit this file into source control
|
|
||||||
declare global {
|
|
||||||
const classNames: typeof import('classnames')['default']
|
|
||||||
const createRef: typeof import('react')['createRef']
|
|
||||||
const forwardRef: typeof import('react')['forwardRef']
|
|
||||||
const lazy: typeof import('react')['lazy']
|
|
||||||
const memo: typeof import('react')['memo']
|
|
||||||
const startTransition: typeof import('react')['startTransition']
|
|
||||||
const toast: typeof import('react-hot-toast')['toast']
|
|
||||||
const useCallback: typeof import('react')['useCallback']
|
|
||||||
const useContext: typeof import('react')['useContext']
|
|
||||||
const useDebugValue: typeof import('react')['useDebugValue']
|
|
||||||
const useDeferredValue: typeof import('react')['useDeferredValue']
|
|
||||||
const useEffect: typeof import('react')['useEffect']
|
|
||||||
const useEffectOnce: typeof import('react-use')['useEffectOnce']
|
|
||||||
const useId: typeof import('react')['useId']
|
|
||||||
const useImperativeHandle: typeof import('react')['useImperativeHandle']
|
|
||||||
const useInfiniteQuery: typeof import('react-query')['useInfiniteQuery']
|
|
||||||
const useInsertionEffect: typeof import('react')['useInsertionEffect']
|
|
||||||
const useLayoutEffect: typeof import('react')['useLayoutEffect']
|
|
||||||
const useMemo: typeof import('react')['useMemo']
|
|
||||||
const useMutation: typeof import('react-query')['useMutation']
|
|
||||||
const useNavigate: typeof import('react-router-dom')['useNavigate']
|
|
||||||
const useParams: typeof import('react-router-dom')['useParams']
|
|
||||||
const useQuery: typeof import('react-query')['useQuery']
|
|
||||||
const useReducer: typeof import('react')['useReducer']
|
|
||||||
const useRef: typeof import('react')['useRef']
|
|
||||||
const useSnapshot: typeof import('valtio')['useSnapshot']
|
|
||||||
const useState: typeof import('react')['useState']
|
|
||||||
const useSyncExternalStore: typeof import('react')['useSyncExternalStore']
|
|
||||||
const useTransition: typeof import('react')['useTransition']
|
|
||||||
}
|
|
||||||
export {}
|
|
126
package.json
|
@ -8,122 +8,22 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "qier222 <qier222@outlook.com>",
|
"author": "qier222 <qier222@outlook.com>",
|
||||||
"repository": "github:qier222/YesPlayMusic",
|
"repository": "github:qier222/YesPlayMusic",
|
||||||
"main": "dist/main/index.js",
|
|
||||||
"scripts": {
|
|
||||||
"install:sqlite3": "node scripts/build.sqlite3.js",
|
|
||||||
"dev": "concurrently -n=vite,main -c=#646cff,#74b1be \"npm run dev:renderer\" \"node scripts/build.main.mjs --watch\"",
|
|
||||||
"dev:renderer": "vite dev",
|
|
||||||
"build:main": "node scripts/build.main.mjs",
|
|
||||||
"build:renderer": "vite build",
|
|
||||||
"build": "cross-env-shell IS_ELECTRON=true npm run build:renderer && npm run build:main",
|
|
||||||
"build:app": "npm run build && electron-builder --config .electron-builder.config.js",
|
|
||||||
"build:app-dir": "npm run build && electron-builder --config .electron-builder.config.js --dir",
|
|
||||||
"build:app-win": "npm run build && electron-builder --config .electron-builder.config.js --win",
|
|
||||||
"build:app-mac": "npm run build && electron-builder --config .electron-builder.config.js --mac",
|
|
||||||
"build:app-linux": "npm run build && electron-builder --config .electron-builder.config.js --linux",
|
|
||||||
"debug": "cross-env-shell NODE_ENV=debug \"npm run typecheck && node scripts/build.mjs && vite ./src/renderer\"",
|
|
||||||
"test": "vitest",
|
|
||||||
"test:ui": "vitest --ui",
|
|
||||||
"test:coverage": "vitest run --coverage",
|
|
||||||
"test:types": "npm run test:types-renderer && npm run test:types-main && npm run test:types-shared",
|
|
||||||
"test:types-renderer": "tsc --noEmit --project src/renderer/tsconfig.json",
|
|
||||||
"test:types-main": "tsc --noEmit --project src/main/tsconfig.json",
|
|
||||||
"test:types-shared": "tsc --noEmit --project src/shared/tsconfig.json",
|
|
||||||
"netease": "npx NeteaseCloudMusicApi",
|
|
||||||
"eslint": "eslint --ext .ts,.js ./",
|
|
||||||
"prettier": "prettier --write './**/*.{ts,js,tsx,jsx}'",
|
|
||||||
"analyze:css": "npx windicss-analysis",
|
|
||||||
"analyze:js": "npm run build:renderer && open-cli bundle-stats-renderer.html"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
"node": "^14.13.1 || >=16.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"packageManager": "pnpm@7.0.0",
|
||||||
"@sentry/node": "^6.19.7",
|
"scripts": {
|
||||||
"@sentry/tracing": "^6.19.7",
|
"install": "turbo run post-install --parallel --no-cache",
|
||||||
"@unblockneteasemusic/rust-napi": "^0.3.0-pre.1",
|
"build": "turbo run build",
|
||||||
"NeteaseCloudMusicApi": "^4.5.12",
|
"build:web": "turbo run build:web",
|
||||||
"better-sqlite3": "7.5.1",
|
"dev": "turbo run dev --parallel",
|
||||||
"change-case": "^4.1.2",
|
"lint": "turbo run lint",
|
||||||
"cookie-parser": "^1.4.6",
|
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,md}\""
|
||||||
"electron-log": "^4.4.6",
|
|
||||||
"electron-store": "^8.0.1",
|
|
||||||
"express": "^4.18.0",
|
|
||||||
"fast-folder-size": "^1.6.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron/universal": "1.2.1",
|
"eslint": "^8.15.0",
|
||||||
"@sentry/react": "^6.19.7",
|
"prettier": "^2.6.2",
|
||||||
"@testing-library/react": "^13.1.1",
|
"turbo": "^1.2.8",
|
||||||
"@types/better-sqlite3": "^7.5.0",
|
"typescript": "^4.6.4"
|
||||||
"@types/cookie-parser": "^1.4.3",
|
|
||||||
"@types/express": "^4.17.13",
|
|
||||||
"@types/express-fileupload": "^1.2.2",
|
|
||||||
"@types/howler": "^2.2.7",
|
|
||||||
"@types/js-cookie": "^3.0.2",
|
|
||||||
"@types/lodash-es": "^4.17.6",
|
|
||||||
"@types/md5": "^2.3.2",
|
|
||||||
"@types/qrcode": "^1.4.2",
|
|
||||||
"@types/react": "^18.0.8",
|
|
||||||
"@types/react-dom": "^18.0.1",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
||||||
"@typescript-eslint/parser": "^5.21.0",
|
|
||||||
"@vitejs/plugin-react": "^1.3.1",
|
|
||||||
"@vitest/ui": "^0.10.0",
|
|
||||||
"autoprefixer": "^10.4.5",
|
|
||||||
"axios": "^0.27.2",
|
|
||||||
"c8": "^7.11.2",
|
|
||||||
"classnames": "^2.3.1",
|
|
||||||
"color.js": "^1.2.0",
|
|
||||||
"colord": "^2.9.2",
|
|
||||||
"concurrently": "^7.1.0",
|
|
||||||
"cross-env": "^7.0.3",
|
|
||||||
"dayjs": "^1.11.1",
|
|
||||||
"dotenv": "^16.0.0",
|
|
||||||
"electron": "^18.1.0",
|
|
||||||
"electron-builder": "^23.0.3",
|
|
||||||
"electron-devtools-installer": "^3.2.0",
|
|
||||||
"electron-rebuild": "^3.2.7",
|
|
||||||
"electron-releases": "^3.1004.0",
|
|
||||||
"esbuild": "^0.14.38",
|
|
||||||
"eslint": "^8.14.0",
|
|
||||||
"eslint-plugin-react": "^7.29.4",
|
|
||||||
"eslint-plugin-react-hooks": "^4.5.0",
|
|
||||||
"express-fileupload": "^1.3.1",
|
|
||||||
"framer-motion": "^6.3.2",
|
|
||||||
"howler": "^2.2.3",
|
|
||||||
"js-cookie": "^3.0.1",
|
|
||||||
"jsdom": "^19.0.0",
|
|
||||||
"lodash-es": "^4.17.21",
|
|
||||||
"md5": "^2.3.0",
|
|
||||||
"minimist": "^1.2.6",
|
|
||||||
"music-metadata": "^7.12.3",
|
|
||||||
"open-cli": "^7.0.1",
|
|
||||||
"ora": "^6.1.0",
|
|
||||||
"picocolors": "^1.0.0",
|
|
||||||
"postcss": "^8.4.12",
|
|
||||||
"prettier": "2.6.2",
|
|
||||||
"prettier-plugin-tailwindcss": "^0.1.10",
|
|
||||||
"qrcode": "^1.5.0",
|
|
||||||
"react": "^18.1.0",
|
|
||||||
"react-dom": "^18.1.0",
|
|
||||||
"react-ga4": "^1.4.1",
|
|
||||||
"react-hot-toast": "^2.2.0",
|
|
||||||
"react-query": "^3.38.0",
|
|
||||||
"react-router-dom": "^6.3.0",
|
|
||||||
"react-use": "^17.3.2",
|
|
||||||
"rollup-plugin-visualizer": "^5.6.0",
|
|
||||||
"sass": "^1.51.0",
|
|
||||||
"tailwindcss": "^3.0.24",
|
|
||||||
"typescript": "^4.6.3",
|
|
||||||
"unplugin-auto-import": "^0.7.1",
|
|
||||||
"valtio": "^1.6.0",
|
|
||||||
"vite": "^2.9.6",
|
|
||||||
"vite-plugin-svg-icons": "^2.0.1",
|
|
||||||
"vitest": "^0.10.0",
|
|
||||||
"wait-on": "^6.0.1"
|
|
||||||
},
|
|
||||||
"resolutions": {
|
|
||||||
"@electron/universal": "1.2.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* @type {import('electron-builder').Configuration}
|
* @type {import('electron-builder').Configuration}
|
||||||
* @see https://www.electron.build/configuration/configuration
|
* @see https://www.electron.build/configuration/configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
appId: 'com.qier222.yesplaymusic',
|
appId: 'com.qier222.yesplaymusic',
|
||||||
productName: 'YesPlayMusic',
|
productName: 'YesPlayMusic',
|
||||||
|
@ -100,7 +101,7 @@ module.exports = {
|
||||||
'dist/main/**/*',
|
'dist/main/**/*',
|
||||||
'dist/renderer/**/*',
|
'dist/renderer/**/*',
|
||||||
{
|
{
|
||||||
from: 'src/main/migrations',
|
from: 'packages/electron/migrations',
|
||||||
to: 'dist/main/migrations',
|
to: 'dist/main/migrations',
|
||||||
},
|
},
|
||||||
{
|
{
|
Before Width: | Height: | Size: 936 B After Width: | Height: | Size: 936 B |
Before Width: | Height: | Size: 612 B After Width: | Height: | Size: 612 B |
Before Width: | Height: | Size: 844 B After Width: | Height: | Size: 844 B |
Before Width: | Height: | Size: 890 B After Width: | Height: | Size: 890 B |
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 308 B |
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 953 B After Width: | Height: | Size: 953 B |
Before Width: | Height: | Size: 396 B After Width: | Height: | Size: 396 B |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 344 B |
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 932 B |
|
@ -86,7 +86,7 @@ class DB {
|
||||||
initTables() {
|
initTables() {
|
||||||
const migration = fs.readFileSync(
|
const migration = fs.readFileSync(
|
||||||
isDev
|
isDev
|
||||||
? path.join(process.cwd(), './src/main/migrations/init.sql')
|
? path.join(process.cwd(), './migrations/init.sql')
|
||||||
: path.join(__dirname, './migrations/init.sql'),
|
: path.join(__dirname, './migrations/init.sql'),
|
||||||
'utf8'
|
'utf8'
|
||||||
)
|
)
|
63
packages/electron/package.json
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
{
|
||||||
|
"name": "electron",
|
||||||
|
"private": true,
|
||||||
|
"version": "2.0.0",
|
||||||
|
"main": "./index.js",
|
||||||
|
"scripts": {
|
||||||
|
"post-install": "node scripts/build.sqlite3.js",
|
||||||
|
"dev": "node scripts/build.main.mjs --watch",
|
||||||
|
"build": "node scripts/build.main.mjs",
|
||||||
|
"test:types": "tsc --noEmit --project src/main/tsconfig.json",
|
||||||
|
"lint": "eslint --ext .ts,.js ./",
|
||||||
|
"format": "prettier --write './**/*.{ts,js,tsx,jsx}'"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^14.13.1 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@sentry/node": "^6.19.7",
|
||||||
|
"@sentry/tracing": "^6.19.7",
|
||||||
|
"@unblockneteasemusic/rust-napi": "^0.3.0-pre.1",
|
||||||
|
"NeteaseCloudMusicApi": "^4.5.12",
|
||||||
|
"better-sqlite3": "7.5.1",
|
||||||
|
"change-case": "^4.1.2",
|
||||||
|
"cookie-parser": "^1.4.6",
|
||||||
|
"electron-log": "^4.4.6",
|
||||||
|
"electron-store": "^8.0.1",
|
||||||
|
"express": "^4.18.1",
|
||||||
|
"fast-folder-size": "^1.6.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@electron/universal": "1.2.1",
|
||||||
|
"@types/better-sqlite3": "^7.5.0",
|
||||||
|
"@types/cookie-parser": "^1.4.3",
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
|
"@types/express-fileupload": "^1.2.2",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
||||||
|
"@typescript-eslint/parser": "^5.21.0",
|
||||||
|
"@vitejs/plugin-react": "^1.3.1",
|
||||||
|
"axios": "^0.27.2",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
|
"dotenv": "^16.0.0",
|
||||||
|
"electron": "^18.2.2",
|
||||||
|
"electron-builder": "^23.0.3",
|
||||||
|
"electron-devtools-installer": "^3.2.0",
|
||||||
|
"electron-rebuild": "^3.2.7",
|
||||||
|
"electron-releases": "^3.1009.0",
|
||||||
|
"esbuild": "^0.14.38",
|
||||||
|
"eslint": "*",
|
||||||
|
"express-fileupload": "^1.3.1",
|
||||||
|
"minimist": "^1.2.6",
|
||||||
|
"music-metadata": "^7.12.3",
|
||||||
|
"open-cli": "^7.0.1",
|
||||||
|
"ora": "^6.1.0",
|
||||||
|
"picocolors": "^1.0.0",
|
||||||
|
"prettier": "*",
|
||||||
|
"prettier-plugin-tailwindcss": "^0.1.10",
|
||||||
|
"typescript": "*",
|
||||||
|
"wait-on": "^6.0.1"
|
||||||
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"@electron/universal": "1.2.1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ import { createDirIfNotExist } from './utils'
|
||||||
const isDev = process.env.NODE_ENV === 'development'
|
const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
const devUserDataPath = path.resolve(process.cwd(), './tmp/userData')
|
const devUserDataPath = path.resolve(process.cwd(), '../../tmp/userData')
|
||||||
createDirIfNotExist(devUserDataPath)
|
createDirIfNotExist(devUserDataPath)
|
||||||
app.setPath('appData', devUserDataPath)
|
app.setPath('appData', devUserDataPath)
|
||||||
}
|
}
|
|
@ -10,10 +10,10 @@ import pc from 'picocolors'
|
||||||
import minimist from 'minimist'
|
import minimist from 'minimist'
|
||||||
|
|
||||||
const env = dotenv.config({
|
const env = dotenv.config({
|
||||||
path: path.resolve(process.cwd(), '.env'),
|
path: path.resolve(process.cwd(), '../../.env'),
|
||||||
})
|
})
|
||||||
const envForEsbuild = {}
|
const envForEsbuild = {}
|
||||||
Object.entries(env.parsed).forEach(([key, value]) => {
|
Object.entries(env.parsed || {}).forEach(([key, value]) => {
|
||||||
envForEsbuild[`process.env.${key}`] = `"${value}"`
|
envForEsbuild[`process.env.${key}`] = `"${value}"`
|
||||||
})
|
})
|
||||||
console.log(envForEsbuild)
|
console.log(envForEsbuild)
|
||||||
|
@ -23,8 +23,8 @@ const TAG = '[script/build.main.ts]'
|
||||||
const spinner = ora(`${TAG} Main Process Building...`)
|
const spinner = ora(`${TAG} Main Process Building...`)
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
entryPoints: ['./src/main/index.ts', './src/main/rendererPreload.ts'],
|
entryPoints: ['./index.ts', './rendererPreload.ts'],
|
||||||
outdir: './dist/main/',
|
outdir: './dist',
|
||||||
platform: 'node',
|
platform: 'node',
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
bundle: true,
|
bundle: true,
|
||||||
|
@ -37,22 +37,18 @@ const options = {
|
||||||
'electron',
|
'electron',
|
||||||
'NeteaseCloudMusicApi',
|
'NeteaseCloudMusicApi',
|
||||||
'better-sqlite3',
|
'better-sqlite3',
|
||||||
'@unblockneteasemusic/rust-napi'
|
'@unblockneteasemusic/rust-napi',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
const runApp = () => {
|
const runApp = () => {
|
||||||
return spawn(
|
return spawn(electron, [path.resolve(process.cwd(), './dist/index.js')], {
|
||||||
electron,
|
stdio: 'inherit',
|
||||||
[path.resolve(process.cwd(), './dist/main/index.js')],
|
env: {
|
||||||
{
|
...process.env,
|
||||||
stdio: 'inherit',
|
NODE_ENV: 'development',
|
||||||
env: {
|
},
|
||||||
...process.env,
|
})
|
||||||
NODE_ENV: 'development',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv.watch) {
|
if (argv.watch) {
|
|
@ -7,6 +7,7 @@ const releases = require('electron-releases')
|
||||||
const pkg = require(`${process.cwd()}/package.json`)
|
const pkg = require(`${process.cwd()}/package.json`)
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const { execSync } = require('child_process')
|
const { execSync } = require('child_process')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
const electronVersion = pkg.devDependencies.electron.replaceAll('^', '')
|
const electronVersion = pkg.devDependencies.electron.replaceAll('^', '')
|
||||||
const betterSqlite3Version = pkg.dependencies['better-sqlite3'].replaceAll(
|
const betterSqlite3Version = pkg.dependencies['better-sqlite3'].replaceAll(
|
||||||
|
@ -21,10 +22,10 @@ const isWin = process.platform === 'win32'
|
||||||
const isMac = process.platform === 'darwin'
|
const isMac = process.platform === 'darwin'
|
||||||
const isLinux = process.platform === 'linux'
|
const isLinux = process.platform === 'linux'
|
||||||
|
|
||||||
const projectDir = process.cwd()
|
const projectDir = path.resolve(process.cwd(), '../../')
|
||||||
|
|
||||||
if (!fs.existsSync(`${projectDir}/dist/main`)) {
|
if (!fs.existsSync(`${projectDir}/src/main/dist`)) {
|
||||||
fs.mkdirSync(`${projectDir}/dist/main`, {
|
fs.mkdirSync(`${projectDir}/src/main/dist`, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,7 @@ const download = async arch => {
|
||||||
try {
|
try {
|
||||||
fs.copyFileSync(
|
fs.copyFileSync(
|
||||||
`${dir}/build/Release/better_sqlite3.node`,
|
`${dir}/build/Release/better_sqlite3.node`,
|
||||||
`${projectDir}/dist/main/better_sqlite3_${arch}.node`
|
`${projectDir}/src/main/dist/better_sqlite3_${arch}.node`
|
||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(pc.red('Copy failed! Skip copy.', e))
|
console.log(pc.red('Copy failed! Skip copy.', e))
|
||||||
|
@ -77,7 +78,7 @@ const download = async arch => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(`${dir}/build`, { recursive: true, force: true })
|
fs.rmSync(`${dir}/build`, { recursive: true, force: true })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(pc.red('Delete failed! Skip delete.'))
|
console.log(pc.red('Delete failed! Skip delete.'))
|
||||||
return false
|
return false
|
||||||
|
@ -92,15 +93,20 @@ const build = async arch => {
|
||||||
|
|
||||||
console.log(pc.cyan(`Building for ${arch}...`))
|
console.log(pc.cyan(`Building for ${arch}...`))
|
||||||
await rebuild({
|
await rebuild({
|
||||||
buildPath: projectDir,
|
// projectRootPath: projectDir,
|
||||||
|
// buildPath: process.cwd(),
|
||||||
|
projectRootPath: projectDir,
|
||||||
|
buildPath: process.cwd(),
|
||||||
electronVersion,
|
electronVersion,
|
||||||
arch: arch,
|
arch,
|
||||||
|
onlyModules: ['better-sqlite3'],
|
||||||
|
force: true,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.info('Build succeeded')
|
console.info('Build succeeded')
|
||||||
fs.copyFileSync(
|
fs.copyFileSync(
|
||||||
`${projectDir}/node_modules/better-sqlite3/build/Release/better_sqlite3.node`,
|
`${projectDir}/node_modules/better-sqlite3/build/Release/better_sqlite3.node`,
|
||||||
`${projectDir}/dist/main/better_sqlite3_${arch}.node`
|
`${projectDir}/src/main/dist/better_sqlite3_${arch}.node`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
|
@ -76,7 +76,7 @@ class Server {
|
||||||
|
|
||||||
serveStaticForProd() {
|
serveStaticForProd() {
|
||||||
if (isProd) {
|
if (isProd) {
|
||||||
this.app.use('/', express.static(path.join(__dirname, '../renderer/')))
|
this.app.use('/', express.static(path.join(__dirname, '../web/')))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { Toaster } from 'react-hot-toast'
|
import { Toaster } from 'react-hot-toast'
|
||||||
import { QueryClientProvider } from 'react-query'
|
import { QueryClientProvider } from 'react-query'
|
||||||
import { ReactQueryDevtools } from 'react-query/devtools'
|
import { ReactQueryDevtools } from 'react-query/devtools'
|
||||||
import Player from '@/renderer/components/Player'
|
import Player from '@/web/components/Player'
|
||||||
import Sidebar from '@/renderer/components/Sidebar'
|
import Sidebar from '@/web/components/Sidebar'
|
||||||
import reactQueryClient from '@/renderer/utils/reactQueryClient'
|
import reactQueryClient from '@/web/utils/reactQueryClient'
|
||||||
import Main from '@/renderer/components/Main'
|
import Main from '@/web/components/Main'
|
||||||
import TitleBar from '@/renderer/components/TitleBar'
|
import TitleBar from '@/web/components/TitleBar'
|
||||||
import Lyric from '@/renderer/components/Lyric'
|
import Lyric from '@/web/components/Lyric'
|
||||||
import IpcRendererReact from '@/renderer/IpcRendererReact'
|
import IpcRendererReact from '@/web/IpcRendererReact'
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
return (
|
return (
|
|
@ -1,10 +1,13 @@
|
||||||
import { IpcChannels } from '@/shared/IpcChannels'
|
import { IpcChannels } from '@/shared/IpcChannels'
|
||||||
import useUserLikedTracksIDs, {
|
import useUserLikedTracksIDs, {
|
||||||
useMutationLikeATrack,
|
useMutationLikeATrack,
|
||||||
} from '@/renderer/hooks/useUserLikedTracksIDs'
|
} from '@/web/hooks/useUserLikedTracksIDs'
|
||||||
import { player } from '@/renderer/store'
|
import { player } from '@/web/store'
|
||||||
import useIpcRenderer from '@/renderer/hooks/useIpcRenderer'
|
import useIpcRenderer from '@/web/hooks/useIpcRenderer'
|
||||||
import { State as PlayerState } from '@/renderer/utils/player'
|
import { State as PlayerState } from '@/web/utils/player'
|
||||||
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
|
import { useEffectOnce } from 'react-use'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
|
||||||
const IpcRendererReact = () => {
|
const IpcRendererReact = () => {
|
||||||
const [isPlaying, setIsPlaying] = useState(false)
|
const [isPlaying, setIsPlaying] = useState(false)
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
import {
|
import {
|
||||||
FetchAlbumParams,
|
FetchAlbumParams,
|
||||||
FetchAlbumResponse,
|
FetchAlbumResponse,
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
import {
|
import {
|
||||||
FetchArtistParams,
|
FetchArtistParams,
|
||||||
FetchArtistResponse,
|
FetchArtistResponse,
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
import { FetchUserAccountResponse } from '@/shared/api/User'
|
import { FetchUserAccountResponse } from '@/shared/api/User'
|
||||||
|
|
||||||
// 手机号登录
|
// 手机号登录
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
|
|
||||||
export enum PersonalFMApiNames {
|
export enum PersonalFMApiNames {
|
||||||
FetchPersonalFm = 'fetchPersonalFM',
|
FetchPersonalFm = 'fetchPersonalFM',
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
import {
|
import {
|
||||||
FetchPlaylistParams,
|
FetchPlaylistParams,
|
||||||
FetchPlaylistResponse,
|
FetchPlaylistResponse,
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
import {
|
import {
|
||||||
SearchParams,
|
SearchParams,
|
||||||
SearchResponse,
|
SearchResponse,
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
import {
|
import {
|
||||||
FetchAudioSourceParams,
|
FetchAudioSourceParams,
|
||||||
FetchAudioSourceResponse,
|
FetchAudioSourceResponse,
|
|
@ -1,4 +1,4 @@
|
||||||
import request from '@/renderer/utils/request'
|
import request from '@/web/utils/request'
|
||||||
import {
|
import {
|
||||||
FetchUserAccountResponse,
|
FetchUserAccountResponse,
|
||||||
FetchUserPlaylistsParams,
|
FetchUserPlaylistsParams,
|
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 538 B After Width: | Height: | Size: 538 B |
Before Width: | Height: | Size: 946 B After Width: | Height: | Size: 946 B |
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 429 B |
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 540 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 847 B |
Before Width: | Height: | Size: 484 B After Width: | Height: | Size: 484 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 550 B |
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 557 B After Width: | Height: | Size: 557 B |
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 367 B |
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 369 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 741 B After Width: | Height: | Size: 741 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 708 B |