perf: 代码优化 统一将 props 运行时声明修改为类型声明
This commit is contained in:
parent
d1c7480a4f
commit
75eadd2094
@ -1,13 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { type PropType } from "vue"
|
|
||||||
import { type ListItem } from "./data"
|
import { type ListItem } from "./data"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
list: {
|
list: ListItem[]
|
||||||
type: Object as PropType<ListItem[]>,
|
}
|
||||||
required: true
|
|
||||||
}
|
const props = defineProps<Props>()
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -3,22 +3,19 @@ import { ref, watchEffect } from "vue"
|
|||||||
import { ElMessage } from "element-plus"
|
import { ElMessage } from "element-plus"
|
||||||
import screenfull from "screenfull"
|
import screenfull from "screenfull"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
|
element?: string
|
||||||
|
openTips?: string
|
||||||
|
exitTips?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
/** 全屏的元素,默认是 html */
|
/** 全屏的元素,默认是 html */
|
||||||
element: {
|
element: "html",
|
||||||
type: String,
|
|
||||||
default: "html"
|
|
||||||
},
|
|
||||||
/** 打开全屏提示语 */
|
/** 打开全屏提示语 */
|
||||||
openTips: {
|
openTips: "全屏",
|
||||||
type: String,
|
|
||||||
default: "全屏"
|
|
||||||
},
|
|
||||||
/** 关闭全屏提示语 */
|
/** 关闭全屏提示语 */
|
||||||
exitTips: {
|
exitTips: "退出全屏"
|
||||||
type: String,
|
|
||||||
default: "退出全屏"
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tips = ref<string>(props.openTips)
|
const tips = ref<string>(props.openTips)
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from "vue"
|
import { computed } from "vue"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
prefix: {
|
prefix?: string
|
||||||
type: String,
|
name: string
|
||||||
default: "icon"
|
}
|
||||||
},
|
|
||||||
name: {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
type: String,
|
prefix: "icon"
|
||||||
required: true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
|
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Expand, Fold } from "@element-plus/icons-vue"
|
import { Expand, Fold } from "@element-plus/icons-vue"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
isActive: {
|
isActive?: boolean
|
||||||
type: Boolean,
|
}
|
||||||
default: false
|
|
||||||
}
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
isActive: false
|
||||||
})
|
})
|
||||||
|
|
||||||
/** Vue 3.3+ defineEmits 语法 */
|
/** Vue 3.3+ defineEmits 语法 */
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
import { ref } from "vue"
|
import { ref } from "vue"
|
||||||
import { Setting } from "@element-plus/icons-vue"
|
import { Setting } from "@element-plus/icons-vue"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
buttonTop: {
|
buttonTop?: number
|
||||||
type: Number,
|
}
|
||||||
default: 350
|
|
||||||
}
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
buttonTop: 350
|
||||||
})
|
})
|
||||||
|
|
||||||
const buttonTopCss = props.buttonTop + "px"
|
const buttonTopCss = props.buttonTop + "px"
|
||||||
|
@ -1,27 +1,21 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { type PropType, computed } from "vue"
|
import { computed } from "vue"
|
||||||
import { type RouteRecordRaw } from "vue-router"
|
import { type RouteRecordRaw } from "vue-router"
|
||||||
import SidebarItemLink from "./SidebarItemLink.vue"
|
import SidebarItemLink from "./SidebarItemLink.vue"
|
||||||
import { isExternal } from "@/utils/validate"
|
import { isExternal } from "@/utils/validate"
|
||||||
import path from "path-browserify"
|
import path from "path-browserify"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
item: {
|
item: RouteRecordRaw
|
||||||
type: Object as PropType<RouteRecordRaw>,
|
isCollapse?: boolean
|
||||||
required: true
|
isFirstLevel?: boolean
|
||||||
},
|
basePath?: string
|
||||||
isCollapse: {
|
}
|
||||||
type: Boolean,
|
|
||||||
default: false
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
},
|
isCollapse: false,
|
||||||
isFirstLevel: {
|
isFirstLevel: true,
|
||||||
type: Boolean,
|
basePath: ""
|
||||||
default: true
|
|
||||||
},
|
|
||||||
basePath: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 是否始终显示根菜单 */
|
/** 是否始终显示根菜单 */
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { isExternal } from "@/utils/validate"
|
import { isExternal } from "@/utils/validate"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
to: {
|
to: string
|
||||||
type: String,
|
}
|
||||||
required: true
|
|
||||||
}
|
const props = defineProps<Props>()
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
collapse: {
|
collapse?: boolean
|
||||||
type: Boolean,
|
}
|
||||||
default: true
|
|
||||||
}
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
collapse: true
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
<script lang="ts" setup>
|
<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 { RouterLink, useRoute } from "vue-router"
|
||||||
import { ElScrollbar } from "element-plus"
|
import { ElScrollbar } from "element-plus"
|
||||||
import { ArrowLeft, ArrowRight } from "@element-plus/icons-vue"
|
import { ArrowLeft, ArrowRight } from "@element-plus/icons-vue"
|
||||||
import { useSettingsStore } from "@/store/modules/settings"
|
import { useSettingsStore } from "@/store/modules/settings"
|
||||||
import Screenfull from "@/components/Screenfull/index.vue"
|
import Screenfull from "@/components/Screenfull/index.vue"
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
tagRefs: {
|
tagRefs: InstanceType<typeof RouterLink>[]
|
||||||
type: Object as PropType<InstanceType<typeof RouterLink>[]>,
|
}
|
||||||
required: true
|
|
||||||
}
|
const props = defineProps<Props>()
|
||||||
})
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user