fix: 修改模板
This commit is contained in:
parent
4cf5a6d2f6
commit
ae3c4abac2
3
.prettierignore
Normal file
3
.prettierignore
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
.umi
|
||||
.umi-production
|
8
.prettierrc
Normal file
8
.prettierrc
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"proseWrap": "never",
|
||||
"overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }],
|
||||
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"]
|
||||
}
|
25
.umirc.ts
25
.umirc.ts
@ -1,5 +1,5 @@
|
||||
import { defineConfig } from 'umi';
|
||||
import { Platform, createTargets } from '@umijs/plugin-electron';
|
||||
import { defineConfig } from "umi";
|
||||
import { Platform, createTargets } from "@umijs/plugin-electron";
|
||||
|
||||
// example: mac & windows
|
||||
const targets = createTargets([Platform.WINDOWS]);
|
||||
@ -8,14 +8,23 @@ const targets = createTargets([Platform.WINDOWS]);
|
||||
// const targets = Platform.MAC.createTarget(['dmg'], Arch.arm64);
|
||||
|
||||
export default defineConfig({
|
||||
npmClient: 'yarn',
|
||||
plugins: ['@umijs/plugin-electron'],
|
||||
npmClient: "pnpm",
|
||||
plugins: ["@umijs/plugin-electron", "@umijs/plugins/dist/dva"],
|
||||
// metas: [
|
||||
// {
|
||||
// 'http-equiv': 'Content-Security-Policy',
|
||||
// content: "default-src 'none'"
|
||||
// }
|
||||
// ],
|
||||
electron: {
|
||||
builder: {
|
||||
targets
|
||||
targets,
|
||||
config: {}
|
||||
},
|
||||
extraDevFiles: {
|
||||
// 'xxxx.js' : fs.readFileSync('xxxx.js','utf-8'),
|
||||
}
|
||||
extraDevFiles: {}
|
||||
},
|
||||
define: {
|
||||
APP_ENV: "dev"
|
||||
},
|
||||
dva: {},
|
||||
});
|
||||
|
2
jest-setup.ts
Normal file
2
jest-setup.ts
Normal file
@ -0,0 +1,2 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import 'umi/test-setup'
|
27
jest.config.ts
Normal file
27
jest.config.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { Config, configUmiAlias, createConfig } from 'umi/test';
|
||||
|
||||
export default async () => {
|
||||
try{
|
||||
return (await configUmiAlias({
|
||||
...createConfig({
|
||||
target: 'browser',
|
||||
jsTransformer: 'esbuild',
|
||||
// config opts for esbuild , it will pass to esbuild directly
|
||||
jsTransformerOpts: { jsx: 'automatic' },
|
||||
}),
|
||||
|
||||
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{ts,js,tsx,jsx}',
|
||||
'!src/.umi/**',
|
||||
'!src/.umi-test/**',
|
||||
'!src/.umi-production/**'
|
||||
],
|
||||
// if you require some es-module npm package, please uncomment below line and insert your package name
|
||||
// transformIgnorePatterns: ['node_modules/(?!.*(lodash-es|your-es-pkg-name)/)']
|
||||
})) as Config.InitialOptions;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw e;
|
||||
}
|
||||
};
|
29
package.json
29
package.json
@ -6,11 +6,16 @@
|
||||
},
|
||||
"description": "eggKnife-electron的客户端模板",
|
||||
"scripts": {
|
||||
"dev": "umi dev",
|
||||
"build": "umi build",
|
||||
"postinstall": "umi setup",
|
||||
"setup": "umi setup",
|
||||
"start": "npm run dev"
|
||||
"dev": "cross-env umi dev",
|
||||
"build": "cross-env NODE_ENV=production umi build",
|
||||
"postinstall": "cross-env umi setup",
|
||||
"setup": "cross-env umi setup",
|
||||
"start": "cross-env npm run dev",
|
||||
"test": "cross-env TS_NODE_TRANSPILE_ONLY=yes jest --passWithNoTests"
|
||||
},
|
||||
"build": {
|
||||
"productName": "测试",
|
||||
"appId": "nicecode"
|
||||
},
|
||||
"dependencies": {
|
||||
"antd": "^5.16.1",
|
||||
@ -25,7 +30,19 @@
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"@umijs/plugin-electron": "^0.2.0",
|
||||
"electron": "29.1.6",
|
||||
"typescript": "^4.1.2"
|
||||
"typescript": "^5",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-organize-imports": "^3.2.2",
|
||||
"prettier-plugin-packagejson": "^2.4.3",
|
||||
"jest": "^29",
|
||||
"@types/jest": "^29",
|
||||
"ts-node": "^10",
|
||||
"cross-env": "^7",
|
||||
"jest-environment-jsdom": "^29",
|
||||
"@testing-library/jest-dom": "^5",
|
||||
"@testing-library/react": "^14",
|
||||
"@types/testing-library__jest-dom": "^5.14.5",
|
||||
"@umijs/plugins": "^4.1.8"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
|
2716
pnpm-lock.yaml
2716
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
12
src/index.html
Normal file
12
src/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>形体结构化视频数据分析系统</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<webview id="" src="http://10.0.0.96:30003/" />
|
||||
</body>
|
||||
</html>
|
@ -2,11 +2,15 @@ import { BrowserWindowConstructorOptions } from 'electron';
|
||||
|
||||
export default {
|
||||
browserWindow: {
|
||||
titleBarStyle: process.platform === 'win32' ? 'hidden' : 'hiddenInset',
|
||||
title: 'nicecode 客户端模板',
|
||||
titleBarOverlay: {
|
||||
color: '#2f3241',
|
||||
symbolColor: '#74b1be',
|
||||
height: 48
|
||||
},
|
||||
maximizable: false,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
enableRemoteModule: true
|
||||
enableRemoteModule: true,
|
||||
}
|
||||
} as BrowserWindowConstructorOptions
|
||||
};
|
1
src/main/forks/init.ts
Normal file
1
src/main/forks/init.ts
Normal file
@ -0,0 +1 @@
|
||||
console.log('123', 123)
|
@ -1 +1,114 @@
|
||||
getBrowserWindowRuntime().webContents.openDevTools();
|
||||
import { app, Menu } from 'electron';
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
getBrowserWindowRuntime().webContents.openDevTools();
|
||||
}
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
|
||||
const template = [
|
||||
// { role: 'appMenu' }
|
||||
...(isMac
|
||||
? [{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{ label: '关于', role: 'about' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'services' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'hide' },
|
||||
{ role: 'hideOthers' },
|
||||
{ role: 'unhide' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
}]
|
||||
: []),
|
||||
// { role: 'fileMenu' }
|
||||
{
|
||||
label: '文件',
|
||||
submenu: [
|
||||
isMac ? { label: '退出', role: 'close' } : { label: '退出', role: 'quit' }
|
||||
]
|
||||
},
|
||||
// { role: 'editMenu' }
|
||||
{
|
||||
label: '编辑',
|
||||
submenu: [
|
||||
{ role: 'undo' },
|
||||
{ role: 'redo' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'cut' },
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' },
|
||||
...(isMac
|
||||
? [
|
||||
{ role: 'pasteAndMatchStyle' },
|
||||
{ role: 'delete' },
|
||||
{ role: 'selectAll' },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{ role: 'startSpeaking' },
|
||||
{ role: 'stopSpeaking' }
|
||||
]
|
||||
}
|
||||
]
|
||||
: [
|
||||
{ role: 'delete' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'selectAll' }
|
||||
])
|
||||
]
|
||||
},
|
||||
// { role: 'viewMenu' }
|
||||
{
|
||||
label: '视图',
|
||||
submenu: [
|
||||
{ label: '重新加载', role: 'reload' },
|
||||
{ label: '强制重新加载', role: 'forceReload' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'resetZoom' },
|
||||
{ role: 'zoomIn' },
|
||||
{ role: 'zoomOut' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'togglefullscreen' }
|
||||
]
|
||||
},
|
||||
// { role: 'windowMenu' }
|
||||
{
|
||||
label: '窗口',
|
||||
submenu: [
|
||||
{ role: 'minimize' },
|
||||
{ role: 'zoom' },
|
||||
...(isMac
|
||||
? [
|
||||
{ type: 'separator' },
|
||||
{ role: 'front' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'window' }
|
||||
]
|
||||
: [
|
||||
{ role: 'close' }
|
||||
])
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{ label: '控制台', role: 'toggleDevTools' },
|
||||
{
|
||||
label: '更多',
|
||||
click: async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { shell } = require('electron')
|
||||
await shell.openExternal('https://electronjs.org')
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
const menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
@ -1,4 +1,4 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { ipcMain, app } from 'electron';
|
||||
|
||||
ipcMain.handle('getPlatform', () => {
|
||||
return `hi, i'm from ${process.platform}`;
|
||||
|
@ -1,19 +1,19 @@
|
||||
import { app, ipcMain } from 'electron';
|
||||
import fs from 'fs';
|
||||
import path from 'node:path';
|
||||
// import fs from 'fs';
|
||||
// import path from 'node:path';
|
||||
|
||||
ipcMain.on('uploadFile', (event, filePaths: string[]) => {
|
||||
// 获取用户当前文件夹路径
|
||||
// console.log('app', app.getPath('userData'))
|
||||
console.log('app', app.getGPUInfo('basic'))
|
||||
// const saveDirectoryPath = await app.getPath('downloads');
|
||||
for (let i = 0; i < filePaths.length; i++) {
|
||||
const fileName = path.basename(filePaths[i]);
|
||||
const targetFilePath = path.join(__dirname, fileName);
|
||||
const fileStream = fs.createWriteStream(targetFilePath);
|
||||
fileStream.write(fs.readFileSync(filePaths[i]));
|
||||
fileStream.end();
|
||||
console.log('Uploaded file saved at:', targetFilePath);
|
||||
}
|
||||
// for (let i = 0; i < filePaths.length; i++) {
|
||||
// const fileName = path.basename(filePaths[i]);
|
||||
// const targetFilePath = path.join(__dirname, fileName);
|
||||
// const fileStream = fs.createWriteStream(targetFilePath);
|
||||
// fileStream.write(fs.readFileSync(filePaths[i]));
|
||||
// fileStream.end();
|
||||
// console.log('Uploaded file saved at:', targetFilePath);
|
||||
// }
|
||||
// const fileSize = fs.statSync(filePath).size;
|
||||
// let uploadedSize = 0;
|
||||
|
||||
|
1
src/main/typing.d.ts
vendored
1
src/main/typing.d.ts
vendored
@ -2,4 +2,5 @@ import { BrowserWindow } from 'electron';
|
||||
|
||||
declare global {
|
||||
export function getBrowserWindowRuntime(): BrowserWindow;
|
||||
const APP_ENV: string
|
||||
}
|
||||
|
21
src/models/count.ts
Normal file
21
src/models/count.ts
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
export default {
|
||||
namespace: 'count',
|
||||
state: {
|
||||
num: 0,
|
||||
},
|
||||
reducers: {
|
||||
add(state: any) {
|
||||
state.num += 1;
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*addAsync(_action: any, { put }: any) {
|
||||
yield delay(1000);
|
||||
yield put({ type: 'add' });
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Button } from 'antd';
|
||||
import avatar from '../assets/avatar.jpg';
|
||||
|
||||
export default function HomePage() {
|
||||
@ -10,13 +11,13 @@ export default function HomePage() {
|
||||
<p>
|
||||
To get started, edit <code>pages/index.tsx</code> and save to reload.
|
||||
</p>
|
||||
<button
|
||||
<Button
|
||||
onClick={async () => {
|
||||
window.alert(await window.$api.getPlatform());
|
||||
}}
|
||||
>
|
||||
what is my platform?
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
0
src/utils/index.ts
Normal file
0
src/utils/index.ts
Normal file
Loading…
Reference in New Issue
Block a user