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

View File

@ -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')

View File

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