Files
dvcp_v2_webapp/examples/App.vue

139 lines
3.2 KiB
Vue
Raw Normal View History

2021-12-14 18:36:19 +08:00
<template>
<div id="app">
2022-06-13 10:46:55 +08:00
<header-nav v-if="showTools" title="web端产品库">
<template #right>
<mock/>
2024-09-03 15:49:06 +08:00
<div @click="showTools=false,dvDev=true">大屏开发</div>
<div @click="showTools=false">隐藏工具栏</div>
<div @click="handleLogin">点此登录</div>
</template>
</header-nav>
2024-09-03 15:49:06 +08:00
<ai-dv-wrapper class="fill" :views="[{label: '返回'}]" v-if="dvDev">
<router-view/>
</ai-dv-wrapper>
<el-row v-else-if="showTools" class="fill mar-t48" type="flex">
2022-08-25 09:54:56 +08:00
<slider-nav/>
<main-content class="fill"/>
2021-12-14 18:36:19 +08:00
</el-row>
2022-08-25 09:54:56 +08:00
<router-view class="fill" v-else/>
2021-12-14 18:36:19 +08:00
<div v-if="dialog" class="sign-box">
2022-07-27 10:24:38 +08:00
<ai-sign style="margin: auto" :instance="$request" :action="{login}"
2021-12-14 18:36:19 +08:00
visible @login="getToken" :showScanLogin="false"/>
</div>
<el-button type="info" v-if="!showTools" class="fixedBtn" @click="showTools=true">显示工具栏</el-button>
</div>
</template>
<script>
import SliderNav from "./components/sliderNav";
import MainContent from "./components/mainContent";
import HeaderNav from "./components/headerNav";
2022-07-19 15:20:10 +08:00
import {mapActions, mapMutations, mapState} from "vuex";
import Mock from "./components/mock";
2024-09-03 15:49:06 +08:00
import AiDvWrapper from "@dui/dv/layout/AiDvWrapper/AiDvWrapper.vue";
2021-12-14 18:36:19 +08:00
export default {
name: 'app',
2024-09-03 15:49:06 +08:00
components: {AiDvWrapper, Mock, HeaderNav, MainContent, SliderNav},
2021-12-14 18:36:19 +08:00
computed: {
2022-05-16 11:10:11 +08:00
...mapState(['user']),
2022-03-23 11:23:32 +08:00
login() {
let url = '/auth/oauth/token';
/project\/sass/g.test(location.pathname) && (url += "?corpId=ww596787bb70f08288")
return url
},
},
2021-12-14 18:36:19 +08:00
data() {
return {
dialog: false,
showTools: true,
2024-09-03 15:49:06 +08:00
dvDev: false
}
},
watch: {
showTools(v) {
v && (this.dvDev = false)
2021-12-14 18:36:19 +08:00
}
},
methods: {
2022-08-29 11:16:25 +08:00
...mapMutations(['setToken']),
...mapActions(['getUserInfo', 'getFinanceUser']),
2021-12-14 18:36:19 +08:00
getToken(params) {
2022-06-28 09:15:10 +08:00
if (params.access_token) {
this.setToken([params.token_type, params.access_token].join(' '))
this.dialog = false
this.$message.success("登录成功,正在刷新页面...")
location.reload()
} else this.$message.error(params.msg || "登录失败!")
2021-12-14 18:36:19 +08:00
},
handleLogin() {
2022-07-27 10:24:38 +08:00
this.$request.delete("/auth/token/logout").finally(() => {
2021-12-14 18:36:19 +08:00
this.dialog = true
})
},
handleMock() {
}
2021-12-14 18:36:19 +08:00
},
created() {
wx = jWeixin
if (this.user.token) this.getUserInfo().finally(() => {
2022-07-19 15:20:10 +08:00
if (/^\/project\/xiushan/.test(location.pathname)) {
this.getFinanceUser()
2022-07-19 15:20:10 +08:00
}
})
2021-12-14 18:36:19 +08:00
}
}
</script>
<style lang="scss">
html, body {
width: 100%;
height: 100%;
margin: 0;
}
.mar-t48 {
margin-top: 48px;
}
2021-12-14 18:36:19 +08:00
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
overflow: hidden;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
.fixedBtn {
position: fixed;
top: 0;
right: 60px;
opacity: 0;
&:hover {
opacity: 1;
}
}
li {
list-style-type: none;
}
.sign-box {
z-index: 99;
margin: -10px;
display: flex;
position: fixed;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.2);
}
}
2021-12-14 18:36:19 +08:00
</style>