Skip to content

Commit eb41399

Browse files
committed
update site
1 parent 23a89b1 commit eb41399

Some content is hidden

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

44 files changed

+3413
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ typings/
6161
dist
6262
lib
6363
es
64+
site-dist
6465

6566
# 备份文件
6667
/components/test/*

package-lock.json

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

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"scripts": {
2525
"start": "NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot",
2626
"test": "karma start test/karma.conf.js --single-run",
27-
"build": "sh build.sh",
27+
"site": "node scripts/run.js site-dist",
28+
"copy": "node scripts/run.js copy-html",
2829
"compile": "node antd-tools/cli/run.js compile",
2930
"dist": "node antd-tools/cli/run.js dist",
3031
"lint": "eslint -c ./.eslintrc --fix --ext .jsx ./components",
@@ -100,6 +101,7 @@
100101
"markdown-it": "^8.4.0",
101102
"marked": "^0.3.7",
102103
"merge2": "^1.2.1",
104+
"mkdirp": "^0.5.1",
103105
"mocha": "^3.2.0",
104106
"postcss": "^6.0.20",
105107
"postcss-loader": "^2.1.2",

scripts/deploy-to-gh-pages.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ if [[ $TRAVIS_BRANCH == "master" && $TRAVIS_PULL_REQUEST == "false" ]]; then
66

77
echo "Starting to update gh-pages\n"
88

9-
rm -rf dist
10-
mkdir dist
9+
rm -rf site-dist
10+
mkdir site-dist
1111

1212
git config --global user.email "[email protected]"
1313
git config --global user.name "Travis"
1414

15-
./node_modules/.bin/webpack --config webpack.site.config.js
15+
npm run site
1616

17-
cd dist
17+
cd site-dist
1818
git init
1919
git add -f .
2020
git commit -m "Travis build"

scripts/gulpfile.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
'use strict'
2+
const webpack = require('webpack')
3+
4+
const path = require('path')
5+
const gulp = require('gulp')
6+
const readline = require('readline')
7+
const fs = require('fs')
8+
9+
const rimraf = require('rimraf')
10+
const mkdirp = require('mkdirp')
11+
12+
const cwd = process.cwd()
13+
14+
function dist (done) {
15+
rimraf.sync(path.join(cwd, 'site-dist'))
16+
process.env.RUN_ENV = 'PRODUCTION'
17+
const webpackConfig = require(path.join(cwd, 'webpack.site.config.js'))
18+
webpack(webpackConfig, (err, stats) => {
19+
if (err) {
20+
console.error(err.stack || err)
21+
if (err.details) {
22+
console.error(err.details)
23+
}
24+
return
25+
}
26+
27+
const info = stats.toJson()
28+
29+
if (stats.hasErrors()) {
30+
console.error(info.errors)
31+
}
32+
33+
if (stats.hasWarnings()) {
34+
console.warn(info.warnings)
35+
}
36+
37+
const buildInfo = stats.toString({
38+
colors: true,
39+
children: true,
40+
chunks: false,
41+
modules: false,
42+
chunkModules: false,
43+
hash: false,
44+
version: false,
45+
})
46+
console.log(buildInfo)
47+
done(0)
48+
})
49+
}
50+
51+
function copyHtml () {
52+
const rl = readline.createInterface({
53+
input: fs.createReadStream(path.join(cwd, 'site/demo.js')),
54+
})
55+
56+
rl.on('line', (line) => {
57+
const name = line.split('antd/')[1].split('/')[0]
58+
console.log('create path:', name)
59+
const toPath1 = `site-dist/components/${name}`
60+
const toPath2 = `site-dist/components/${name}-cn`
61+
rimraf.sync(path.join(cwd, toPath1))
62+
rimraf.sync(path.join(cwd, toPath2))
63+
mkdirp(path.join(cwd, toPath1), function () {
64+
fs.writeFileSync(path.join(cwd, `${toPath1}/index.html`), fs.readFileSync(path.join(cwd, 'site-dist/index.html')))
65+
})
66+
mkdirp(path.join(cwd, toPath2), function () {
67+
fs.writeFileSync(path.join(cwd, `${toPath2}/index.html`), fs.readFileSync(path.join(cwd, 'site-dist/index.html')))
68+
})
69+
})
70+
}
71+
72+
gulp.task('site-dist', (done) => {
73+
dist(() => {
74+
copyHtml()
75+
})
76+
})
77+
gulp.task('copy-html', () => {
78+
copyHtml()
79+
})
80+

scripts/run.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env node
2+
3+
'use strict'
4+
5+
require('colorful').colorful()
6+
const gulp = require('gulp')
7+
const program = require('commander')
8+
9+
program.on('--help', () => {
10+
console.log(' Usage:'.to.bold.blue.color)
11+
console.log()
12+
})
13+
14+
program.parse(process.argv)
15+
16+
const task = program.args[0]
17+
18+
if (!task) {
19+
program.help()
20+
} else {
21+
console.log('scripts run', task)
22+
23+
require('./gulpfile')
24+
25+
gulp.start(task)
26+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<li :class="justCopied ? 'copied' : ''" v-clipboard:copy="text"
3+
v-clipboard:success="onCopied">
4+
<a-icon :type="type" />
5+
<span class='anticon-class'>
6+
<a-badge :dot="isNew">
7+
{{type}}
8+
</a-badge>
9+
</span>
10+
</li>
11+
</template>
12+
<script>
13+
import BaseMixin from 'antd/_util/BaseMixin'
14+
15+
export default {
16+
mixins: [BaseMixin],
17+
props: {
18+
type: String,
19+
isNew: Boolean,
20+
},
21+
data () {
22+
return {
23+
justCopied: false,
24+
text: `<a-icon type="${this.type}" />`,
25+
}
26+
},
27+
methods: {
28+
onCopied () {
29+
this.setState({ justCopied: true }, () => {
30+
setTimeout(() => {
31+
this.setState({ justCopied: false })
32+
}, 2000)
33+
})
34+
},
35+
},
36+
}
37+
</script>

site/components/IconSet/index.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script>
2+
import CopyableIcon from './CopyableIcon'
3+
export default {
4+
props: {
5+
catigory: String,
6+
},
7+
data () {
8+
return {
9+
icons: {
10+
direction: ['step-backward', 'step-forward', 'fast-backward', 'fast-forward', 'shrink', 'arrows-alt', 'down', 'up', 'left', 'right', 'caret-up', 'caret-down', 'caret-left', 'caret-right', 'up-circle', 'down-circle', 'left-circle', 'right-circle', 'up-circle-o', 'down-circle-o', 'right-circle-o', 'left-circle-o', 'double-right', 'double-left', 'verticle-left', 'verticle-right', 'forward', 'backward', 'rollback', 'enter', 'retweet', 'swap', 'swap-left', 'swap-right', 'arrow-up', 'arrow-down', 'arrow-left', 'arrow-right', 'play-circle', 'play-circle-o', 'up-square', 'down-square', 'left-square', 'right-square', 'up-square-o', 'down-square-o', 'left-square-o', 'right-square-o', 'login', 'logout', 'menu-fold', 'menu-unfold'],
11+
suggestion: ['question', 'question-circle-o', 'question-circle', 'plus', 'plus-circle-o', 'plus-circle', 'pause', 'pause-circle-o', 'pause-circle', 'minus', 'minus-circle-o', 'minus-circle', 'plus-square', 'plus-square-o', 'minus-square', 'minus-square-o', 'info', 'info-circle-o', 'info-circle', 'exclamation', 'exclamation-circle-o', 'exclamation-circle', 'close', 'close-circle', 'close-circle-o', 'close-square', 'close-square-o', 'check', 'check-circle', 'check-circle-o', 'check-square', 'check-square-o', 'clock-circle-o', 'clock-circle', 'warning'],
12+
logo: [
13+
'android', 'android-o', 'apple', 'apple-o', 'windows', 'windows-o', 'ie', 'chrome', 'github', 'aliwangwang', 'aliwangwang-o', 'dingding', 'dingding-o',
14+
'weibo-square', 'weibo-circle', 'taobao-circle', 'html5', 'weibo', 'twitter', 'wechat', 'youtube', 'alipay-circle', 'taobao', 'skype', 'qq', 'medium-workmark', 'gitlab', 'medium', 'linkedin', 'google-plus',
15+
'dropbox', 'facebook', 'codepen', 'amazon', 'google', 'codepen-circle', 'alipay', 'ant-design', 'aliyun',
16+
],
17+
other: ['lock', 'unlock', 'area-chart', 'pie-chart', 'bar-chart', 'dot-chart', 'bars', 'book', 'calendar', 'cloud', 'cloud-download', 'code', 'code-o', 'copy', 'credit-card', 'delete', 'desktop', 'download', 'edit', 'ellipsis', 'file', 'file-text', 'file-unknown', 'file-pdf', 'file-word', 'file-excel', 'file-jpg', 'file-ppt', 'file-add', 'folder', 'folder-open', 'folder-add', 'hdd', 'frown', 'frown-o', 'meh', 'meh-o', 'smile', 'smile-o', 'inbox', 'laptop', 'appstore-o', 'appstore', 'line-chart', 'link', 'mail', 'mobile', 'notification', 'paper-clip', 'picture', 'poweroff', 'reload', 'search', 'setting', 'share-alt', 'shopping-cart', 'tablet', 'tag', 'tag-o', 'tags', 'tags-o', 'to-top', 'upload', 'user', 'video-camera', 'home', 'loading', 'loading-3-quarters', 'cloud-upload-o', 'cloud-download-o', 'cloud-upload', 'cloud-o', 'star-o', 'star', 'heart-o', 'heart', 'environment', 'environment-o', 'eye', 'eye-o', 'camera', 'camera-o', 'save', 'team', 'solution', 'phone', 'filter', 'exception', 'export', 'customer-service', 'qrcode', 'scan', 'like', 'like-o', 'dislike', 'dislike-o', 'message', 'pay-circle', 'pay-circle-o', 'calculator', 'pushpin', 'pushpin-o', 'bulb', 'select', 'switcher', 'rocket', 'bell', 'disconnect', 'database', 'compass', 'barcode', 'hourglass', 'key', 'flag', 'layout', 'printer', 'sound', 'usb', 'skin', 'tool', 'sync', 'wifi', 'car', 'schedule', 'user-add', 'user-delete', 'usergroup-add', 'usergroup-delete', 'man', 'woman', 'shop', 'gift', 'idcard', 'medicine-box', 'red-envelope', 'coffee', 'copyright', 'trademark', 'safety', 'wallet', 'bank', 'trophy', 'contacts', 'global', 'shake', 'api', 'fork', 'dashboard', 'form', 'table', 'profile'],
18+
},
19+
newIcons: [
20+
'aliyun',
21+
],
22+
}
23+
},
24+
25+
render () {
26+
const { catigory } = this.$props
27+
const listClassName = {
28+
'anticons-list': true,
29+
clearfix: true,
30+
}
31+
return (
32+
<ul class={listClassName}>
33+
{this.icons[catigory].map(type => (
34+
<CopyableIcon key={type} type={type} isNew={this.newIcons.indexOf(type) >= 0} />
35+
))}
36+
</ul>
37+
)
38+
},
39+
}
40+
</script>

site/components/api.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class='markdown api-container'>
3+
<slot v-if="isZhCN" name="cn"></slot>
4+
<slot v-else></slot>
5+
</div>
6+
</template>
7+
<script>
8+
import { isZhCN } from '../util'
9+
export default {
10+
name: 'api',
11+
data () {
12+
const { name } = this.$route.params
13+
return {
14+
isZhCN: isZhCN(name),
15+
}
16+
},
17+
}
18+
</script>

site/components/demo.vue

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<script>
2+
import * as AllDemo from '../demo'
3+
import Header from './header'
4+
import zhCN from 'antd/locale-provider/zh_CN'
5+
import enUS from 'antd/locale-provider/default'
6+
import _ from 'lodash'
7+
import { isZhCN } from '../util'
8+
9+
export default {
10+
render () {
11+
let { name } = this.$route.params
12+
const lang = isZhCN(name) ? 'cn' : 'us'
13+
name = name.replace('-cn', '')
14+
const titleMap = {}
15+
const menuConfig = {
16+
General: [],
17+
Layout: [],
18+
Navigation: [],
19+
'Data Entry': [],
20+
'Data Display': [],
21+
Feedback: [],
22+
Other: [],
23+
}
24+
for (const [title, d] of Object.entries(AllDemo)) {
25+
const type = d.type || 'Other'
26+
const key = `${title.replace(/(\B[A-Z])/g, '-$1').toLowerCase()}`
27+
titleMap[key] = title
28+
menuConfig[type] = menuConfig[type] || []
29+
menuConfig[type].push(d)
30+
}
31+
const Demo = AllDemo[titleMap[name]]
32+
const MenuGroup = []
33+
for (const [type, menus] of Object.entries(menuConfig)) {
34+
const MenuItems = []
35+
_.sortBy(menus, ['title']).forEach(({ title, subtitle }) => {
36+
const linkValue = lang === 'cn'
37+
? [<span>{title}</span>, <span class='chinese'>{subtitle}</span>]
38+
: [<span>{title}</span>]
39+
let key = `${title.replace(/(\B[A-Z])/g, '-$1').toLowerCase()}`
40+
if (lang === 'cn') {
41+
key = `${key}-cn`
42+
}
43+
MenuItems.push(<a-menu-item key={key}>
44+
<router-link to={{ path: `/ant-design/components/${key}` }}>{linkValue}</router-link>
45+
</a-menu-item>)
46+
})
47+
MenuGroup.push(<a-menu-item-group title={type}>{MenuItems}</a-menu-item-group>)
48+
}
49+
let locale = zhCN
50+
if (lang !== 'cn') {
51+
locale = enUS
52+
}
53+
return (
54+
<div class='page-wrapper'>
55+
<Header num={Object.keys(AllDemo).length}/>
56+
<a-locale-provider locale={locale}>
57+
<div class='main-wrapper'>
58+
<a-row>
59+
<a-col xxl={4} xl={5} lg={5} md={6} sm={24} xs={24}>
60+
<a-menu
61+
class='aside-container menu-site'
62+
selectedKeys={[name]}
63+
defaultOpenKeys={['Components']}
64+
inlineIndent={40}
65+
mode='inline'>
66+
<a-sub-menu title='Components' key='Components'>
67+
{MenuGroup}
68+
</a-sub-menu>
69+
</a-menu>
70+
</a-col>
71+
<a-col xxl={20} xl={19} lg={19} md={18} sm={0} xs={0}>
72+
<div class='content main-container'>
73+
{Demo ? <Demo key={lang}/> : '正在紧急开发中...'}
74+
</div>
75+
</a-col>
76+
</a-row>
77+
</div>
78+
</a-locale-provider>
79+
</div>
80+
)
81+
},
82+
}
83+
</script>

0 commit comments

Comments
 (0)