Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-20 19:09:21 +08:00

perf: 代码优化 统一将 props 运行时声明修改为类型声明

This commit is contained in:
pany 2023-06-20 18:40:18 +08:00
parent d1c7480a4f
commit 75eadd2094
9 changed files with 63 additions and 75 deletions

View File

@ -1,13 +1,11 @@
<script lang="ts" setup>
import { type PropType } from "vue"
import { type ListItem } from "./data"
const props = defineProps({
list: {
type: Object as PropType<ListItem[]>,
required: true
}
})
interface Props {
list: ListItem[]
}
const props = defineProps<Props>()
</script>
<template>

View File

@ -3,22 +3,19 @@ import { ref, watchEffect } from "vue"
import { ElMessage } from "element-plus"
import screenfull from "screenfull"
const props = defineProps({
interface Props {
element?: string
openTips?: string
exitTips?: string
}
const props = withDefaults(defineProps<Props>(), {
/** 全屏的元素,默认是 html */
element: {
type: String,
default: "html"
},
element: "html",
/** 打开全屏提示语 */
openTips: {
type: String,
default: "全屏"
},
openTips: "全屏",
/** 关闭全屏提示语 */
exitTips: {
type: String,
default: "退出全屏"
}
exitTips: "退出全屏"
})
const tips = ref<string>(props.openTips)

View File

@ -1,15 +1,13 @@
<script lang="ts" setup>
import { computed } from "vue"
const props = defineProps({
prefix: {
type: String,
default: "icon"
},
name: {
type: String,
required: true
}
interface Props {
prefix?: string
name: string
}
const props = withDefaults(defineProps<Props>(), {
prefix: "icon"
})
const symbolId = computed(() => `#${props.prefix}-${props.name}`)

View File

@ -1,11 +1,12 @@
<script lang="ts" setup>
import { Expand, Fold } from "@element-plus/icons-vue"
const props = defineProps({
isActive: {
type: Boolean,
default: false
}
interface Props {
isActive?: boolean
}
const props = withDefaults(defineProps<Props>(), {
isActive: false
})
/** Vue 3.3+ defineEmits 语法 */

View File

@ -2,11 +2,12 @@
import { ref } from "vue"
import { Setting } from "@element-plus/icons-vue"
const props = defineProps({
buttonTop: {
type: Number,
default: 350
}
interface Props {
buttonTop?: number
}
const props = withDefaults(defineProps<Props>(), {
buttonTop: 350
})
const buttonTopCss = props.buttonTop + "px"

View File

@ -1,27 +1,21 @@
<script lang="ts" setup>
import { type PropType, computed } from "vue"
import { computed } from "vue"
import { type RouteRecordRaw } from "vue-router"
import SidebarItemLink from "./SidebarItemLink.vue"
import { isExternal } from "@/utils/validate"
import path from "path-browserify"
const props = defineProps({
item: {
type: Object as PropType<RouteRecordRaw>,
required: true
},
isCollapse: {
type: Boolean,
default: false
},
isFirstLevel: {
type: Boolean,
default: true
},
basePath: {
type: String,
default: ""
}
interface Props {
item: RouteRecordRaw
isCollapse?: boolean
isFirstLevel?: boolean
basePath?: string
}
const props = withDefaults(defineProps<Props>(), {
isCollapse: false,
isFirstLevel: true,
basePath: ""
})
/** 是否始终显示根菜单 */

View File

@ -1,12 +1,11 @@
<script lang="ts" setup>
import { isExternal } from "@/utils/validate"
const props = defineProps({
to: {
type: String,
required: true
}
})
interface Props {
to: string
}
const props = defineProps<Props>()
</script>
<template>

View File

@ -1,9 +1,10 @@
<script lang="ts" setup>
const props = defineProps({
collapse: {
type: Boolean,
default: true
}
interface Props {
collapse?: boolean
}
const props = withDefaults(defineProps<Props>(), {
collapse: true
})
</script>

View File

@ -1,17 +1,16 @@
<script lang="ts" setup>
import { type PropType, ref, watch, nextTick } from "vue"
import { ref, watch, nextTick } from "vue"
import { RouterLink, useRoute } from "vue-router"
import { ElScrollbar } from "element-plus"
import { ArrowLeft, ArrowRight } from "@element-plus/icons-vue"
import { useSettingsStore } from "@/store/modules/settings"
import Screenfull from "@/components/Screenfull/index.vue"
const props = defineProps({
tagRefs: {
type: Object as PropType<InstanceType<typeof RouterLink>[]>,
required: true
}
})
interface Props {
tagRefs: InstanceType<typeof RouterLink>[]
}
const props = defineProps<Props>()
const route = useRoute()
const settingsStore = useSettingsStore()