Skip to content

Commit 5c96a59

Browse files
committed
feat: init
0 parents  commit 5c96a59

47 files changed

Lines changed: 9424 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:import/recommended",
12+
"plugin:import/electron",
13+
"plugin:import/typescript"
14+
],
15+
"parser": "@typescript-eslint/parser"
16+
}

.gitignore

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
.DS_Store
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# TypeScript cache
43+
*.tsbuildinfo
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
.env.test
63+
64+
# parcel-bundler cache (https://parceljs.org/)
65+
.cache
66+
67+
# next.js build output
68+
.next
69+
70+
# nuxt.js build output
71+
.nuxt
72+
73+
# vuepress build output
74+
.vuepress/dist
75+
76+
# Serverless directories
77+
.serverless/
78+
79+
# FuseBox cache
80+
.fusebox/
81+
82+
# DynamoDB Local files
83+
.dynamodb/
84+
85+
# Webpack
86+
.webpack/
87+
88+
# Vite
89+
.vite/
90+
91+
# Electron-Forge
92+
out/

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "all",
8+
"bracketSpacing": true,
9+
"jsxBracketSameLine": false,
10+
"arrowParens": "avoid"
11+
}

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Click Command
2+
3+
**⚡️ Instead of typing a command, click it.**
4+
5+
## 创建项目
6+
7+
```sh
8+
yarn create electron-app test-forge-ts --template=webpack-typescript
9+
```
10+
11+
## development
12+
13+
开发工具区分 dev prod,使用 isDev。
14+
15+
业务代码中,使用 app.isPackaged。

forge.config.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { ForgeConfig } from '@electron-forge/shared-types';
2+
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
3+
import { MakerZIP } from '@electron-forge/maker-zip';
4+
import { MakerDeb } from '@electron-forge/maker-deb';
5+
import { MakerRpm } from '@electron-forge/maker-rpm';
6+
import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
7+
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
8+
9+
import { mainConfig } from './webpack.main.config';
10+
import { rendererConfig } from './webpack.renderer.config';
11+
12+
const config: ForgeConfig = {
13+
packagerConfig: {
14+
asar: true,
15+
},
16+
rebuildConfig: {},
17+
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})],
18+
plugins: [
19+
new AutoUnpackNativesPlugin({}),
20+
new WebpackPlugin({
21+
mainConfig,
22+
renderer: {
23+
config: rendererConfig,
24+
entryPoints: [
25+
{
26+
html: './src/index.html',
27+
js: './src/renderer.ts',
28+
name: 'main_window',
29+
preload: {
30+
js: './src/preload.ts',
31+
},
32+
},
33+
],
34+
},
35+
}),
36+
],
37+
};
38+
39+
export default config;

package.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "click-command",
3+
"productName": "ClickCommand",
4+
"version": "0.3.0",
5+
"description": "My Electron application description",
6+
"main": ".webpack/main",
7+
"scripts": {
8+
"dev": "DEV=y electron-forge start",
9+
"package": "electron-forge package",
10+
"make": "electron-forge make",
11+
"publish": "electron-forge publish",
12+
"lint": "eslint --ext .ts,.tsx ."
13+
},
14+
"keywords": [],
15+
"author": {
16+
"name": "yulitao",
17+
"email": "yult123@qq.com"
18+
},
19+
"license": "MIT",
20+
"devDependencies": {
21+
"@electron-forge/cli": "^6.4.1",
22+
"@electron-forge/maker-deb": "^6.4.1",
23+
"@electron-forge/maker-rpm": "^6.4.1",
24+
"@electron-forge/maker-squirrel": "^6.4.1",
25+
"@electron-forge/maker-zip": "^6.4.1",
26+
"@electron-forge/plugin-auto-unpack-natives": "^6.4.1",
27+
"@electron-forge/plugin-webpack": "^6.4.1",
28+
"@types/lodash-es": "^4.17.10",
29+
"@types/node": "18",
30+
"@types/react": "18.2",
31+
"@types/react-dom": "18.2",
32+
"@types/uuid": "^9.0.7",
33+
"@typescript-eslint/eslint-plugin": "^5.0.0",
34+
"@typescript-eslint/parser": "^5.0.0",
35+
"@vercel/webpack-asset-relocator-loader": "1.7.3",
36+
"aws-sdk": "^2.1498.0",
37+
"css-loader": "^6.0.0",
38+
"electron": "26.1.0",
39+
"eslint": "^8.0.1",
40+
"eslint-plugin-import": "^2.25.0",
41+
"fork-ts-checker-webpack-plugin": "^7.2.13",
42+
"mock-aws-s3": "^4.0.2",
43+
"nock": "^13.3.8",
44+
"node-loader": "^2.0.0",
45+
"prettier": "^3.0.3",
46+
"style-loader": "^3.0.0",
47+
"ts-loader": "^9.2.2",
48+
"ts-node": "^10.0.0",
49+
"typescript": "~4.5.4"
50+
},
51+
"dependencies": {
52+
"@arco-design/web-react": "^2.55.0",
53+
"@monaco-editor/react": "^4.6.0",
54+
"dayjs": "1.10.5",
55+
"electron-squirrel-startup": "^1.0.0",
56+
"lodash-es": "^4.17.21",
57+
"react": "18.2",
58+
"react-dom": "18.2",
59+
"sqlite": "^5.0.1",
60+
"sqlite3": "^5.1.6",
61+
"uuid": "^9.0.1"
62+
}
63+
}

src/components/AppList.tsx

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import classNames from "classnames";
2+
import sunglasses from "public/img/svg/011-sunglasses.svg";
3+
import compass from "public/img/svg/039-compass.svg";
4+
import beach from "public/img/svg/045-beach.svg";
5+
import hat from "public/img/svg/006-fedora-hat.svg";
6+
import sailBoat from "public/img/svg/048-sail-boat.svg";
7+
import React, { useMemo, CSSProperties } from "react";
8+
import { NavLink } from "react-router-dom";
9+
10+
const appExecutor = [
11+
{
12+
id: "executor",
13+
name: "Executor",
14+
icon: hat,
15+
menu: [
16+
{
17+
name: "Host List",
18+
url: "host",
19+
},
20+
{
21+
name: "Action List",
22+
url: "action",
23+
},
24+
{
25+
name: "Execution List",
26+
url: "execution",
27+
},
28+
],
29+
},
30+
];
31+
32+
const appOthersArr = [
33+
{
34+
id: "k8s",
35+
name: "K8s Partner",
36+
icon: compass,
37+
menu: [
38+
{
39+
name: "Cluster List",
40+
url: "cluster",
41+
},
42+
{
43+
name: "Dashboard",
44+
url: "dashboard",
45+
},
46+
],
47+
},
48+
{
49+
id: "helm",
50+
name: "Helm",
51+
icon: sailBoat,
52+
menu: [],
53+
},
54+
{
55+
id: "http-echo",
56+
name: "HTTP Echo",
57+
icon: sunglasses,
58+
menu: [],
59+
},
60+
{
61+
id: "chat",
62+
name: "Chat",
63+
icon: beach,
64+
menu: [],
65+
},
66+
];
67+
68+
let appArr: typeof appExecutor = [];
69+
70+
if (WEBPACK_DEFINE_APPS === "executor") {
71+
appArr = appExecutor;
72+
} else {
73+
appArr = appExecutor.concat(appOthersArr);
74+
}
75+
76+
export { appArr };
77+
78+
export default function AppList({
79+
className,
80+
column = 4,
81+
style,
82+
}: {
83+
column?: number;
84+
className?: string;
85+
style?: CSSProperties;
86+
}) {
87+
const widthPercentage = useMemo(() => {
88+
return (column * 100) / 24 + "%";
89+
}, [column]);
90+
91+
return (
92+
<ul
93+
className={classNames("dpfx mono flexWrap", className)}
94+
style={{ ...style }}
95+
>
96+
{appArr.map((appObj) => (
97+
<li
98+
key={appObj.name}
99+
className="borderBox"
100+
style={{ width: widthPercentage, padding: 8 }}
101+
>
102+
<NavLink
103+
to={`/app/${appObj.id}`}
104+
className="cursorPointer dpbk"
105+
style={{
106+
border: "1px solid lightgrey",
107+
padding: "8px 10px",
108+
borderRadius: 20,
109+
}}
110+
activeStyle={{ border: "1px solid blue" }}
111+
>
112+
<img
113+
src={appObj.icon}
114+
className="dpbk mxAuto my8"
115+
width="45"
116+
alt={appObj.name}
117+
/>
118+
<div className="textCenter">
119+
<span className="fs16">{appObj.name}</span>
120+
</div>
121+
</NavLink>
122+
</li>
123+
))}
124+
</ul>
125+
);
126+
}

src/components/Box.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Props } from '@/typing';
2+
3+
export default function Box({ children, ...rest }: Props) {
4+
return (
5+
<section
6+
{...rest}
7+
style={{
8+
borderRadius: 12,
9+
boxShadow: '0 0 6px 1px lightgrey',
10+
backgroundColor: '#fefefe',
11+
...rest.style,
12+
}}
13+
>
14+
{children}
15+
</section>
16+
);
17+
}

0 commit comments

Comments
 (0)