mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-05 22:30:28 +08:00
33 lines
627 B
JavaScript
33 lines
627 B
JavaScript
Vue.component("csrf-token", {
|
|
created: function () {
|
|
this.refreshToken()
|
|
},
|
|
mounted: function () {
|
|
let that = this
|
|
this.$refs.token.form.addEventListener("submit", function () {
|
|
that.refreshToken()
|
|
})
|
|
|
|
// 自动刷新
|
|
setInterval(function () {
|
|
that.refreshToken()
|
|
}, 10 * 60 * 1000)
|
|
},
|
|
data: function () {
|
|
return {
|
|
token: ""
|
|
}
|
|
},
|
|
methods: {
|
|
refreshToken: function () {
|
|
let that = this
|
|
Tea.action("/csrf/token")
|
|
.get()
|
|
.success(function (resp) {
|
|
that.token = resp.data.token
|
|
})
|
|
}
|
|
},
|
|
template: `<input type="hidden" name="csrfToken" :value="token" ref="token"/>`
|
|
})
|