Skip to content

Commit c768252

Browse files
committed
feat: add dashboard
1 parent 9d2c437 commit c768252

50 files changed

Lines changed: 12318 additions & 137 deletions

Some content is hidden

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

dev-dashboard-entry.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
3+
<head>
4+
<style>
5+
html,
6+
body {
7+
margin: 0;
8+
padding: 0;
9+
}
10+
</style>
11+
</head>
12+
13+
<body>
14+
<div id="root"></div>
15+
<script src="./built/commands/dev/dashboard/client/index.js"></script>
16+
</body>
17+
18+
</html>

package-lock.json

Lines changed: 10859 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "pri",
3-
"version": "0.0.29",
3+
"version": "0.0.30",
44
"types": "src/index.ts",
55
"main": "built/index.js",
66
"scripts": {
77
"start": "tsc -w",
8-
"build": "rm -rf built && rm -rf .cache && tsc",
9-
"prepublishOnly": "npm run build"
8+
"build": "rm -rf built && rm -rf .cache && tsc && npm run build-dashboard",
9+
"prepublishOnly": "npm run build",
10+
"build-dashboard": "parcel build --out-dir built/bundle ./src/commands/dev/dashboard/client/index.tsx"
1011
},
1112
"bin": {
1213
"pri": "built/bin.js"
@@ -18,33 +19,54 @@
1819
"@babel/core": "^7.0.0-beta.39",
1920
"@babel/preset-env": "^7.0.0-beta.39",
2021
"@babel/preset-react": "^7.0.0-beta.39",
22+
"@koa/cors": "^2.2.1",
2123
"@types/chokidar": "^1.7.4",
2224
"@types/commander": "^2.12.2",
2325
"@types/fs-extra": "^5.0.0",
26+
"@types/koa": "^2.0.44",
27+
"@types/koa-route": "^3.2.3",
2428
"@types/lodash": "^4.14.100",
2529
"@types/node": "^9.4.0",
2630
"@types/opn": "^5.1.0",
2731
"@types/ora": "^1.3.1",
32+
"@types/prettier": "^1.10.0",
2833
"@types/react-dom": "^16.0.3",
2934
"@types/react-loadable": "^5.3.2",
3035
"@types/react-router-dom": "^4.2.3",
36+
"@types/socket.io": "^1.4.31",
37+
"@types/socket.io-client": "^1.4.32",
3138
"@types/update-notifier": "^2.0.0",
3239
"@types/yargs": "^10.0.1",
40+
"antd": "^3.2.1",
3341
"babel-preset-env": "^1.6.1",
42+
"body-parser": "^1.18.2",
3443
"chokidar": "^2.0.1",
3544
"colors": "^1.1.2",
3645
"commander": "^2.13.0",
46+
"cors": "^2.8.4",
47+
"dob": "^2.5.8",
48+
"dob-react": "^2.4.10",
3749
"fs-extra": "^5.0.0",
50+
"koa": "^2.5.0",
51+
"koa-compress": "^2.0.0",
52+
"koa-mount": "^3.0.0",
53+
"koa-route": "^3.2.0",
54+
"koa-static": "^4.0.2",
3855
"lodash": "^4.17.4",
56+
"node-forge": "^0.7.1",
3957
"opn": "^5.2.0",
4058
"ora": "^1.4.0",
4159
"parcel-bundler": "^1.5.1",
4260
"portfinder": "^1.0.13",
61+
"prettier": "^1.10.2",
4362
"react": "^16.2.0",
4463
"react-dom": "^16.2.0",
4564
"react-hot-loader": "^3.1.3",
4665
"react-loadable": "^5.3.1",
4766
"react-router-dom": "^4.2.2",
67+
"socket.io": "^2.0.4",
68+
"socket.io-client": "^2.0.4",
69+
"styled-components": "^3.1.6",
4870
"ts-loader": "^3.4.0",
4971
"tslint": "^5.9.1",
5072
"typescript": "^2.7.1",

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ Production deployment. By default the dist folder is `./dist`.
152152

153153
```typescript
154154
class IConfig {
155+
/**
156+
* Title for html <title>
157+
*/
158+
public title?: string = "pri"
155159
/**
156160
* Dist dir path when running: npm run build | pri build
157161
*/
@@ -401,4 +405,4 @@ Production deployment. By default the dist folder is `./dist`.
401405
- PWA support.
402406
- Tree Shaking.
403407
- Scope Hoist.
404-
- Prefetch router.
408+
- Prefetching.

src/commands/build/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ensureFiles } from "../../utils/ensure-files"
77
import { spinner } from "../../utils/log"
88
import { findNearestNodemodules } from "../../utils/npm-finder"
99
import { getConfig } from "../../utils/project-config"
10+
import { IConfig } from "../../utils/project-config-interface"
1011

1112
const projectRootPath = process.cwd();
1213

@@ -29,22 +30,22 @@ export const CommandBuild = async () => {
2930
}
3031

3132
// Run parcel
32-
execSync(`${findNearestNodemodules()}/.bin/parcel build ${entryPath} --out-dir ${path.join(projectRootPath, config.distDir || "dist")} ${publicUrl} --no-cache`, {
33+
execSync(`${findNearestNodemodules()}/.bin/parcel build ${entryPath} --out-dir ${path.join(projectRootPath, config.distDir || "dist")} ${publicUrl}`, {
3334
stdio: "inherit",
3435
cwd: __dirname
3536
});
3637

37-
createEntryHtmlFile("/entry.js")
38+
createEntryHtmlFile("/entry.js", config)
3839
}
3940

40-
function createEntryHtmlFile(entryPath: string) {
41+
function createEntryHtmlFile(entryPath: string, config: IConfig) {
4142
const htmlPath = path.join(projectRootPath, "dist/index.html")
4243

4344
fs.outputFileSync(htmlPath, `
4445
<html>
4546
4647
<head>
47-
<title>Pri dev</title>
48+
<title>${config.title}</title>
4849
4950
<style>
5051
html,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as React from "react"
2+
3+
export default (size: number) => (
4+
<svg viewBox="0 0 1024 1024" width={size} height={size}>
5+
<path d="M512 1008C238.064 1008 16 785.936 16 512S238.064 16 512 16s496 222.064 496 496S785.936 1008 512 1008zM512 78C272.304 78 78 272.304 78 512S272.304 946 512 946 946 751.696 946 512 751.696 78 512 78zM714.096 542.272 542.272 542.272l0 171.824c0 16.72-13.552 30.272-30.272 30.272s-30.272-13.552-30.272-30.272L481.728 542.272 309.904 542.272c-16.72 0-30.272-13.552-30.272-30.272 0-16.72 13.552-30.272 30.272-30.272l171.824 0L481.728 309.904c0-16.72 13.552-30.272 30.272-30.272s30.272 13.552 30.272 30.272l0 171.824 171.824 0c16.72 0 30.272 13.552 30.272 30.272C744.368 528.72 730.816 542.272 714.096 542.272z" />
6+
</svg>
7+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from "react"
2+
import * as ReactDOM from "react-dom"
3+
import * as Styled from "./icon.style"
4+
import * as typings from "./icon.type"
5+
6+
import add from "../assets/add"
7+
8+
const iconMap = new Map<string, (size: number) => React.ReactElement<any>>()
9+
iconMap.set("add", add)
10+
11+
export class Icon extends React.Component<typings.Props, typings.State> {
12+
public static defaultProps = new typings.Props()
13+
public state = new typings.State()
14+
15+
public render() {
16+
return (
17+
<Styled.Container className={this.props.className}>
18+
{iconMap.get(this.props.type)(this.props.size)}
19+
</Styled.Container>
20+
)
21+
}
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import styled from "styled-components"
2+
3+
export const Container = styled.div`
4+
display: flex;
5+
justify-content: center;
6+
align-items: center;
7+
`
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as React from "react"
2+
3+
export class Props {
4+
/**
5+
* 图标类型
6+
*/
7+
public type?: string = "close"
8+
/**
9+
* 图标大小
10+
*/
11+
public size?: number = 20
12+
public className?: string = null
13+
}
14+
15+
export class State {
16+
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Icon as default } from "./icon/icon.component"

0 commit comments

Comments
 (0)