Skip to content

Commit 7bd4ceb

Browse files
author
levy
committed
Merge branch 'dev'
2 parents c222212 + 5fdf8c6 commit 7bd4ceb

File tree

16 files changed

+358
-107
lines changed

16 files changed

+358
-107
lines changed

.travis.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,21 @@ install:
1111
script:
1212
- yarn test
1313
- yarn build:release
14-
cache: yarn
14+
- yarn deploy
15+
cache:
16+
- yarn
17+
- directories:
18+
- release/nuxt-element-dashboard/node_modules
19+
- release/nuxt-multiple-spa/node_modules
20+
- release/nuxt-vant/node_modules
1521
deploy:
22+
- provider: pages
23+
skip_cleanup: true
24+
github_token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
25+
keep_history: true
26+
local-dir: dist
27+
on:
28+
branch: master
1629
- provider: script
1730
skip_cleanup: true
1831
script: npx semantic-release

bin/deploy/build.js

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#!/usr/bin/env node
2+
const path = require('path')
3+
const glob = require('glob')
4+
const fse = require('fs-extra')
5+
const _ = require('lodash')
6+
const spawn = require('cross-spawn')
7+
const env = require('./env.json')
8+
9+
const deployDir = (name = '') => path.join(__dirname, '../../dist', name)
10+
const releaseDir = path.join(__dirname, '../../release')
11+
12+
const templateList = glob.sync('*', {
13+
cwd: releaseDir,
14+
ignore: '*.zip'
15+
})
16+
17+
/**
18+
*create the index.html for templates
19+
*
20+
* @param {Array} [data=[]] templateList array
21+
* @param {String} target target path
22+
*/
23+
function buildIndex(data = [], target) {
24+
let html = fse.readFileSync(path.join(__dirname, './index.html'), { encoding: 'utf-8' })
25+
const complied = _.template(html)
26+
html = complied({ data })
27+
fse.writeFileSync(target, html)
28+
}
29+
30+
/**
31+
*create a child_process with promise
32+
*
33+
* @param {String} name process name for log
34+
* @param {*} args spawn arguments
35+
* @returns {Promise}
36+
*/
37+
function createPs(name, ...args) {
38+
return new Promise((resolve, reject) => {
39+
const ps = spawn(...args)
40+
ps.on('error', console.trace)
41+
ps.on('close', (code) => {
42+
if (code !== 0) {
43+
console.log(`${name} build process exited with code ${code}`)
44+
reject(code)
45+
}
46+
resolve(code)
47+
})
48+
})
49+
}
50+
51+
/**
52+
* @class BuildProcess
53+
*/
54+
class BuildProcess {
55+
/**
56+
*Creates an instance of BuildProcess, which use to run nuxt build
57+
* @param {String} templateName framework tempalte name, used to a folder name
58+
* @param {Object} [options={}] spawn options
59+
* @memberof BuildProcess
60+
*/
61+
constructor(templateName, options = {}) {
62+
const { env = {}, ...opts } = options
63+
this.folderName = templateName
64+
this.options = {
65+
cwd: path.join(releaseDir, templateName),
66+
env: {
67+
API_SERVER: 'https://easy-mock.com/mock/5c1b3895fe5907404e654045/femessage-mock',
68+
...process.env,
69+
...env,
70+
PUBLIC_PATH: `${process.env.PUBLIC_PATH || ''}/${this.folderName}`
71+
},
72+
...opts
73+
}
74+
}
75+
76+
/**
77+
*install dependents
78+
*
79+
* @param {Object} options
80+
* @returns {Promise} spawn options
81+
* @memberof BuildProcess
82+
*/
83+
installDeps(options) {
84+
const action = `${this.folderName} install`
85+
console.log(action + 'ing...')
86+
return createPs(action, 'yarn', ['install'], { ...this.options, ...options })
87+
}
88+
89+
/**
90+
*build nuxt project
91+
*
92+
* @param {Object} options
93+
* @returns {Promise}
94+
* @memberof BuildProcess
95+
*/
96+
build(options) {
97+
const action = `${this.folderName} build`
98+
console.log(action + 'ing...')
99+
return createPs(action, 'yarn', ['build'], { ...this.options, ...options })
100+
}
101+
102+
/**
103+
*move some file, because the assets path is not correct after build success
104+
*
105+
* @memberof BuildProcess
106+
*/
107+
moveToDist() {
108+
const targetDir = deployDir(this.folderName)
109+
const sourceDir = path.join(this.options.cwd, 'dist')
110+
const assetsDir = `${sourceDir}/${this.folderName}`
111+
// move assets out
112+
const assetsList = glob.sync('**', {
113+
cwd: assetsDir,
114+
nodir: true
115+
})
116+
assetsList.forEach(file => fse.moveSync(`${assetsDir}/${file}`, `${sourceDir}/${file}`, { overwrite: true }))
117+
fse.removeSync(assetsDir)
118+
// move to dist
119+
fse.moveSync(sourceDir, targetDir, { overwrite: true })
120+
}
121+
122+
/**
123+
*the total process of build a nuxt project
124+
*
125+
* @returns {Promise}
126+
* @memberof BuildProcess
127+
*/
128+
run() {
129+
return this.installDeps()
130+
.then(() => this.build())
131+
.then(() => {
132+
this.moveToDist()
133+
return this.folderName
134+
})
135+
.catch()
136+
}
137+
}
138+
139+
// Serial build
140+
const templateData = []
141+
142+
const afterBuild = templateList.reduce((p, item) => {
143+
const ps = new BuildProcess(item, { env: env[item] })
144+
p = p.then(() => ps.run())
145+
.then(() => templateData.push(item))
146+
return p
147+
}, Promise.resolve())
148+
149+
afterBuild
150+
.then(() => buildIndex(templateData, deployDir('index.html')))
151+
.catch((err) => {
152+
if (err) {
153+
console.trace(err)
154+
process.exit(1)
155+
}
156+
})

bin/deploy/env.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"nuxt-element-dashboard": {
3+
"NO_LOGIN": 1
4+
},
5+
"nuxt-multiple-spa": {}
6+
}

bin/deploy/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Template List</title>
8+
</head>
9+
<body>
10+
<ul>
11+
<% for (var i = 0; i < data.length; i++) { %>
12+
<% var item = data[i] %>
13+
<li>
14+
<a href="<%= './' + item %>"><%= item %></a>
15+
</li>
16+
<% } %>
17+
</ul>
18+
</body>
19+
</html>

generator/Template.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Template {
1818
this.generator = generator || path.resolve(__dirname, '../generator')
1919
this.outDir = outDir && path.resolve(`${outDir}`)
2020
this.npmClient = npmClient || 'yarn'
21-
this.logLevel = logLevel
2221
}
2322

2423
generate(saoOptions = {}, cmdOptions = {}) {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"test:snapshot": "ava test --verbose --update-snapshots",
2222
"build": "node bin/cli.js -a -o release",
2323
"build:release": "node bin/cli.js -a -o release && node bin/zip.js",
24+
"deploy": "yarn build && node bin/deploy/build.js",
2425
"release": "gren release --override"
2526
},
2627
"dependencies": {
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<template>
2+
<div class="logo">
3+
<svg
4+
width="32"
5+
height="32"
6+
viewBox="0 0 24 24"
7+
version="1.1"
8+
xmlns="http://www.w3.org/2000/svg"
9+
xmlns:xlink="http://www.w3.org/1999/xlink"
10+
>
11+
<!-- Generator: Sketch 57 (83077) - https://sketch.com -->
12+
<desc>Created with Sketch.</desc>
13+
<defs>
14+
<rect id="path-1" x="0" y="0" width="1920" height="784" />
15+
<linearGradient
16+
x1="34.0995885%"
17+
y1="76.6034879%"
18+
x2="55.3722971%"
19+
y2="34.2331585%"
20+
id="linearGradient-3"
21+
>
22+
<stop stop-color="#CB496B" offset="0%" />
23+
<stop stop-color="#D25A83" offset="50.2%" />
24+
<stop stop-color="#DB638D" offset="100%" />
25+
</linearGradient>
26+
<linearGradient
27+
x1="68.1138396%"
28+
y1="13.2651729%"
29+
x2="29.1556379%"
30+
y2="87.4797694%"
31+
id="linearGradient-4"
32+
>
33+
<stop stop-color="#7E70AA" offset="0%" />
34+
<stop stop-color="#7678B1" offset="26.56%" />
35+
<stop stop-color="#5C8AC0" offset="100%" />
36+
</linearGradient>
37+
<linearGradient
38+
x1="0.00252407808%"
39+
y1="50.0015782%"
40+
x2="100.000253%"
41+
y2="50.0015782%"
42+
id="linearGradient-5"
43+
>
44+
<stop stop-color="#3D86BB" offset="0%" />
45+
<stop stop-color="#2F8BC1" offset="41.42%" />
46+
<stop stop-color="#188FC8" offset="100%" />
47+
</linearGradient>
48+
</defs>
49+
<g id="切图" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
50+
<g id="index_切图" transform="translate(-1438.000000, -743.000000)">
51+
<g id="logo" transform="translate(0.000000, 702.000000)">
52+
<g id="多边形备份-4">
53+
<mask id="mask-2" fill="white">
54+
<use xlink:href="#path-1" />
55+
</mask>
56+
<g id="蒙版" />
57+
</g>
58+
</g>
59+
<g id="logo" transform="translate(1438.000000, 743.000000)">
60+
<g id="Group">
61+
<path
62+
d="M8.27046729,0 C8.27046729,0 12.546028,1.52 12.6147196,4.51804878 C12.6431776,5.7697561 11.3105607,6.77853659 9.7061215,8.04097561 C7.45009346,9.81560976 4.9114486,12.3785366 3.72014019,14.2380488 C1.88803738,17.0985366 1.20602804,19.9804878 2.53373832,21.2019512 C2.53373832,21.2019512 -2.06761682,17.2868293 1.13831776,11.244878 C2.08626168,9.32585366 7.16649533,3.59804878 8.27046729,0 Z"
63+
id="Path"
64+
fill="url(#linearGradient-3)"
65+
/>
66+
<path
67+
d="M13.4841589,6.0604878 C13.4841589,6.0604878 16.8215888,7.99804878 16.7558411,10.444878 C16.7214953,12.5590244 9.3214486,16.1258537 7.13901869,20.5229268 C6.44130841,21.862439 6.14102804,23.1112195 7.37943925,24 C4.13327103,23.635122 0.240420561,21.195122 5.41093458,14.8868293 C7.24303738,12.7073171 9.56285047,11.1297561 11.4243925,9.58634146 C12.9365888,8.33268293 14.2446729,7.42536585 13.4841589,6.0604878 Z"
68+
id="Path"
69+
fill="url(#linearGradient-4)"
70+
/>
71+
<path
72+
d="M17.3269626,11.3034146 C17.3308879,12.1765854 16.7882243,14.7531707 13.2614019,17.257561 C9.06042056,20.1619512 7.67186916,21.6809756 8.06242991,23.195122 C8.45299065,24.7092683 13.8197664,23.2517073 16.6017757,18.4487805 C18.2945327,15.5590244 17.493785,11.4087805 17.3269626,11.3034146 Z"
73+
id="Path"
74+
fill="url(#linearGradient-5)"
75+
/>
76+
</g>
77+
</g>
78+
</g>
79+
</g>
80+
</svg>
81+
<span class="text">{{ text }}</span>
82+
</div>
83+
</template>
84+
85+
<script>
86+
export default {
87+
props: {
88+
text: {
89+
type: String,
90+
default() {
91+
return this.$store.state.meta.appName
92+
}
93+
}
94+
}
95+
}
96+
</script>
97+
98+
<style scoped>
99+
.logo {
100+
display: flex;
101+
align-items: center;
102+
justify-content: center;
103+
color: #1f3762;
104+
font-size: 2em;
105+
font-weight: 500;
106+
}
107+
</style>

template/frameworks/mobile/pages/my.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</template>
5858

5959
<script>
60-
import Agreement from '../components/agreement'
60+
import Agreement from '@/components/agreement'
6161
import {Checkbox} from 'vant'
6262
6363
export default {

template/frameworks/multiple/components/layout-head.vue

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
<template>
22
<div class="layout-Head">
33
<div class="fixed-head">
4-
<h1 class="head-logo">
5-
<img
6-
src="https://deepexi.oss-cn-shenzhen.aliyuncs.com/xpaas-console/logo_SPaaS_white.png"
7-
alt="xPaaS"
8-
class="layout-logo"
9-
/>
10-
</h1>
4+
<logo class="head-logo" />
115
<!-- 头部菜单 -->
126
<div class="head-menu">
137
<ul class="clearfix">
@@ -48,9 +42,13 @@
4842
<script>
4943
import {mapMutations} from 'vuex'
5044
import cookie from 'js-cookie'
45+
import Logo from '@/components/logo.vue'
5146
5247
export default {
5348
name: 'LayoutHead',
49+
components: {
50+
Logo,
51+
},
5452
props: {
5553
searchUrl: {
5654
type: Object,
@@ -140,15 +138,10 @@ export default {
140138
}
141139
142140
.head-logo {
143-
display: flex;
144-
justify-content: center;
145-
align-items: center;
146141
width: 200px;
147-
148-
.layout-logo {
149-
width: 80%;
150-
height: auto;
151-
}
142+
color: #fff;
143+
font-weight: 500;
144+
font-size: 20px;
152145
}
153146
154147
.head-menu {

0 commit comments

Comments
 (0)