From 7326e80b4cb45cee6222f0ac3c685dbbdf8efa73 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Sat, 19 Nov 2016 17:15:51 +0800 Subject: [PATCH] add csrf token and some useful function on window --- src/App.vue | 4 ++-- src/main.js | 46 ++++++++++++++++++++++++++++++++++++++++++++-- src/views/Conf.vue | 2 +- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index 594f5b2..7ef37c1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,7 +15,7 @@ diff --git a/src/main.js b/src/main.js index 8cef7ca..1d576b1 100644 --- a/src/main.js +++ b/src/main.js @@ -10,7 +10,7 @@ Vue.use(VueRouter) // Vue.use(VueI18n) // 引入 view 组件 -import { Announcement, User } from './views' +import { Announcement, User, Conf } from './views' const router = new VueRouter({ scrollBehavior: () => ({ y: 0 }), routes: [ @@ -24,7 +24,49 @@ const router = new VueRouter({ name: 'user', component: User }, - { path: '*', redirect: '/announcement' } + { + path: '/conf', + name: 'conf', + component: Conf + }, + { + path: '*', redirect: '/announcement' + } ] }) + +for (var msgType of ['success', 'warning', 'info', 'error']) { + window[msgType] = (msg) => { + Vue.prototype.$message({ + showClose: true, + message: msg, + type: msgType + }) + } +} + +var message = (msg, msgType) => { + Vue.prototype.$message({ + showClose: true, + message: msg, + type: msgType + }) +} + +window.error = (msg) => { + message(msg, 'error') +} + +window.alert = (msg) => { + message(msg, 'info') +} + +window.success = (msg) => { + if (!msg) { + message('Succeeded', 'success') + } else { + message(msg, 'success') + } +} + new Vue(Vue.util.extend({ router }, App)).$mount('#app') diff --git a/src/views/Conf.vue b/src/views/Conf.vue index 67f37e5..891afc1 100644 --- a/src/views/Conf.vue +++ b/src/views/Conf.vue @@ -100,7 +100,7 @@ window.success() }) } else { - api.saveSMTPConfig(this.smtp).then(res => { + api.createSMTPConfig(this.smtp).then(res => { window.success() }) }