Merge branch 'i18n' into deploy

This commit is contained in:
花裤衩 2020-01-09 17:46:51 +08:00
commit f1d5e5c19b
18 changed files with 90 additions and 166 deletions

View File

@ -18,7 +18,7 @@ for (let i = 0; i < count; i++) {
forecast: '@float(0, 100, 2, 2)', forecast: '@float(0, 100, 2, 2)',
importance: '@integer(1, 3)', importance: '@integer(1, 3)',
'type|1': ['CN', 'US', 'JP', 'EU'], 'type|1': ['CN', 'US', 'JP', 'EU'],
'status|1': ['published', 'draft', 'deleted'], 'status|1': ['published', 'draft'],
display_time: '@datetime', display_time: '@datetime',
comment_disabled: true, comment_disabled: true,
pageviews: '@integer(300, 5000)', pageviews: '@integer(300, 5000)',
@ -29,7 +29,7 @@ for (let i = 0; i < count; i++) {
export default [ export default [
{ {
url: '/article/list', url: '/vue-element-admin/article/list',
type: 'get', type: 'get',
response: config => { response: config => {
const { importance, type, title, page = 1, limit = 20, sort } = config.query const { importance, type, title, page = 1, limit = 20, sort } = config.query
@ -58,7 +58,7 @@ export default [
}, },
{ {
url: '/article/detail', url: '/vue-element-admin/article/detail',
type: 'get', type: 'get',
response: config => { response: config => {
const { id } = config.query const { id } = config.query
@ -74,7 +74,7 @@ export default [
}, },
{ {
url: '/article/pv', url: '/vue-element-admin/article/pv',
type: 'get', type: 'get',
response: _ => { response: _ => {
return { return {
@ -92,7 +92,7 @@ export default [
}, },
{ {
url: '/article/create', url: '/vue-element-admin/article/create',
type: 'post', type: 'post',
response: _ => { response: _ => {
return { return {
@ -103,7 +103,7 @@ export default [
}, },
{ {
url: '/article/update', url: '/vue-element-admin/article/update',
type: 'post', type: 'post',
response: _ => { response: _ => {
return { return {

View File

@ -57,9 +57,10 @@ export function mockXHR() {
// for mock server // for mock server
const responseFake = (url, type, respond) => { const responseFake = (url, type, respond) => {
return { return {
url: new RegExp(`/mock${url}`), url: new RegExp(`${process.env.VUE_APP_BASE_API}${url}`),
type: type || 'get', type: type || 'get',
response(req, res) { response(req, res) {
console.log('request invoke:' + req.path)
res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond)) res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond))
} }
} }

View File

@ -13,7 +13,7 @@ NameList.push({ name: 'mock-Pan' })
export default [ export default [
// username search // username search
{ {
url: '/search/user', url: '/vue-element-admin/search/user',
type: 'get', type: 'get',
response: config => { response: config => {
const { name } = config.query const { name } = config.query
@ -30,7 +30,7 @@ export default [
// transaction list // transaction list
{ {
url: '/transaction/list', url: '/vue-element-admin/transaction/list',
type: 'get', type: 'get',
response: _ => { response: _ => {
return { return {

View File

@ -38,7 +38,7 @@ const roles = [
export default [ export default [
// mock get all routes form server // mock get all routes form server
{ {
url: '/routes', url: '/vue-element-admin/routes',
type: 'get', type: 'get',
response: _ => { response: _ => {
return { return {
@ -50,7 +50,7 @@ export default [
// mock get all roles form server // mock get all roles form server
{ {
url: '/roles', url: '/vue-element-admin/roles',
type: 'get', type: 'get',
response: _ => { response: _ => {
return { return {
@ -62,7 +62,7 @@ export default [
// add role // add role
{ {
url: '/role', url: '/vue-element-admin/role',
type: 'post', type: 'post',
response: { response: {
code: 20000, code: 20000,
@ -74,7 +74,7 @@ export default [
// update role // update role
{ {
url: '/role/[A-Za-z0-9]', url: '/vue-element-admin/role/[A-Za-z0-9]',
type: 'put', type: 'put',
response: { response: {
code: 20000, code: 20000,
@ -86,7 +86,7 @@ export default [
// delete role // delete role
{ {
url: '/role/[A-Za-z0-9]', url: '/vue-element-admin/role/[A-Za-z0-9]',
type: 'delete', type: 'delete',
response: { response: {
code: 20000, code: 20000,

View File

@ -26,7 +26,7 @@ const users = {
export default [ export default [
// user login // user login
{ {
url: '/user/login', url: '/vue-element-admin/user/login',
type: 'post', type: 'post',
response: config => { response: config => {
const { username } = config.body const { username } = config.body
@ -49,7 +49,7 @@ export default [
// get user info // get user info
{ {
url: '/user/info\.*', url: '/vue-element-admin/user/info\.*',
type: 'get', type: 'get',
response: config => { response: config => {
const { token } = config.query const { token } = config.query
@ -72,7 +72,7 @@ export default [
// user logout // user logout
{ {
url: '/user/logout', url: '/vue-element-admin/user/logout',
type: 'post', type: 'post',
response: _ => { response: _ => {
return { return {

View File

@ -50,7 +50,7 @@
"driver.js": "0.9.5", "driver.js": "0.9.5",
"dropzone": "5.5.1", "dropzone": "5.5.1",
"echarts": "4.2.1", "echarts": "4.2.1",
"element-ui": "2.7.0", "element-ui": "2.13.0",
"file-saver": "2.0.1", "file-saver": "2.0.1",
"fuse.js": "3.4.4", "fuse.js": "3.4.4",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",

View File

@ -2,7 +2,7 @@ import request from '@/utils/request'
export function fetchList(query) { export function fetchList(query) {
return request({ return request({
url: '/article/list', url: '/vue-element-admin/article/list',
method: 'get', method: 'get',
params: query params: query
}) })
@ -10,7 +10,7 @@ export function fetchList(query) {
export function fetchArticle(id) { export function fetchArticle(id) {
return request({ return request({
url: '/article/detail', url: '/vue-element-admin/article/detail',
method: 'get', method: 'get',
params: { id } params: { id }
}) })
@ -18,7 +18,7 @@ export function fetchArticle(id) {
export function fetchPv(pv) { export function fetchPv(pv) {
return request({ return request({
url: '/article/pv', url: '/vue-element-admin/article/pv',
method: 'get', method: 'get',
params: { pv } params: { pv }
}) })
@ -26,7 +26,7 @@ export function fetchPv(pv) {
export function createArticle(data) { export function createArticle(data) {
return request({ return request({
url: '/article/create', url: '/vue-element-admin/article/create',
method: 'post', method: 'post',
data data
}) })
@ -34,7 +34,7 @@ export function createArticle(data) {
export function updateArticle(data) { export function updateArticle(data) {
return request({ return request({
url: '/article/update', url: '/vue-element-admin/article/update',
method: 'post', method: 'post',
data data
}) })

View File

@ -2,7 +2,7 @@ import request from '@/utils/request'
export function searchUser(name) { export function searchUser(name) {
return request({ return request({
url: '/search/user', url: '/vue-element-admin/search/user',
method: 'get', method: 'get',
params: { name } params: { name }
}) })
@ -10,7 +10,7 @@ export function searchUser(name) {
export function transactionList(query) { export function transactionList(query) {
return request({ return request({
url: '/transaction/list', url: '/vue-element-admin/transaction/list',
method: 'get', method: 'get',
params: query params: query
}) })

View File

@ -2,21 +2,21 @@ import request from '@/utils/request'
export function getRoutes() { export function getRoutes() {
return request({ return request({
url: '/routes', url: '/vue-element-admin/routes',
method: 'get' method: 'get'
}) })
} }
export function getRoles() { export function getRoles() {
return request({ return request({
url: '/roles', url: '/vue-element-admin/roles',
method: 'get' method: 'get'
}) })
} }
export function addRole(data) { export function addRole(data) {
return request({ return request({
url: '/role', url: '/vue-element-admin/role',
method: 'post', method: 'post',
data data
}) })
@ -24,7 +24,7 @@ export function addRole(data) {
export function updateRole(id, data) { export function updateRole(id, data) {
return request({ return request({
url: `/role/${id}`, url: `/vue-element-admin/role/${id}`,
method: 'put', method: 'put',
data data
}) })
@ -32,7 +32,7 @@ export function updateRole(id, data) {
export function deleteRole(id) { export function deleteRole(id) {
return request({ return request({
url: `/role/${id}`, url: `/vue-element-admin/role/${id}`,
method: 'delete' method: 'delete'
}) })
} }

View File

@ -2,7 +2,7 @@ import request from '@/utils/request'
export function login(data) { export function login(data) {
return request({ return request({
url: '/user/login', url: '/vue-element-admin/user/login',
method: 'post', method: 'post',
data data
}) })
@ -10,7 +10,7 @@ export function login(data) {
export function getInfo(token) { export function getInfo(token) {
return request({ return request({
url: '/user/info', url: '/vue-element-admin/user/info',
method: 'get', method: 'get',
params: { token } params: { token }
}) })
@ -18,7 +18,7 @@ export function getInfo(token) {
export function logout() { export function logout() {
return request({ return request({
url: '/user/logout', url: '/vue-element-admin/user/logout',
method: 'post' method: 'post'
}) })
} }

View File

@ -3,32 +3,54 @@ import { debounce } from '@/utils'
export default { export default {
data() { data() {
return { return {
$_sidebarElm: null $_sidebarElm: null,
$_resizeHandler: null
} }
}, },
mounted() { mounted() {
this.__resizeHandler = debounce(() => { this.initListener()
if (this.chart) { },
this.chart.resize() activated() {
} if (!this.$_resizeHandler) {
}, 100) // avoid duplication init
window.addEventListener('resize', this.__resizeHandler) this.initListener()
}
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0] // when keep-alive chart activated, auto resize
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler) this.resize()
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('resize', this.__resizeHandler) this.destroyListener()
},
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler) deactivated() {
this.destroyListener()
}, },
methods: { methods: {
// use $_ for mixins properties // use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_sidebarResizeHandler(e) { $_sidebarResizeHandler(e) {
if (e.propertyName === 'width') { if (e.propertyName === 'width') {
this.__resizeHandler() this.$_resizeHandler()
} }
},
initListener() {
this.$_resizeHandler = debounce(() => {
this.resize()
}, 100)
window.addEventListener('resize', this.$_resizeHandler)
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
},
destroyListener() {
window.removeEventListener('resize', this.$_resizeHandler)
this.$_resizeHandler = null
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
},
resize() {
const { chart } = this
chart && chart.resize()
} }
} }
} }

View File

@ -44,8 +44,8 @@
<a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/"> <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
<el-dropdown-item>Docs</el-dropdown-item> <el-dropdown-item>Docs</el-dropdown-item>
</a> </a>
<el-dropdown-item divided> <el-dropdown-item divided @click.native="logout">
<span style="display:block;" @click="logout">{{ $t('navbar.logOut') }}</span> <span style="display:block;">{{ $t('navbar.logOut') }}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-if="!item.hidden" class="menu-wrapper"> <div v-if="!item.hidden">
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"> <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)"> <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">

View File

@ -33,11 +33,12 @@ Vue.use(VueAnalytics, {
* you can execute: mockXHR() * you can execute: mockXHR()
* *
* Currently MockJs will be used in the production environment, * Currently MockJs will be used in the production environment,
* please remove it before going online! ! ! * please remove it before going online ! ! !
*/ */
import { mockXHR } from '../mock'
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
mockXHR() import('../mock').then(({ mockXHR }) => {
mockXHR()
})
} }
Vue.use(Element, { Vue.use(Element, {

View File

@ -1,74 +1,3 @@
const elementIcons = [ const elementIcons = ['platform-eleme', 'eleme', 'delete-solid', 'delete', 's-tools', 'setting', 'user-solid', 'user', 'phone', 'phone-outline', 'more', 'more-outline', 'star-on', 'star-off', 's-goods', 'goods', 'warning', 'warning-outline', 'question', 'info', 'remove', 'circle-plus', 'success', 'error', 'zoom-in', 'zoom-out', 'remove-outline', 'circle-plus-outline', 'circle-check', 'circle-close', 's-help', 'help', 'minus', 'plus', 'check', 'close', 'picture', 'picture-outline', 'picture-outline-round', 'upload', 'upload2', 'download', 'camera-solid', 'camera', 'video-camera-solid', 'video-camera', 'message-solid', 'bell', 's-cooperation', 's-order', 's-platform', 's-fold', 's-unfold', 's-operation', 's-promotion', 's-home', 's-release', 's-ticket', 's-management', 's-open', 's-shop', 's-marketing', 's-flag', 's-comment', 's-finance', 's-claim', 's-custom', 's-opportunity', 's-data', 's-check', 's-grid', 'menu', 'share', 'd-caret', 'caret-left', 'caret-right', 'caret-bottom', 'caret-top', 'bottom-left', 'bottom-right', 'back', 'right', 'bottom', 'top', 'top-left', 'top-right', 'arrow-left', 'arrow-right', 'arrow-down', 'arrow-up', 'd-arrow-left', 'd-arrow-right', 'video-pause', 'video-play', 'refresh', 'refresh-right', 'refresh-left', 'finished', 'sort', 'sort-up', 'sort-down', 'rank', 'loading', 'view', 'c-scale-to-original', 'date', 'edit', 'edit-outline', 'folder', 'folder-opened', 'folder-add', 'folder-remove', 'folder-delete', 'folder-checked', 'tickets', 'document-remove', 'document-delete', 'document-copy', 'document-checked', 'document', 'document-add', 'printer', 'paperclip', 'takeaway-box', 'search', 'monitor', 'attract', 'mobile', 'scissors', 'umbrella', 'headset', 'brush', 'mouse', 'coordinate', 'magic-stick', 'reading', 'data-line', 'data-board', 'pie-chart', 'data-analysis', 'collection-tag', 'film', 'suitcase', 'suitcase-1', 'receiving', 'collection', 'files', 'notebook-1', 'notebook-2', 'toilet-paper', 'office-building', 'school', 'table-lamp', 'house', 'no-smoking', 'smoking', 'shopping-cart-full', 'shopping-cart-1', 'shopping-cart-2', 'shopping-bag-1', 'shopping-bag-2', 'sold-out', 'sell', 'present', 'box', 'bank-card', 'money', 'coin', 'wallet', 'discount', 'price-tag', 'news', 'guide', 'male', 'female', 'thumb', 'cpu', 'link', 'connection', 'open', 'turn-off', 'set-up', 'chat-round', 'chat-line-round', 'chat-square', 'chat-dot-round', 'chat-dot-square', 'chat-line-square', 'message', 'postcard', 'position', 'turn-off-microphone', 'microphone', 'close-notification', 'bangzhu', 'time', 'odometer', 'crop', 'aim', 'switch-button', 'full-screen', 'copy-document', 'mic', 'stopwatch', 'medal-1', 'medal', 'trophy', 'trophy-1', 'first-aid-kit', 'discover', 'place', 'location', 'location-outline', 'location-information', 'add-location', 'delete-location', 'map-location', 'alarm-clock', 'timer', 'watch-1', 'watch', 'lock', 'unlock', 'key', 'service', 'mobile-phone', 'bicycle', 'truck', 'ship', 'basketball', 'football', 'soccer', 'baseball', 'wind-power', 'light-rain', 'lightning', 'heavy-rain', 'sunrise', 'sunrise-1', 'sunset', 'sunny', 'cloudy', 'partly-cloudy', 'cloudy-and-sunny', 'moon', 'moon-night', 'dish', 'dish-1', 'food', 'chicken', 'fork-spoon', 'knife-fork', 'burger', 'tableware', 'sugar', 'dessert', 'ice-cream', 'hot-water', 'water-cup', 'coffee-cup', 'cold-drink', 'goblet', 'goblet-full', 'goblet-square', 'goblet-square-full', 'refrigerator', 'grape', 'watermelon', 'cherry', 'apple', 'pear', 'orange', 'coffee', 'ice-tea', 'ice-drink', 'milk-tea', 'potato-strips', 'lollipop', 'ice-cream-square', 'ice-cream-round']
'info',
'error',
'success',
'warning',
'question',
'back',
'arrow-left',
'arrow-down',
'arrow-right',
'arrow-up',
'caret-left',
'caret-bottom',
'caret-top',
'caret-right',
'd-arrow-left',
'd-arrow-right',
'minus',
'plus',
'remove',
'circle-plus',
'remove-outline',
'circle-plus-outline',
'close',
'check',
'circle-close',
'circle-check',
'circle-close-outline',
'circle-check-outline',
'zoom-out',
'zoom-in',
'd-caret',
'sort',
'sort-down',
'sort-up',
'tickets',
'document',
'goods',
'sold-out',
'news',
'message',
'date',
'printer',
'time',
'bell',
'mobile-phone',
'service',
'view',
'menu',
'more',
'more-outline',
'star-on',
'star-off',
'location',
'location-outline',
'phone',
'phone-outline',
'picture',
'picture-outline',
'delete',
'search',
'edit',
'edit-outline',
'rank',
'refresh',
'share',
'setting',
'upload',
'upload2',
'download',
'loading'
]
export default elementIcons export default elementIcons

View File

@ -146,17 +146,9 @@ export default {
// window.removeEventListener('storage', this.afterQRScan) // window.removeEventListener('storage', this.afterQRScan)
}, },
methods: { methods: {
checkCapslock({ shiftKey, key } = {}) { checkCapslock(e) {
if (key && key.length === 1) { const { key } = e
if (shiftKey && (key >= 'a' && key <= 'z') || !shiftKey && (key >= 'A' && key <= 'Z')) { this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z')
this.capsTooltip = true
} else {
this.capsTooltip = false
}
}
if (key === 'CapsLock' && this.capsTooltip === true) {
this.capsTooltip = false
}
}, },
showPwd() { showPwd() {
if (this.passwordType === 'password') { if (this.passwordType === 'password') {

View File

@ -80,7 +80,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('table.actions')" align="center" width="230" class-name="small-padding fixed-width"> <el-table-column :label="$t('table.actions')" align="center" width="230" class-name="small-padding fixed-width">
<template slot-scope="{row}"> <template slot-scope="{row,$index}">
<el-button type="primary" size="mini" @click="handleUpdate(row)"> <el-button type="primary" size="mini" @click="handleUpdate(row)">
{{ $t('table.edit') }} {{ $t('table.edit') }}
</el-button> </el-button>
@ -90,7 +90,7 @@
<el-button v-if="row.status!='draft'" size="mini" @click="handleModifyStatus(row,'draft')"> <el-button v-if="row.status!='draft'" size="mini" @click="handleModifyStatus(row,'draft')">
{{ $t('table.draft') }} {{ $t('table.draft') }}
</el-button> </el-button>
<el-button v-if="row.status!='deleted'" size="mini" type="danger" @click="handleModifyStatus(row,'deleted')"> <el-button v-if="row.status!='deleted'" size="mini" type="danger" @click="handleDelete(row,$index)">
{{ $t('table.delete') }} {{ $t('table.delete') }}
</el-button> </el-button>
</template> </template>
@ -319,13 +319,8 @@ export default {
const tempData = Object.assign({}, this.temp) const tempData = Object.assign({}, this.temp)
tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464 tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
updateArticle(tempData).then(() => { updateArticle(tempData).then(() => {
for (const v of this.list) { const index = this.list.findIndex(v => v.id === this.temp.id)
if (v.id === this.temp.id) { this.list.splice(index, 1, this.temp)
const index = this.list.indexOf(v)
this.list.splice(index, 1, this.temp)
break
}
}
this.dialogFormVisible = false this.dialogFormVisible = false
this.$notify({ this.$notify({
title: '成功', title: '成功',
@ -337,14 +332,13 @@ export default {
} }
}) })
}, },
handleDelete(row) { handleDelete(row, index) {
this.$notify({ this.$notify({
title: '成功', title: '成功',
message: '删除成功', message: '删除成功',
type: 'success', type: 'success',
duration: 2000 duration: 2000
}) })
const index = this.list.indexOf(row)
this.list.splice(index, 1) this.list.splice(index, 1)
}, },
handleFetchPv(pv) { handleFetchPv(pv) {
@ -358,7 +352,7 @@ export default {
import('@/vendor/Export2Excel').then(excel => { import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status'] const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status'] const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
const data = this.formatJson(filterVal, this.list) const data = this.formatJson(filterVal)
excel.export_json_to_excel({ excel.export_json_to_excel({
header: tHeader, header: tHeader,
data, data,
@ -367,8 +361,8 @@ export default {
this.downloadLoading = false this.downloadLoading = false
}) })
}, },
formatJson(filterVal, jsonData) { formatJson(filterVal) {
return jsonData.map(v => filterVal.map(j => { return this.list.map(v => filterVal.map(j => {
if (j === 'timestamp') { if (j === 'timestamp') {
return parseTime(v[j]) return parseTime(v[j])
} else { } else {
@ -378,11 +372,7 @@ export default {
}, },
getSortClass: function(key) { getSortClass: function(key) {
const sort = this.listQuery.sort const sort = this.listQuery.sort
return sort === `+${key}` return sort === `+${key}` ? 'ascending' : 'descending'
? 'ascending'
: sort === `-${key}`
? 'descending'
: ''
} }
} }
} }

View File

@ -36,18 +36,7 @@ module.exports = {
warnings: false, warnings: false,
errors: true errors: true
}, },
proxy: { before: require('./mock/mock-server.js')
// change xxx-api/login => mock/login
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://127.0.0.1:${port}/mock`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
}
}
},
after: require('./mock/mock-server.js')
}, },
configureWebpack: { configureWebpack: {
// provide the app's title in webpack's name field, so that // provide the app's title in webpack's name field, so that