Skip to content

Commit 7f40044

Browse files
authored
Merge pull request #8 from PanJiaChen/master
pull
2 parents 460a0ab + 806f960 commit 7f40044

File tree

127 files changed

+999
-693
lines changed

Some content is hidden

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

127 files changed

+999
-693
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# http://editorconfig.org
1+
# https://editorconfig.org
22
root = true
33

44
[*]

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ English | [简体中文](./README.zh-CN.md)
3030

3131
## Introduction
3232

33-
[vue-element-admin](http://panjiachen.github.io/vue-element-admin) is a production-ready front-end solution for admin interfaces. It based on [vue](https://github.com/vuejs/vue) and use the UI Toolkit [element-ui](https://github.com/ElemeFE/element).
33+
[vue-element-admin](https://panjiachen.github.io/vue-element-admin) is a production-ready front-end solution for admin interfaces. It based on [vue](https://github.com/vuejs/vue) and use the UI Toolkit [element-ui](https://github.com/ElemeFE/element).
3434

3535
It is a magical vue admin based on the newest development stack of vue, built-in i18n solution, typical templates for enterprise applications, lots of awesome features. It helps you build a large complex Single-Page Applications. I believe whatever your needs are, this project will help you.
3636

37-
- [Preview](http://panjiachen.github.io/vue-element-admin)
37+
- [Preview](https://panjiachen.github.io/vue-element-admin)
3838

3939
- [Documentation](https://panjiachen.github.io/vue-element-admin-site/)
4040

@@ -50,13 +50,13 @@ It is a magical vue admin based on the newest development stack of vue, built-in
5050
- Desktop: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
5151
- Typescript: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (Credits: [@Armour](https://github.com/Armour))
5252

53-
**The current version is `4.0-beta`. If you find a problem, please put [issue](https://github.com/PanJiaChen/vue-element-admin/issues/new). If you want to use the old version - stable version, you can switch branch to [tag/3.11.0](https://github.com/PanJiaChen/vue-element-admin/tree/tag/3.11.0)**
53+
**The current version is `v4.0+` build on `vue-cli`. If you find a problem, please put [issue](https://github.com/PanJiaChen/vue-element-admin/issues/new). If you want to use the old version , you can switch branch to [tag/3.11.0](https://github.com/PanJiaChen/vue-element-admin/tree/tag/3.11.0), it does not rely on `vue-cli'**
5454

5555
**This project does not support low version browsers (e.g. IE). Please add polyfill by yourself.**
5656

5757
## Preparation
5858

59-
You need to install [node](http://nodejs.org/) and [git](https://git-scm.com/) locally. The project is based on [ES2015+](http://es6.ruanyifeng.com/), [vue](https://cn.vuejs.org/index.html), [vuex](https://vuex.vuejs.org/zh-cn/), [vue-router](https://router.vuejs.org/zh-cn/), [vue-cli](https://github.com/vuejs/vue-cli) , [axios](https://github.com/axios/axios) and [element-ui](https://github.com/ElemeFE/element), all request data is simulated using [Mock.js](https://github.com/nuysoft/Mock).
59+
You need to install [node](https://nodejs.org/) and [git](https://git-scm.com/) locally. The project is based on [ES2015+](https://es6.ruanyifeng.com/), [vue](https://cn.vuejs.org/index.html), [vuex](https://vuex.vuejs.org/zh-cn/), [vue-router](https://router.vuejs.org/zh-cn/), [vue-cli](https://github.com/vuejs/vue-cli) , [axios](https://github.com/axios/axios) and [element-ui](https://github.com/ElemeFE/element), all request data is simulated using [Mock.js](https://github.com/nuysoft/Mock).
6060
Understanding and learning this knowledge in advance will greatly help the use of this project.
6161

6262
<p align="center">
@@ -187,7 +187,7 @@ Detailed changes for each release are documented in the [release notes](https://
187187

188188
## Online Demo
189189

190-
[Preview](http://panjiachen.github.io/vue-element-admin)
190+
[Preview](https://panjiachen.github.io/vue-element-admin)
191191

192192
## Donate
193193

@@ -203,7 +203,7 @@ If you find this project useful, you can buy author a glass of juice :tropical_d
203203

204204
Modern browsers and Internet Explorer 10+.
205205

206-
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
206+
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Safari |
207207
| --------- | --------- | --------- | --------- |
208208
| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions
209209

README.zh-CN.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131
## 简介
3232

33-
[vue-element-admin](http://panjiachen.github.io/vue-element-admin) 是一个后台前端解决方案,它基于 [vue](https://github.com/vuejs/vue)[element-ui](https://github.com/ElemeFE/element)实现。它使用了最新的前端技术栈,内置了 i18n 国际化解决方案,动态路由,权限验证,提炼了典型的业务模型,提供了丰富的功能组件,它可以帮助你快速搭建企业级中后台产品原型。相信不管你的需求是什么,本项目都能帮助到你。
33+
[vue-element-admin](https://panjiachen.github.io/vue-element-admin) 是一个后台前端解决方案,它基于 [vue](https://github.com/vuejs/vue)[element-ui](https://github.com/ElemeFE/element)实现。它使用了最新的前端技术栈,内置了 i18n 国际化解决方案,动态路由,权限验证,提炼了典型的业务模型,提供了丰富的功能组件,它可以帮助你快速搭建企业级中后台产品原型。相信不管你的需求是什么,本项目都能帮助到你。
3434

35-
- [在线预览](http://panjiachen.github.io/vue-element-admin)
35+
- [在线预览](https://panjiachen.github.io/vue-element-admin)
3636

3737
- [使用文档](https://panjiachen.github.io/vue-element-admin-site/zh/)
3838

@@ -50,7 +50,7 @@
5050
- 桌面端: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
5151
- Typescript 版: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (鸣谢: [@Armour](https://github.com/Armour))
5252

53-
**目前版本为 `4.0-beta`,若发现问题,欢迎提[issue](https://github.com/PanJiaChen/vue-element-admin/issues/new)。若你想使用旧版本-稳定版,可以切换分支到[tag/3.11.0](https://github.com/PanJiaChen/vue-element-admin/tree/tag/3.11.0)**
53+
**目前版本为 `v4.0+` 基于 `vue-cli` 进行构建,若发现问题,欢迎提[issue](https://github.com/PanJiaChen/vue-element-admin/issues/new)。若你想使用旧版本,可以切换分支到[tag/3.11.0](https://github.com/PanJiaChen/vue-element-admin/tree/tag/3.11.0),它不依赖 `vue-cli`**
5454

5555
**该项目不支持低版本浏览器(如 ie),有需求请自行添加 polyfill [详情](https://github.com/PanJiaChen/vue-element-admin/wiki#babel-polyfill)**
5656

@@ -204,7 +204,7 @@ Detailed changes for each release are documented in the [release notes](https://
204204

205205
## Online Demo
206206

207-
[在线 Demo](http://panjiachen.github.io/vue-element-admin)
207+
[在线 Demo](https://panjiachen.github.io/vue-element-admin)
208208

209209
## Donate
210210

@@ -221,7 +221,7 @@ Detailed changes for each release are documented in the [release notes](https://
221221

222222
Modern browsers and Internet Explorer 10+.
223223

224-
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
224+
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)</br>Safari |
225225
| --------- | --------- | --------- | --------- |
226226
| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions
227227

build/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
2626
app.listen(port, function () {
2727
console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
2828
if (report) {
29-
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}/report.html`))
29+
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
3030
}
3131

3232
})

mock/article.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Mock from 'mockjs'
33
const List = []
44
const count = 100
55

6-
const baseContent = '<p>我是测试数据我是测试数据</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
6+
const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
77
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
88

99
for (let i = 0; i < count; i++) {

mock/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import Mock from 'mockjs'
2-
import mocks from './mocks'
32
import { param2Obj } from '../src/utils'
43

5-
const MOCK_API_BASE = '/mock'
4+
import user from './user'
5+
import role from './role'
6+
import article from './article'
7+
import search from './remote-search'
68

9+
const mocks = [
10+
...user,
11+
...role,
12+
...article,
13+
...search
14+
]
15+
16+
// for front mock
17+
// please use it cautiously, it will redefine XMLHttpRequest,
18+
// which will cause many of your third-party libraries to be invalidated(like progress event).
719
export function mockXHR() {
8-
// 修复在使用 MockJS 情况下,设置 withCredentials = true,且未被拦截的跨域请求丢失 Cookies 的问题
20+
// mock patch
921
// https://github.com/nuysoft/Mock/issues/300
1022
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
1123
Mock.XHR.prototype.send = function() {
@@ -42,9 +54,10 @@ export function mockXHR() {
4254
}
4355
}
4456

57+
// for mock server
4558
const responseFake = (url, type, respond) => {
4659
return {
47-
url: new RegExp(`${MOCK_API_BASE}${url}`),
60+
url: new RegExp(`/mock${url}`),
4861
type: type || 'get',
4962
response(req, res) {
5063
res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond))

mock/mock-server.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const chokidar = require('chokidar')
2+
const bodyParser = require('body-parser')
3+
const chalk = require('chalk')
4+
5+
function registerRoutes(app) {
6+
let mockLastIndex
7+
const { default: mocks } = require('./index.js')
8+
for (const mock of mocks) {
9+
app[mock.type](mock.url, mock.response)
10+
mockLastIndex = app._router.stack.length
11+
}
12+
const mockRoutesLength = Object.keys(mocks).length
13+
return {
14+
mockRoutesLength: mockRoutesLength,
15+
mockStartIndex: mockLastIndex - mockRoutesLength
16+
}
17+
}
18+
19+
function unregisterRoutes() {
20+
Object.keys(require.cache).forEach(i => {
21+
if (i.includes('/mock')) {
22+
delete require.cache[require.resolve(i)]
23+
}
24+
})
25+
}
26+
27+
module.exports = app => {
28+
// es6 polyfill
29+
require('@babel/register')
30+
31+
// parse app.body
32+
// https://expressjs.com/en/4x/api.html#req.body
33+
app.use(bodyParser.json())
34+
app.use(bodyParser.urlencoded({
35+
extended: true
36+
}))
37+
38+
const mockRoutes = registerRoutes(app)
39+
var mockRoutesLength = mockRoutes.mockRoutesLength
40+
var mockStartIndex = mockRoutes.mockStartIndex
41+
42+
// watch files, hot reload mock server
43+
chokidar.watch(('./mock'), {
44+
ignored: 'mock/mock-server.js',
45+
persistent: true,
46+
ignoreInitial: true
47+
}).on('all', (event, path) => {
48+
if (event === 'change' || event === 'add') {
49+
// remove mock routes stack
50+
app._router.stack.splice(mockStartIndex, mockRoutesLength)
51+
52+
// clear routes cache
53+
unregisterRoutes()
54+
55+
const mockRoutes = registerRoutes(app)
56+
mockRoutesLength = mockRoutes.mockRoutesLength
57+
mockStartIndex = mockRoutes.mockStartIndex
58+
59+
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
60+
}
61+
})
62+
}

mock/mocks.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)