refactor: 改为Vue3.5解构语法 (#799)

This commit is contained in:
liect 2024-12-17 18:55:36 +08:00 committed by GitHub
parent 3dfa8f2444
commit d235ea2857
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 12 additions and 20 deletions

View File

@ -9,14 +9,13 @@ import { DEFAULT_COLOR_OPTIONS } from '@/config/color';
const panelColor = const panelColor =
'conic-gradient(from 90deg at 50% 50%, #FF0000 -19.41deg, #FF0000 18.76deg, #FF8A00 59.32deg, #FFE600 99.87deg, #14FF00 141.65deg, #00A3FF 177.72deg, #0500FF 220.23deg, #AD00FF 260.13deg, #FF00C7 300.69deg, #FF0000 340.59deg, #FF0000 378.76deg)'; 'conic-gradient(from 90deg at 50% 50%, #FF0000 -19.41deg, #FF0000 18.76deg, #FF8A00 59.32deg, #FFE600 99.87deg, #14FF00 141.65deg, #00A3FF 177.72deg, #0500FF 220.23deg, #AD00FF 260.13deg, #FF00C7 300.69deg, #FF0000 340.59deg, #FF0000 378.76deg)';
const props = defineProps({ const { value } = defineProps({
value: { value: {
type: String, type: String,
}, },
}); });
const style = computed(() => { const style = computed(() => {
const { value } = props;
return { return {
background: DEFAULT_COLOR_OPTIONS.indexOf(value) > -1 ? value : panelColor, background: DEFAULT_COLOR_OPTIONS.indexOf(value) > -1 ? value : panelColor,
}; };

View File

@ -18,7 +18,7 @@ import ResultIeIcon from '@/assets/assets-result-ie.svg?component';
import ResultMaintenanceIcon from '@/assets/assets-result-maintenance.svg?component'; import ResultMaintenanceIcon from '@/assets/assets-result-maintenance.svg?component';
import ResultWifiIcon from '@/assets/assets-result-wifi.svg?component'; import ResultWifiIcon from '@/assets/assets-result-wifi.svg?component';
const props = defineProps({ const { type } = defineProps({
bgUrl: String, bgUrl: String,
title: String, title: String,
tip: String, tip: String,
@ -26,7 +26,7 @@ const props = defineProps({
}); });
const dynamicComponent = computed(() => { const dynamicComponent = computed(() => {
switch (props.type) { switch (type) {
case '403': case '403':
return Result403Icon; return Result403Icon;
case '404': case '404':

View File

@ -4,7 +4,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'; import { computed } from 'vue';
const props = defineProps({ const { type } = defineProps({
url: String, url: String,
type: { type: {
type: String, type: String,
@ -13,7 +13,6 @@ const props = defineProps({
}); });
const className = computed(() => { const className = computed(() => {
const { type } = props;
return [ return [
'thumbnail-container', 'thumbnail-container',
{ {

View File

@ -23,7 +23,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'; import { computed } from 'vue';
const props = defineProps({ const { type, isReverseColor } = defineProps({
type: String, type: String,
describe: [String, Number], describe: [String, Number],
isReverseColor: { isReverseColor: {
@ -33,7 +33,6 @@ const props = defineProps({
}); });
const containerCls = computed(() => { const containerCls = computed(() => {
const { isReverseColor, type } = props;
return [ return [
'trend-container', 'trend-container',
{ {

View File

@ -95,7 +95,7 @@ import MenuContent from './MenuContent.vue';
import Notice from './Notice.vue'; import Notice from './Notice.vue';
import Search from './Search.vue'; import Search from './Search.vue';
const props = defineProps({ const { theme, layout, showLogo, menu, isFixed, isCompact } = defineProps({
theme: { theme: {
type: String, type: String,
default: 'light', default: 'light',
@ -141,7 +141,6 @@ const active = computed(() => getActive());
const layoutCls = computed(() => [`${prefix}-header-layout`]); const layoutCls = computed(() => [`${prefix}-header-layout`]);
const menuCls = computed(() => { const menuCls = computed(() => {
const { isFixed, layout, isCompact } = props;
return [ return [
{ {
[`${prefix}-header-menu`]: !isFixed, [`${prefix}-header-menu`]: !isFixed,
@ -151,7 +150,7 @@ const menuCls = computed(() => {
}, },
]; ];
}); });
const menuTheme = computed(() => props.theme as ModeType); const menuTheme = computed(() => theme as ModeType);
// //
const { changeLocale } = useLocale(); const { changeLocale } = useLocale();

View File

@ -34,7 +34,7 @@ import type { MenuRoute } from '@/types/interface';
type ListItemType = MenuRoute & { icon?: string }; type ListItemType = MenuRoute & { icon?: string };
const props = defineProps({ const { navData } = defineProps({
navData: { navData: {
type: Array as PropType<MenuRoute[]>, type: Array as PropType<MenuRoute[]>,
default: () => [], default: () => [],
@ -45,7 +45,6 @@ const active = computed(() => getActive());
const { locale } = useLocale(); const { locale } = useLocale();
const list = computed(() => { const list = computed(() => {
const { navData } = props;
return getMenuList(navData); return getMenuList(navData);
}); });

View File

@ -42,7 +42,7 @@ import MenuContent from './MenuContent.vue';
const MIN_POINT = 992 - 1; const MIN_POINT = 992 - 1;
const props = defineProps({ const { menu, showLogo, isFixed, layout, theme, isCompact } = defineProps({
menu: { menu: {
type: Array as PropType<MenuRoute[]>, type: Array as PropType<MenuRoute[]>,
default: () => [], default: () => [],
@ -97,11 +97,9 @@ const onExpanded = (value: MenuValue[]) => {
}; };
const sideMode = computed(() => { const sideMode = computed(() => {
const { theme } = props;
return theme === 'dark'; return theme === 'dark';
}); });
const sideNavCls = computed(() => { const sideNavCls = computed(() => {
const { isCompact } = props;
return [ return [
`${prefix}-sidebar-layout`, `${prefix}-sidebar-layout`,
{ {
@ -126,7 +124,6 @@ const versionCls = computed(() => {
]; ];
}); });
const menuCls = computed(() => { const menuCls = computed(() => {
const { showLogo, isFixed, layout } = props;
return [ return [
`${prefix}-side-nav`, `${prefix}-side-nav`,
{ {

View File

@ -65,7 +65,7 @@ const SELECT_OPTIONS = [
{ label: 'CVM', value: '3' }, { label: 'CVM', value: '3' },
]; ];
const props = defineProps({ const { visible, data } = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -100,14 +100,14 @@ watch(
); );
watch( watch(
() => props.visible, () => visible,
(val) => { (val) => {
formVisible.value = val; formVisible.value = val;
}, },
); );
watch( watch(
() => props.data, () => data,
(val) => { (val) => {
formData.value = val; formData.value = val;
}, },