diff --git a/README.md b/README.md index 27234ec7..d45c342e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ GitHub release + + gitter + + + donate +

English | [简体中文](./README.zh-CN.md) diff --git a/README.zh-CN.md b/README.zh-CN.md index 4d136c84..bc114c3d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -18,6 +18,12 @@ GitHub release + + gitter + + + donate +

简体中文 | [English](./README.md) diff --git a/package.json b/package.json index 7b81aeb2..f76574b0 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "vue": "2.5.17", "vue-count-to": "1.0.13", "vue-i18n": "7.3.2", - "vue-multiselect": "2.1.0", "vue-router": "3.0.1", "vue-splitpane": "1.0.2", "vuedraggable": "^2.16.0", diff --git a/src/components/BackToTop/index.vue b/src/components/BackToTop/index.vue index 2d4b0193..39977178 100644 --- a/src/components/BackToTop/index.vue +++ b/src/components/BackToTop/index.vue @@ -45,7 +45,8 @@ export default { data() { return { visible: false, - interval: null + interval: null, + isMoving: false } }, mounted() { @@ -62,13 +63,16 @@ export default { this.visible = window.pageYOffset > this.visibilityHeight }, backToTop() { + if (this.isMoving) return const start = window.pageYOffset let i = 0 + this.isMoving = true this.interval = setInterval(() => { const next = Math.floor(this.easeInOutQuad(10 * i, start, -start, 500)) if (next <= this.backPosition) { window.scrollTo(0, this.backPosition) clearInterval(this.interval) + this.isMoving = false } else { window.scrollTo(0, next) } diff --git a/src/components/LangSelect/index.vue b/src/components/LangSelect/index.vue index ea381277..31cc80d0 100644 --- a/src/components/LangSelect/index.vue +++ b/src/components/LangSelect/index.vue @@ -22,7 +22,7 @@ export default { this.$i18n.locale = lang this.$store.dispatch('setLanguage', lang) this.$message({ - message: 'switch language success', + message: 'Switch Language Success', type: 'success' }) } diff --git a/src/components/SizeSelect/index.vue b/src/components/SizeSelect/index.vue new file mode 100644 index 00000000..ffc4f77a --- /dev/null +++ b/src/components/SizeSelect/index.vue @@ -0,0 +1,63 @@ + + + + + + diff --git a/src/components/Tinymce/index.vue b/src/components/Tinymce/index.vue index 6383556c..37fd8dd2 100644 --- a/src/components/Tinymce/index.vue +++ b/src/components/Tinymce/index.vue @@ -46,7 +46,16 @@ export default { hasChange: false, hasInit: false, tinymceId: this.id, - fullscreen: false + fullscreen: false, + languageTypeList: { + 'en': 'en', + 'zh': 'zh_CN' + } + } + }, + computed: { + language() { + return this.languageTypeList[this.$store.getters.language] } }, watch: { @@ -55,6 +64,10 @@ export default { this.$nextTick(() => window.tinymce.get(this.tinymceId).setContent(val || '')) } + }, + language() { + this.destroyTinymce() + this.$nextTick(() => this.initTinymce()) } }, mounted() { @@ -73,6 +86,7 @@ export default { initTinymce() { const _this = this window.tinymce.init({ + language: this.language, selector: `#${this.tinymceId}`, height: this.height, body_class: 'panel-body ', diff --git a/src/errorLog.js b/src/errorLog.js index 7f7e492e..00b18b72 100644 --- a/src/errorLog.js +++ b/src/errorLog.js @@ -2,20 +2,18 @@ import Vue from 'vue' import store from './store' // you can set only in production env show the error-log -// if (process.env.NODE_ENV === 'production') { - -Vue.config.errorHandler = function(err, vm, info, a) { +if (process.env.NODE_ENV === 'production') { + Vue.config.errorHandler = function(err, vm, info, a) { // Don't ask me why I use Vue.nextTick, it just a hack. // detail see https://forum.vuejs.org/t/dispatch-in-vue-config-errorhandler-has-some-problem/23500 - Vue.nextTick(() => { - store.dispatch('addErrorLog', { - err, - vm, - info, - url: window.location.href + Vue.nextTick(() => { + store.dispatch('addErrorLog', { + err, + vm, + info, + url: window.location.href + }) + console.error(err, info) }) - console.error(err, info) - }) + } } - -// } diff --git a/src/icons/svg/link.svg b/src/icons/svg/link.svg new file mode 100644 index 00000000..11037e6f --- /dev/null +++ b/src/icons/svg/link.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/size.svg b/src/icons/svg/size.svg new file mode 100644 index 00000000..def290f7 --- /dev/null +++ b/src/icons/svg/size.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/src/lang/en.js b/src/lang/en.js index d47b557f..677df4fd 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -60,14 +60,16 @@ export default { exportZip: 'Export Zip', theme: 'Theme', clipboardDemo: 'Clipboard', - i18n: 'I18n' + i18n: 'I18n', + externalLink: 'External Link' }, navbar: { logOut: 'Log Out', dashboard: 'Dashboard', github: 'Github', - screenfull: 'screenfull', - theme: 'theme' + screenfull: 'Screenfull', + theme: 'Theme', + size: 'Global Size' }, login: { title: 'Login Form', diff --git a/src/lang/zh.js b/src/lang/zh.js index 7958b879..c8f494f0 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -60,14 +60,16 @@ export default { exportZip: 'Export Zip', theme: '换肤', clipboardDemo: 'Clipboard', - i18n: '国际化' + i18n: '国际化', + externalLink: '外链' }, navbar: { logOut: '退出登录', dashboard: '首页', github: '项目地址', screenfull: '全屏', - theme: '换肤' + theme: '换肤', + size: '布局大小' }, login: { title: '系统登录', diff --git a/src/main.js b/src/main.js index 1dc4af9e..1ce709c9 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,7 @@ import Vue from 'vue' +import Cookies from 'js-cookie' + import 'normalize.css/normalize.css' // A modern alternative to CSS resets import Element from 'element-ui' @@ -20,7 +22,7 @@ import './mock' // simulation data import * as filters from './filters' // global filters Vue.use(Element, { - size: 'medium', // set element-ui default size + size: Cookies.get('size') || 'medium', // set element-ui default size i18n: (key, value) => i18n.t(key, value) }) diff --git a/src/router/index.js b/src/router/index.js index 76a517c8..2daae31f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -31,6 +31,17 @@ import nestedRouter from './modules/nested' } **/ export const constantRouterMap = [ + { + path: '/redirect', + component: Layout, + hidden: true, + children: [ + { + path: '/redirect/:path*', + component: () => import('@/views/redirect/index') + } + ] + }, { path: '/login', component: () => import('@/views/login/index'), @@ -322,5 +333,16 @@ export const asyncRouterMap = [ ] }, + { + path: 'external-link', + component: Layout, + children: [ + { + path: 'https://github.com/PanJiaChen/vue-element-admin', + meta: { title: 'externalLink', icon: 'link' } + } + ] + }, + { path: '*', redirect: '/404', hidden: true } ] diff --git a/src/store/getters.js b/src/store/getters.js index d68251fd..cf314f5c 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,6 +1,7 @@ const getters = { sidebar: state => state.app.sidebar, language: state => state.app.language, + size: state => state.app.size, device: state => state.app.device, visitedViews: state => state.tagsView.visitedViews, cachedViews: state => state.tagsView.cachedViews, diff --git a/src/store/modules/app.js b/src/store/modules/app.js index d89664f8..bc4fb478 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -7,7 +7,8 @@ const app = { withoutAnimation: false }, device: 'desktop', - language: Cookies.get('language') || 'en' + language: Cookies.get('language') || 'en', + size: Cookies.get('size') || 'medium' }, mutations: { TOGGLE_SIDEBAR: state => { @@ -30,6 +31,10 @@ const app = { SET_LANGUAGE: (state, language) => { state.language = language Cookies.set('language', language) + }, + SET_SIZE: (state, size) => { + state.size = size + Cookies.set('size', size) } }, actions: { @@ -44,6 +49,9 @@ const app = { }, setLanguage({ commit }, language) { commit('SET_LANGUAGE', language) + }, + setSize({ commit }, size) { + commit('SET_SIZE', size) } } } diff --git a/src/utils/index.js b/src/utils/index.js index 3e540802..43a374e4 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -25,7 +25,8 @@ export function parseTime(time, cFormat) { } const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { let value = formatObj[key] - if (key === 'a') { return ['一', '二', '三', '四', '五', '六', '日'][value - 1] } + // Note: getDay() returns 0 on Sunday + if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] } if (result.length > 0 && value < 10) { value = '0' + value } diff --git a/src/views/example/components/ArticleDetail.vue b/src/views/example/components/ArticleDetail.vue index b5511134..c7ec1eb0 100644 --- a/src/views/example/components/ArticleDetail.vue +++ b/src/views/example/components/ArticleDetail.vue @@ -77,8 +77,6 @@ import Tinymce from '@/components/Tinymce' import Upload from '@/components/Upload/singleImage3' import MDinput from '@/components/MDinput' -import Multiselect from 'vue-multiselect'// 使用的一个多选框组件,element-ui的select不能满足所有需求 -import 'vue-multiselect/dist/vue-multiselect.min.css'// 多选框组件css import Sticky from '@/components/Sticky' // 粘性header组件 import { validateURL } from '@/utils/validate' import { fetchArticle } from '@/api/article' @@ -102,7 +100,7 @@ const defaultForm = { export default { name: 'ArticleDetail', - components: { Tinymce, MDinput, Upload, Multiselect, Sticky, Warning, CommentDropdown, PlatformDropdown, SourceUrlDropdown }, + components: { Tinymce, MDinput, Upload, Sticky, Warning, CommentDropdown, PlatformDropdown, SourceUrlDropdown }, props: { isEdit: { type: Boolean, diff --git a/src/views/layout/components/Navbar.vue b/src/views/layout/components/Navbar.vue index 07244584..08f3f9d0 100644 --- a/src/views/layout/components/Navbar.vue +++ b/src/views/layout/components/Navbar.vue @@ -11,6 +11,10 @@ + + + + @@ -48,6 +52,7 @@ import Breadcrumb from '@/components/Breadcrumb' import Hamburger from '@/components/Hamburger' import ErrorLog from '@/components/ErrorLog' import Screenfull from '@/components/Screenfull' +import SizeSelect from '@/components/SizeSelect' import LangSelect from '@/components/LangSelect' import ThemePicker from '@/components/ThemePicker' @@ -57,6 +62,7 @@ export default { Hamburger, ErrorLog, Screenfull, + SizeSelect, LangSelect, ThemePicker }, diff --git a/src/views/layout/components/Sidebar/Item.vue b/src/views/layout/components/Sidebar/Item.vue new file mode 100644 index 00000000..b515f615 --- /dev/null +++ b/src/views/layout/components/Sidebar/Item.vue @@ -0,0 +1,29 @@ + diff --git a/src/views/layout/components/Sidebar/SidebarItem.vue b/src/views/layout/components/Sidebar/SidebarItem.vue index 30a22baf..6e461d4a 100644 --- a/src/views/layout/components/Sidebar/SidebarItem.vue +++ b/src/views/layout/components/Sidebar/SidebarItem.vue @@ -1,28 +1,27 @@