add csrf token and some useful function on window

This commit is contained in:
virusdefender 2016-11-19 17:15:51 +08:00
parent 77a2ebd81a
commit 7326e80b4c
3 changed files with 47 additions and 5 deletions

View File

@ -15,7 +15,7 @@
<script> <script>
import SideMenu from './components/SideMenu.vue' import SideMenu from './components/SideMenu.vue'
import api from './api.js' // import api from './api.js'
export default { export default {
name: 'app', name: 'app',
components: { components: {
@ -24,7 +24,7 @@ export default {
methods: { methods: {
}, },
mounted () { mounted () {
api.login('root', '047e09').then(res => {}) // api.login('root', '277555').then(res => {})
} }
} }
</script> </script>

View File

@ -10,7 +10,7 @@ Vue.use(VueRouter)
// Vue.use(VueI18n) // Vue.use(VueI18n)
// 引入 view 组件 // 引入 view 组件
import { Announcement, User } from './views' import { Announcement, User, Conf } from './views'
const router = new VueRouter({ const router = new VueRouter({
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: [ routes: [
@ -24,7 +24,49 @@ const router = new VueRouter({
name: 'user', name: 'user',
component: 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') new Vue(Vue.util.extend({ router }, App)).$mount('#app')

View File

@ -100,7 +100,7 @@
window.success() window.success()
}) })
} else { } else {
api.saveSMTPConfig(this.smtp).then(res => { api.createSMTPConfig(this.smtp).then(res => {
window.success() window.success()
}) })
} }