commit
8e767f8522
26 changed files with 28662 additions and 0 deletions
@ -0,0 +1,9 @@ |
|||
root = true |
|||
|
|||
[*] |
|||
charset = utf-8 |
|||
indent_style = space |
|||
indent_size = 2 |
|||
end_of_line = lf |
|||
insert_final_newline = true |
|||
trim_trailing_whitespace = true |
@ -0,0 +1,6 @@ |
|||
node_modules |
|||
dist |
|||
out |
|||
.DS_Store |
|||
.eslintcache |
|||
*.log* |
@ -0,0 +1,2 @@ |
|||
electron_mirror=https://npmmirror.com/mirrors/electron/ |
|||
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/ |
@ -0,0 +1,6 @@ |
|||
out |
|||
dist |
|||
pnpm-lock.yaml |
|||
LICENSE.md |
|||
tsconfig.json |
|||
tsconfig.*.json |
@ -0,0 +1,4 @@ |
|||
singleQuote: true |
|||
semi: false |
|||
printWidth: 100 |
|||
trailingComma: none |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"recommendations": ["dbaeumer.vscode-eslint"] |
|||
} |
@ -0,0 +1,39 @@ |
|||
{ |
|||
"version": "0.2.0", |
|||
"configurations": [ |
|||
{ |
|||
"name": "Debug Main Process", |
|||
"type": "node", |
|||
"request": "launch", |
|||
"cwd": "${workspaceRoot}", |
|||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite", |
|||
"windows": { |
|||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd" |
|||
}, |
|||
"runtimeArgs": ["--sourcemap"], |
|||
"env": { |
|||
"REMOTE_DEBUGGING_PORT": "9222" |
|||
} |
|||
}, |
|||
{ |
|||
"name": "Debug Renderer Process", |
|||
"port": 9222, |
|||
"request": "attach", |
|||
"type": "chrome", |
|||
"webRoot": "${workspaceFolder}/src/renderer", |
|||
"timeout": 60000, |
|||
"presentation": { |
|||
"hidden": true |
|||
} |
|||
} |
|||
], |
|||
"compounds": [ |
|||
{ |
|||
"name": "Debug All", |
|||
"configurations": ["Debug Main Process", "Debug Renderer Process"], |
|||
"presentation": { |
|||
"order": 1 |
|||
} |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,11 @@ |
|||
{ |
|||
"[typescript]": { |
|||
"editor.defaultFormatter": "esbenp.prettier-vscode" |
|||
}, |
|||
"[javascript]": { |
|||
"editor.defaultFormatter": "esbenp.prettier-vscode" |
|||
}, |
|||
"[json]": { |
|||
"editor.defaultFormatter": "esbenp.prettier-vscode" |
|||
} |
|||
} |
@ -0,0 +1,6 @@ |
|||
# 有源标靶上位机软件 |
|||
|
|||
## 快速开始 |
|||
### 安装 |
|||
1. 克隆仓库 |
|||
|
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
|||
<plist version="1.0"> |
|||
<dict> |
|||
<key>com.apple.security.cs.allow-jit</key> |
|||
<true/> |
|||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key> |
|||
<true/> |
|||
<key>com.apple.security.cs.allow-dyld-environment-variables</key> |
|||
<true/> |
|||
</dict> |
|||
</plist> |
After Width: | Height: | Size: 121 KiB |
After Width: | Height: | Size: 536 KiB |
@ -0,0 +1,3 @@ |
|||
provider: generic |
|||
url: https://example.com/auto-updates |
|||
updaterCacheDirName: electron-app-updater |
@ -0,0 +1,44 @@ |
|||
appId: com.electron.app |
|||
productName: electron-app |
|||
directories: |
|||
buildResources: build |
|||
files: |
|||
- '!**/.vscode/*' |
|||
- '!src/*' |
|||
- '!electron.vite.config.{js,ts,mjs,cjs}' |
|||
- '!{.eslintcache,eslint.config.mjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}' |
|||
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}' |
|||
asarUnpack: |
|||
- resources/** |
|||
win: |
|||
executableName: electron-app |
|||
nsis: |
|||
artifactName: ${name}-${version}-setup.${ext} |
|||
shortcutName: ${productName} |
|||
uninstallDisplayName: ${productName} |
|||
createDesktopShortcut: always |
|||
mac: |
|||
entitlementsInherit: build/entitlements.mac.plist |
|||
extendInfo: |
|||
- NSCameraUsageDescription: Application requests access to the device's camera. |
|||
- NSMicrophoneUsageDescription: Application requests access to the device's microphone. |
|||
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder. |
|||
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder. |
|||
notarize: false |
|||
dmg: |
|||
artifactName: ${name}-${version}.${ext} |
|||
linux: |
|||
target: |
|||
- AppImage |
|||
- snap |
|||
- deb |
|||
maintainer: electronjs.org |
|||
category: Utility |
|||
appImage: |
|||
artifactName: ${name}-${version}.${ext} |
|||
npmRebuild: false |
|||
publish: |
|||
provider: generic |
|||
url: https://example.com/auto-updates |
|||
electronDownload: |
|||
mirror: https://npmmirror.com/mirrors/electron/ |
@ -0,0 +1,20 @@ |
|||
import { resolve } from 'path' |
|||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite' |
|||
import react from '@vitejs/plugin-react' |
|||
|
|||
export default defineConfig({ |
|||
main: { |
|||
plugins: [externalizeDepsPlugin()] |
|||
}, |
|||
preload: { |
|||
plugins: [externalizeDepsPlugin()] |
|||
}, |
|||
renderer: { |
|||
resolve: { |
|||
alias: { |
|||
'@renderer': resolve('src/renderer/src') |
|||
} |
|||
}, |
|||
plugins: [react()] |
|||
} |
|||
}) |
@ -0,0 +1,31 @@ |
|||
import eslint from '@electron-toolkit/eslint-config' |
|||
import eslintConfigPrettier from '@electron-toolkit/eslint-config-prettier' |
|||
import eslintPluginReact from 'eslint-plugin-react' |
|||
import eslintPluginReactHooks from 'eslint-plugin-react-hooks' |
|||
import eslintPluginReactRefresh from 'eslint-plugin-react-refresh' |
|||
|
|||
export default [ |
|||
{ ignores: ['**/node_modules', '**/dist', '**/out'] }, |
|||
eslint, |
|||
eslintPluginReact.configs.flat.recommended, |
|||
eslintPluginReact.configs.flat['jsx-runtime'], |
|||
{ |
|||
settings: { |
|||
react: { |
|||
version: 'detect' |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
files: ['**/*.{js,jsx}'], |
|||
plugins: { |
|||
'react-hooks': eslintPluginReactHooks, |
|||
'react-refresh': eslintPluginReactRefresh |
|||
}, |
|||
rules: { |
|||
...eslintPluginReactHooks.configs.recommended.rules, |
|||
...eslintPluginReactRefresh.configs.vite.rules |
|||
} |
|||
}, |
|||
eslintConfigPrettier |
|||
] |
File diff suppressed because it is too large
@ -0,0 +1,42 @@ |
|||
{ |
|||
"name": "FlexometerSetup", |
|||
"version": "1.0.0", |
|||
"description": "An Electron application with React", |
|||
"main": "./out/main/index.js", |
|||
"author": "cles", |
|||
"homepage": "https://blog.clesbit.top", |
|||
"scripts": { |
|||
"format": "prettier --write .", |
|||
"lint": "eslint --cache .", |
|||
"start": "electron-vite preview", |
|||
"dev": "electron-vite dev", |
|||
"build": "electron-vite build", |
|||
"postinstall": "electron-builder install-app-deps", |
|||
"build:unpack": "npm run build && electron-builder --dir", |
|||
"build:win": "npm run build && electron-builder --win", |
|||
"build:mac": "npm run build && electron-builder --mac", |
|||
"build:linux": "npm run build && electron-builder --linux" |
|||
}, |
|||
"dependencies": { |
|||
"@electron-toolkit/preload": "^3.0.2", |
|||
"@electron-toolkit/utils": "^4.0.0", |
|||
"antd": "^5.27.1", |
|||
"electron-updater": "^6.3.9" |
|||
}, |
|||
"devDependencies": { |
|||
"@electron-toolkit/eslint-config": "^2.0.0", |
|||
"@electron-toolkit/eslint-config-prettier": "^3.0.0", |
|||
"@vitejs/plugin-react": "^4.3.4", |
|||
"electron": "^37.2.3", |
|||
"electron-builder": "^25.1.8", |
|||
"electron-vite": "^4.0.0", |
|||
"eslint": "^9.31.0", |
|||
"eslint-plugin-react": "^7.37.5", |
|||
"eslint-plugin-react-hooks": "^5.2.0", |
|||
"eslint-plugin-react-refresh": "^0.4.20", |
|||
"prettier": "^3.6.2", |
|||
"react": "^19.1.0", |
|||
"react-dom": "^19.1.0", |
|||
"vite": "^7.0.5" |
|||
} |
|||
} |
After Width: | Height: | Size: 536 KiB |
@ -0,0 +1,74 @@ |
|||
import { app, shell, BrowserWindow, ipcMain } from 'electron' |
|||
import { join } from 'path' |
|||
import { electronApp, optimizer, is } from '@electron-toolkit/utils' |
|||
import icon from '../../resources/icon.png?asset' |
|||
|
|||
function createWindow() { |
|||
// Create the browser window.
|
|||
const mainWindow = new BrowserWindow({ |
|||
width: 900, |
|||
height: 670, |
|||
show: false, |
|||
autoHideMenuBar: true, |
|||
...(process.platform === 'linux' ? { icon } : {}), |
|||
webPreferences: { |
|||
preload: join(__dirname, '../preload/index.js'), |
|||
sandbox: false |
|||
} |
|||
}) |
|||
|
|||
mainWindow.on('ready-to-show', () => { |
|||
mainWindow.show() |
|||
}) |
|||
|
|||
mainWindow.webContents.setWindowOpenHandler((details) => { |
|||
shell.openExternal(details.url) |
|||
return { action: 'deny' } |
|||
}) |
|||
|
|||
// HMR for renderer base on electron-vite cli.
|
|||
// Load the remote URL for development or the local html file for production.
|
|||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { |
|||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) |
|||
} else { |
|||
mainWindow.loadFile(join(__dirname, '../renderer/index.html')) |
|||
} |
|||
} |
|||
|
|||
// This method will be called when Electron has finished
|
|||
// initialization and is ready to create browser windows.
|
|||
// Some APIs can only be used after this event occurs.
|
|||
app.whenReady().then(() => { |
|||
// Set app user model id for windows
|
|||
electronApp.setAppUserModelId('com.electron') |
|||
|
|||
// Default open or close DevTools by F12 in development
|
|||
// and ignore CommandOrControl + R in production.
|
|||
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
|||
app.on('browser-window-created', (_, window) => { |
|||
optimizer.watchWindowShortcuts(window) |
|||
}) |
|||
|
|||
// IPC test
|
|||
ipcMain.on('ping', () => console.log('pong')) |
|||
|
|||
createWindow() |
|||
|
|||
app.on('activate', function () { |
|||
// On macOS it's common to re-create a window in the app when the
|
|||
// dock icon is clicked and there are no other windows open.
|
|||
if (BrowserWindow.getAllWindows().length === 0) createWindow() |
|||
}) |
|||
}) |
|||
|
|||
// Quit when all windows are closed, except on macOS. There, it's common
|
|||
// for applications and their menu bar to stay active until the user quits
|
|||
// explicitly with Cmd + Q.
|
|||
app.on('window-all-closed', () => { |
|||
if (process.platform !== 'darwin') { |
|||
app.quit() |
|||
} |
|||
}) |
|||
|
|||
// In this file you can include the rest of your app's specific main process
|
|||
// code. You can also put them in separate files and require them here.
|
@ -0,0 +1,20 @@ |
|||
import { contextBridge } from 'electron' |
|||
import { electronAPI } from '@electron-toolkit/preload' |
|||
|
|||
// Custom APIs for renderer
|
|||
const api = {} |
|||
|
|||
// Use `contextBridge` APIs to expose Electron APIs to
|
|||
// renderer only if context isolation is enabled, otherwise
|
|||
// just add to the DOM global.
|
|||
if (process.contextIsolated) { |
|||
try { |
|||
contextBridge.exposeInMainWorld('electron', electronAPI) |
|||
contextBridge.exposeInMainWorld('api', api) |
|||
} catch (error) { |
|||
console.error(error) |
|||
} |
|||
} else { |
|||
window.electron = electronAPI |
|||
window.api = api |
|||
} |
@ -0,0 +1,16 @@ |
|||
<!doctype html> |
|||
<html> |
|||
|
|||
<head> |
|||
<meta charset="UTF-8" /> |
|||
<title>FlexometerSetup is developed by FS</title> |
|||
<meta http-equiv="Content-Security-Policy" |
|||
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" /> |
|||
</head> |
|||
|
|||
<body> |
|||
<div id="root"></div> |
|||
<script type="module" src="/src/main.jsx"></script> |
|||
</body> |
|||
|
|||
</html> |
@ -0,0 +1,17 @@ |
|||
import { Button } from 'antd' |
|||
function App() { |
|||
const ipcHandle = () => window.electron.ipcRenderer.send('ping') |
|||
|
|||
return ( |
|||
<> |
|||
<div> |
|||
<h1>Hello Electron + antd!</h1> |
|||
<Button type="primary" onClick={ipcHandle}> |
|||
Antd Button send Ping to Main |
|||
</Button> |
|||
</div> |
|||
</> |
|||
) |
|||
} |
|||
|
|||
export default App |
@ -0,0 +1,34 @@ |
|||
*, |
|||
*::before, |
|||
*::after { |
|||
box-sizing: border-box; |
|||
margin: 0; |
|||
font-weight: normal; |
|||
} |
|||
|
|||
ul { |
|||
list-style: none; |
|||
} |
|||
|
|||
body { |
|||
min-height: 100vh; |
|||
color: black; |
|||
background: white; |
|||
line-height: 1.6; |
|||
font-family: |
|||
Inter, |
|||
-apple-system, |
|||
BlinkMacSystemFont, |
|||
'Segoe UI', |
|||
Roboto, |
|||
Oxygen, |
|||
Ubuntu, |
|||
Cantarell, |
|||
'Fira Sans', |
|||
'Droid Sans', |
|||
'Helvetica Neue', |
|||
sans-serif; |
|||
text-rendering: optimizeLegibility; |
|||
-webkit-font-smoothing: antialiased; |
|||
-moz-osx-font-smoothing: grayscale; |
|||
} |
After Width: | Height: | Size: 1.3 MiB |
@ -0,0 +1,9 @@ |
|||
import { StrictMode } from 'react' |
|||
import { createRoot } from 'react-dom/client' |
|||
import App from './App' |
|||
import 'antd/dist/reset.css' |
|||
createRoot(document.getElementById('root')).render( |
|||
<StrictMode> |
|||
<App /> |
|||
</StrictMode> |
|||
) |
Loading…
Reference in new issue