1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-09-10 02:41:34 +08:00
This commit is contained in:
Pan 2019-03-26 17:11:27 +08:00
parent 02097c0ce5
commit 383b2132c5
7 changed files with 60 additions and 43 deletions

View File

@ -1,6 +1,6 @@
import request from '@/utils/request' import request from '@/utils/request'
export function userSearch(name) { export function searchUser(name) {
return request({ return request({
url: '/search/user', url: '/search/user',
method: 'get', method: 'get',

View File

@ -64,6 +64,7 @@ export default {
font-size: 14px; font-size: 14px;
line-height: 50px; line-height: 50px;
margin-left: 8px; margin-left: 8px;
.no-redirect { .no-redirect {
color: #97a8be; color: #97a8be;
cursor: text; cursor: text;

View File

@ -17,6 +17,9 @@ export default {
mounted() { mounted() {
this.init() this.init()
}, },
beforeDestroy() {
this.destroy()
},
methods: { methods: {
click() { click() {
if (!screenfull.enabled) { if (!screenfull.enabled) {
@ -28,11 +31,17 @@ export default {
} }
screenfull.toggle() screenfull.toggle()
}, },
change() {
this.isFullscreen = screenfull.isFullscreen
},
init() { init() {
if (screenfull.enabled) { if (screenfull.enabled) {
screenfull.on('change', () => { screenfull.on('change', this.change)
this.isFullscreen = screenfull.isFullscreen }
}) },
destroy() {
if (screenfull.enabled) {
screenfull.off('change', this.change)
} }
} }
} }

View File

@ -14,6 +14,9 @@ export default {
beforeMount() { beforeMount() {
window.addEventListener('resize', this.resizeHandler) window.addEventListener('resize', this.resizeHandler)
}, },
beforeDestroy() {
window.removeEventListener('resize', this.resizeHandler)
},
mounted() { mounted() {
const isMobile = this.isMobile() const isMobile = this.isMobile()
if (isMobile) { if (isMobile) {

View File

@ -81,7 +81,7 @@ import MDinput from '@/components/MDinput'
import Sticky from '@/components/Sticky' // header import Sticky from '@/components/Sticky' // header
import { validURL } from '@/utils/validate' import { validURL } from '@/utils/validate'
import { fetchArticle } from '@/api/article' import { fetchArticle } from '@/api/article'
import { userSearch } from '@/api/remoteSearch' import { searchUser } from '@/api/remoteSearch'
import Warning from './Warning' import Warning from './Warning'
import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from './Dropdown' import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from './Dropdown'
@ -225,7 +225,7 @@ export default {
this.postForm.status = 'draft' this.postForm.status = 'draft'
}, },
getRemoteUserList(query) { getRemoteUserList(query) {
userSearch(query).then(response => { searchUser(query).then(response => {
if (!response.data.items) return if (!response.data.items) return
this.userListOptions = response.data.items.map(v => v.name) this.userListOptions = response.data.items.map(v => v.name)
}) })

View File

@ -31,8 +31,8 @@ module.exports = {
errors: true errors: true
}, },
proxy: { proxy: {
// Detail: https://cli.vuejs.org/config/#devserver-proxy // change xxx-api/login => mock/login
// xxx-api/login => mock/login // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: `http://localhost:${port}/mock`, target: `http://localhost:${port}/mock`,
changeOrigin: true, changeOrigin: true,
@ -71,6 +71,8 @@ module.exports = {
chainWebpack(config) { chainWebpack(config) {
config.plugins.delete('preload') // TODO: need test config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test config.plugins.delete('prefetch') // TODO: need test
// set svg-sprite-loader
config.module config.module
.rule('svg') .rule('svg')
.exclude.add(resolve('src/icons')) .exclude.add(resolve('src/icons'))
@ -86,6 +88,8 @@ module.exports = {
symbolId: 'icon-[name]' symbolId: 'icon-[name]'
}) })
.end() .end()
// set preserveWhitespace
config.module config.module
.rule('vue') .rule('vue')
.use('vue-loader') .use('vue-loader')
@ -120,17 +124,17 @@ module.exports = {
name: 'chunk-libs', name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
priority: 10, priority: 10,
chunks: 'initial' // 只打包初始时依赖的第三方 chunks: 'initial' // only package third parties that are initially dependent
}, },
elementUI: { elementUI: {
name: 'chunk-elementUI', // 单独将 elementUI 拆包 name: 'chunk-elementUI', // split elementUI into a single package
priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]element-ui[\\/]/ test: /[\\/]node_modules[\\/]element-ui[\\/]/
}, },
commons: { commons: {
name: 'chunk-commons', name: 'chunk-commons',
test: resolve('src/components'), // 可自定义拓展你的规则 test: resolve('src/components'), // can customize your rules
minChunks: 3, // 最小公用次数 minChunks: 3, // minimum common number
priority: 5, priority: 5,
reuseExistingChunk: true reuseExistingChunk: true
} }