refactor: 重构 management/components 目录下组件, 使用 Vue3 组合式 API 写法 (#151)

This commit is contained in:
alwayrun 2024-05-23 11:49:48 +08:00 committed by GitHub
parent 734e33edbb
commit 57918272ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 57 deletions

View File

@ -5,19 +5,19 @@
<div class="desc" v-html="data.desc"></div> <div class="desc" v-html="data.desc"></div>
</div> </div>
</template> </template>
<script setup lang="ts">
<script> type DataType = {
export default { img: string
name: 'EmptyModule', title: string
props: { desc: string
data: {
type: Object,
required: true
}
}
} }
</script>
interface Props {
data: DataType
}
defineProps<Props>()
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
.default-empty-root { .default-empty-root {
width: 350px; width: 350px;

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="nav"> <div class="nav">
<LogoIcon /> <LogoIcon />
<RouterLink v-for="(tab, index) in tabList" :key="index" class="tab-btn" :to="tab.to" replace> <RouterLink v-for="(tab, index) in tabs" :key="index" class="tab-btn" :to="tab.to" replace>
<div class="icon"> <div class="icon">
<i class="iconfont" :class="tab.icon"></i> <i class="iconfont" :class="tab.icon"></i>
</div> </div>
@ -10,44 +10,33 @@
</div> </div>
</template> </template>
<script> <script setup>
import LogoIcon from './LogoIcon.vue' import LogoIcon from './LogoIcon.vue'
export default { const tabs = [
name: 'LeftMenu', {
components: { text: '编辑问卷',
LogoIcon icon: 'icon-bianji',
to: {
name: 'QuestionEditIndex'
}
}, },
data() { {
return { text: '投放问卷',
tabList: [ icon: 'icon-toufang',
{ to: {
text: '编辑问卷', name: 'publishResultPage'
icon: 'icon-bianji', }
to: { },
name: 'QuestionEditIndex' {
} text: '数据统计',
}, icon: 'icon-shujutongji',
{ to: {
text: '投放问卷', name: 'analysisPage'
icon: 'icon-toufang',
to: {
name: 'publishResultPage'
}
},
{
text: '数据统计',
icon: 'icon-shujutongji',
to: {
name: 'analysisPage'
}
}
]
} }
} }
} ]
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.nav { .nav {
width: 80px; width: 80px;
@ -69,7 +58,6 @@ export default {
&:hover { &:hover {
color: $normal-color; color: $normal-color;
// background-color: $background-color-light;
.icon { .icon {
background-color: $disable-color; background-color: $disable-color;
} }

View File

@ -1,22 +1,17 @@
<template> <template>
<div class="navbar-main-logo" @click="toHomePage"> <div class="navbar-main-logo" @click="handleNavigate">
<img src="/imgs/s-logo.webp" /> <img src="/imgs/s-logo.webp" />
</div> </div>
</template> </template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
<script> const router = useRouter()
export default {
name: 'LogoIcon', const handleNavigate = () => {
methods: { router.push({ name: 'survey' })
toHomePage() {
this.$router.push({
name: 'survey'
})
}
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.navbar-main-logo { .navbar-main-logo {
width: 80px; width: 80px;