diff --git a/src/api/policy.js b/src/api/policy.js index 8a2333c..4c871df 100644 --- a/src/api/policy.js +++ b/src/api/policy.js @@ -16,3 +16,51 @@ export function PolicyDetail(data) { }) } +export function PolicyUpdate(data) { + return request({ + url: `/gateway${policy}/PolicyUpdate`, + method: 'post', + data: { + param: { + auditStatus: data.auditStatus, + content: data.content, + id: data.id, + imgUrl: data.imgUrl, + intro: data.intro, + title: data.title, + titleUrl: data.titleUrl, + type: data.type + } + } + }) +} + +export function PolicyDelete(id) { + return request({ + url: `/gateway${policy}/PolicyDelete`, + method: 'post', + data: { + param: { + id: id + } + } + }) +} + +export function PolicyAdd(data) { + console.log(data) + return request({ + url: `/gateway${policy}/PolicyAdd`, + method: 'post', + data: { + param: { + content: data.content, + imgUrl: data.imgUrl, + intro: data.intro, + publishTime: data.publishTime, + title: data.title, + titleUrl: data.titleUrl + } + } + }) +} diff --git a/src/assets/404_images/touxiang.jpg b/src/assets/404_images/touxiang.jpg new file mode 100644 index 0000000..913bac4 Binary files /dev/null and b/src/assets/404_images/touxiang.jpg differ diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 0ca5cf6..a702483 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -7,23 +7,18 @@
- + +
- Home + 主页 - - Github - - - Docs - - Log Out + 退出登录
diff --git a/src/main.js b/src/main.js index ca707a8..79bd1fe 100644 --- a/src/main.js +++ b/src/main.js @@ -4,7 +4,7 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' -import locale from 'element-ui/lib/locale/lang/en' // lang i18n +// import locale from 'element-ui/lib/locale/lang/en' // lang i18n import '@/styles/index.scss' // global css @@ -28,7 +28,7 @@ if (process.env.NODE_ENV === 'production') { mockXHR() } // set ElementUI lang to EN -Vue.use(ElementUI, { locale }) +Vue.use(ElementUI) // 如果想要中文版 element-ui,按如下方式声明 // Vue.use(ElementUI) diff --git a/src/router/index.js b/src/router/index.js index 6dd6c28..db8c020 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -78,6 +78,12 @@ export const constantRoutes = [ name: 'Train', component: () => import('@/views/firstPages/train'), meta: { title: '培训管理', icon: '' } + }, + { + path: 'typemanage', + name: 'Typemanage', + component: () => import('@/views/firstPages/typemanage'), + meta: { title: '类型管理', icon: '' } }] }, diff --git a/src/utils/error-log.js b/src/utils/error-log.js new file mode 100644 index 0000000..a7f5b55 --- /dev/null +++ b/src/utils/error-log.js @@ -0,0 +1,35 @@ +import Vue from 'vue' +import store from '@/store' +import { isString, isArray } from '@/utils/validate' +import settings from '@/settings' + +// you can set in settings.js +// errorLog:'production' | ['production', 'development'] +const { errorLog: needErrorLog } = settings + +function checkNeed() { + const env = process.env.NODE_ENV + if (isString(needErrorLog)) { + return env === needErrorLog + } + if (isArray(needErrorLog)) { + return needErrorLog.includes(env) + } + return false +} + +if (checkNeed()) { + 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('errorLog/addErrorLog', { + err, + vm, + info, + url: window.location.href + }) + console.error(err, info) + }) + } +} diff --git a/src/utils/open-window.js b/src/utils/open-window.js new file mode 100644 index 0000000..1a655d7 --- /dev/null +++ b/src/utils/open-window.js @@ -0,0 +1,25 @@ +/** + *Created by PanJiaChen on 16/11/29. + * @param {Sting} url + * @param {Sting} title + * @param {Number} w + * @param {Number} h + */ +export default function openWindow(url, title, w, h) { + // Fixes dual-screen position Most browsers Firefox + const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left + const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top + + const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width + const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height + + const left = ((width / 2) - (w / 2)) + dualScreenLeft + const top = ((height / 2) - (h / 2)) + dualScreenTop + const newWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left) + + // Puts focus on the newWindow + if (window.focus) { + newWindow.focus() + } +} + diff --git a/src/utils/permission.js b/src/utils/permission.js new file mode 100644 index 0000000..8e2bbad --- /dev/null +++ b/src/utils/permission.js @@ -0,0 +1,21 @@ +import store from '@/store' + +/** + * @param {Array} value + * @returns {Boolean} + * @example see @/views/permission/directive.vue + */ +export default function checkPermission(value) { + if (value && value instanceof Array && value.length > 0) { + const roles = store.getters && store.getters.roles + const permissionRoles = value + + const hasPermission = roles.some(role => { + return permissionRoles.includes(role) + }) + return hasPermission + } else { + console.error(`need roles! Like v-permission="['admin','editor']"`) + return false + } +} diff --git a/src/utils/scroll-to.js b/src/utils/scroll-to.js new file mode 100644 index 0000000..c5d8e04 --- /dev/null +++ b/src/utils/scroll-to.js @@ -0,0 +1,58 @@ +Math.easeInOutQuad = function(t, b, c, d) { + t /= d / 2 + if (t < 1) { + return c / 2 * t * t + b + } + t-- + return -c / 2 * (t * (t - 2) - 1) + b +} + +// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts +var requestAnimFrame = (function() { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) } +})() + +/** + * Because it's so fucking difficult to detect the scrolling element, just move them all + * @param {number} amount + */ +function move(amount) { + document.documentElement.scrollTop = amount + document.body.parentNode.scrollTop = amount + document.body.scrollTop = amount +} + +function position() { + return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop +} + +/** + * @param {number} to + * @param {number} duration + * @param {Function} callback + */ +export function scrollTo(to, duration, callback) { + const start = position() + const change = to - start + const increment = 20 + let currentTime = 0 + duration = (typeof (duration) === 'undefined') ? 500 : duration + var animateScroll = function() { + // increment the time + currentTime += increment + // find the value with the quadratic in-out easing function + var val = Math.easeInOutQuad(currentTime, start, change, duration) + // move the document.body + move(val) + // do the animation unless its over + if (currentTime < duration) { + requestAnimFrame(animateScroll) + } else { + if (callback && typeof (callback) === 'function') { + // the animation is done so lets callback + callback() + } + } + } + animateScroll() +} diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 62ab038..414c4aa 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,6 +1,6 @@ diff --git a/src/views/firstPages/policy.vue b/src/views/firstPages/policy.vue index 5d12a19..3a50299 100644 --- a/src/views/firstPages/policy.vue +++ b/src/views/firstPages/policy.vue @@ -1,8 +1,9 @@