├── .eslintignore ├── .gitmodules ├── .prettierrc.yaml ├── resources ├── icon.ico └── icon.png ├── .prettierignore ├── .eslintrc.js ├── .editorconfig ├── src ├── preload.js ├── renderer.js ├── index.html ├── main.js ├── style.css └── icons.svg ├── .gitignore ├── LICENSE ├── package.json ├── electron-builder.json5 └── README.MD /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | out 4 | .gitignore 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "um-react"] 2 | path = um-react 3 | url = ./um-react 4 | -------------------------------------------------------------------------------- /.prettierrc.yaml: -------------------------------------------------------------------------------- 1 | singleQuote: true 2 | semi: false 3 | printWidth: 100 4 | trailingComma: none 5 | -------------------------------------------------------------------------------- /resources/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dfvips/um-react-electron/HEAD/resources/icon.ico -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dfvips/um-react-electron/HEAD/resources/icon.png -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | pnpm-lock.yaml 4 | LICENSE.md 5 | tsconfig.json 6 | tsconfig.*.json 7 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['eslint:recommended', '@electron-toolkit', '@electron-toolkit/eslint-config-prettier'] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /src/preload.js: -------------------------------------------------------------------------------- 1 | // All of the Node.js APIs are available in the preload process. 2 | // It has the same sandbox as a Chrome extension. 3 | const { contextBridge } = require('electron') 4 | const { electronAPI } = require('@electron-toolkit/preload') 5 | 6 | // Custom APIs for renderer 7 | const api = {} 8 | 9 | // Use `contextBridge` APIs to expose Electron APIs to 10 | // renderer only if context isolation is enabled, otherwise 11 | // just add to the DOM global. 12 | if (process.contextIsolated) { 13 | try { 14 | contextBridge.exposeInMainWorld('electron', electronAPI) 15 | contextBridge.exposeInMainWorld('api', api) 16 | } catch (error) { 17 | console.error(error) 18 | } 19 | } else { 20 | window.electron = electronAPI 21 | window.api = api 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs/ 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules/ 11 | coverage/ 12 | dist/ 13 | dist-ssr/ 14 | release/**/* 15 | *.local 16 | src/renderer/**/* 17 | src/default/**/* 18 | 19 | # Editor directories and files 20 | .vscode/ 21 | !.vscode/extensions.json 22 | .idea/ 23 | .DS_Store 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | 30 | # Ignore the same patterns in the "um-react" directory 31 | um-react/logs/ 32 | um-react/*.log 33 | um-react/npm-debug.log* 34 | um-react/yarn-debug.log* 35 | um-react/yarn-error.log* 36 | um-react/pnpm-debug.log* 37 | um-react/lerna-debug.log* 38 | 39 | um-react/node_modules/ 40 | um-react/coverage/ 41 | um-react/dist/ 42 | um-react/dist-ssr/ 43 | um-react/*.local 44 | -------------------------------------------------------------------------------- /src/renderer.js: -------------------------------------------------------------------------------- 1 | // This file is required by the index.html file and will 2 | // be executed in the renderer process for that window. 3 | // No Node.js APIs are available in this process because 4 | // `nodeIntegration` is turned off. Use `preload.js` to 5 | // selectively enable features needed in the rendering 6 | // process. 7 | ;(async () => { 8 | window.addEventListener('DOMContentLoaded', () => { 9 | doAThing() 10 | }) 11 | 12 | function doAThing() { 13 | const versions = window.electron.process.versions 14 | replaceText('.electron-version', `Electron v${versions.electron}`) 15 | replaceText('.chrome-version', `Chromium v${versions.chrome}`) 16 | replaceText('.node-version', `Node v${versions.node}`) 17 | replaceText('.v8-version', `V8 v${versions.v8}`) 18 | } 19 | 20 | function replaceText(selector, text) { 21 | const element = document.querySelector(selector) 22 | if (element) { 23 | element.innerText = text 24 | } 25 | } 26 | })() 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 dreamfly 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "um-react-electron", 3 | "version": "1.0.0", 4 | "description": "Unlock Music 音乐解锁 (React) Electron App", 5 | "main": "./src/main.js", 6 | "author": "dreamfly", 7 | "homepage": "https://git.unlock-music.dev/um/um-react", 8 | "scripts": { 9 | "format": "prettier --write .", 10 | "lint": "eslint --ext .js .", 11 | "dev": "cd um-react && npm run build && cp -r ./dist ../src/renderer && cd ../ && electron .", 12 | "start": "cd um-react && npm run build && cp -r ./dist ../src/renderer && cd ../ && electron .", 13 | "postinstall": "electron-builder install-app-deps", 14 | "build": "cd um-react && npm run build && cp -r ./dist ../src/renderer && cd ../", 15 | "build:win": "cd um-react && npm run build && cp -r ./dist ../src/renderer && cd ../ && electron-builder --win --config", 16 | "build:mac": "cd um-react && npm run build && cp -r ./dist ../src/renderer && cd ../ && electron-builder --mac --config", 17 | "build:linux": "cd um-react && npm run build && cp -r ./dist ../src/renderer && cd ../ && electron-builder --linux --config" 18 | }, 19 | "dependencies": { 20 | "@electron-toolkit/preload": "^2.0.0", 21 | "@electron-toolkit/utils": "^2.0.0" 22 | }, 23 | "devDependencies": { 24 | "@electron-toolkit/eslint-config": "^1.0.1", 25 | "@electron-toolkit/eslint-config-prettier": "^1.0.1", 26 | "electron": "^25.6.0", 27 | "electron-builder": "^24.6.3", 28 | "eslint": "^8.47.0", 29 | "prettier": "^3.0.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /electron-builder.json5: -------------------------------------------------------------------------------- 1 | /** 2 | * @see https://www.electron.build/configuration/configuration 3 | */ 4 | { 5 | "$schema": "https://github.com/dfvips/iqiyi-parser", 6 | "appId": "com.dreamfly.um", 7 | "productName": "音乐解锁 React", 8 | "asar": true, 9 | "directories": { 10 | "output": "release/${version}" 11 | }, 12 | "asarUnpack":[ 13 | "resources/**" 14 | ], 15 | "mac": { 16 | "icon": "build/icon.icns", 17 | "artifactName": "${name}-${version}-osx64.${ext}", 18 | "target": [ 19 | "dmg" 20 | ], 21 | "files": [ 22 | "!**/.vscode/*", 23 | "!{.eslintignore,.eslintrc.js,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}" 24 | ] 25 | }, 26 | "compression": "maximum", 27 | "win": { 28 | "icon": "build/icon.ico", 29 | "target": [ 30 | { 31 | "target": "nsis", 32 | "arch": [ 33 | "x64" 34 | ] 35 | }, 36 | { 37 | "target": "7z" 38 | } 39 | ], 40 | "artifactName": "${name}-${version}-winx64.${ext}", 41 | "files": [ 42 | "!**/.vscode/*", 43 | "!{.eslintignore,.eslintrc.js,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}" 44 | ] 45 | }, 46 | "nsis": { 47 | "oneClick": false, 48 | "perMachine": false, 49 | "allowToChangeInstallationDirectory": true, 50 | "deleteAppDataOnUninstall": true, 51 | "installerIcon": "build/icon.ico", 52 | "uninstallerIcon": "build/icon.ico", 53 | "uninstallDisplayName": "${name}-${version}", 54 | "artifactName": "${name}-${version}-winx64-setup.${ext}", 55 | "shortcutName": "${productName}" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |Please try pressing F12 to open the devTool
This is the simplest starter for Electron without any build tools
28 |29 | You can check out the links to learn more about Electron build tools 30 |
31 | 32 | 46 | 47 |More templates:
48 |
49 | vanilla, vanilla-ts, vue, vue-ts,
50 | react, react-ts, svelte, svelte-ts
51 |