dataease/frontend/src/views/link/index.vue

64 lines
1.2 KiB
Vue
Raw Normal View History

2021-03-25 18:58:05 +08:00
<template>
<div>
<link-error v-if="showIndex===0" />
2021-03-26 18:44:41 +08:00
<link-pwd v-if="showIndex===1" :resource-id="resourceId" />
2021-03-25 18:58:05 +08:00
<link-view v-if="showIndex===2" />
</div>
</template>
<script>
import { getQueryVariable } from '@/utils/index'
import { validate } from '@/api/link'
import LinkView from './view'
import LinkError from './error'
import LinkPwd from './pwd'
export default {
components: {
LinkError, LinkPwd, LinkView
},
data() {
return {
PARAMKEY: 'link',
link: null,
showIndex: -1
}
},
created() {
this.loadInit()
},
methods: {
loadInit() {
this.link = getQueryVariable(this.PARAMKEY)
2021-03-26 18:44:41 +08:00
validate({ link: this.link }).then(res => {
2021-03-25 18:58:05 +08:00
const { valid, enablePwd, passPwd } = res.data
// 如果链接无效 直接显示无效页面
2021-03-26 18:44:41 +08:00
if (!valid) {
this.showError()
return
}
2021-03-25 18:58:05 +08:00
2021-03-26 18:44:41 +08:00
if (enablePwd && !passPwd) {
this.showPwd()
return
}
2021-03-25 18:58:05 +08:00
this.showView()
})
},
2021-03-26 18:44:41 +08:00
2021-03-25 18:58:05 +08:00
// 显示无效链接
showError() {
this.showIndex = 0
},
// 显示密码框
showPwd() {
this.showIndex = 1
},
// 显示仪表板
showView() {
this.showIndex = 2
}
}
}
</script>