Skip to content

Commit

Permalink
refactor: 改为Vue3.5解构语法
Browse files Browse the repository at this point in the history
  • Loading branch information
liect committed Dec 17, 2024
1 parent 3dfa8f2 commit e06d023
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 20 deletions.
3 changes: 1 addition & 2 deletions src/components/color/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import { DEFAULT_COLOR_OPTIONS } from '@/config/color';
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)';
const props = defineProps({
const { value } = defineProps({
value: {
type: String,
},
});
const style = computed(() => {
const { value } = props;
return {
background: DEFAULT_COLOR_OPTIONS.indexOf(value) > -1 ? value : panelColor,
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/result/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import ResultIeIcon from '@/assets/assets-result-ie.svg?component';
import ResultMaintenanceIcon from '@/assets/assets-result-maintenance.svg?component';
import ResultWifiIcon from '@/assets/assets-result-wifi.svg?component';
const props = defineProps({
const { type } = defineProps({
bgUrl: String,
title: String,
tip: String,
type: String,
});
const dynamicComponent = computed(() => {
switch (props.type) {
switch (type) {
case '403':
return Result403Icon;
case '404':
Expand Down
3 changes: 1 addition & 2 deletions src/components/thumbnail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps({
const { type } = defineProps({
url: String,
type: {
type: String,
Expand All @@ -13,7 +13,6 @@ const props = defineProps({
});
const className = computed(() => {
const { type } = props;
return [
'thumbnail-container',
{
Expand Down
3 changes: 1 addition & 2 deletions src/components/trend/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps({
const { type, isReverseColor } = defineProps({
type: String,
describe: [String, Number],
isReverseColor: {
Expand All @@ -33,7 +33,6 @@ const props = defineProps({
});
const containerCls = computed(() => {
const { isReverseColor, type } = props;
return [
'trend-container',
{
Expand Down
5 changes: 2 additions & 3 deletions src/layouts/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import MenuContent from './MenuContent.vue';
import Notice from './Notice.vue';
import Search from './Search.vue';
const props = defineProps({
const { theme, layout, showLogo, menu, isFixed, isCompact } = defineProps({
theme: {
type: String,
default: 'light',
Expand Down Expand Up @@ -141,7 +141,6 @@ const active = computed(() => getActive());
const layoutCls = computed(() => [`${prefix}-header-layout`]);
const menuCls = computed(() => {
const { isFixed, layout, isCompact } = props;
return [
{
[`${prefix}-header-menu`]: !isFixed,
Expand All @@ -151,7 +150,7 @@ const menuCls = computed(() => {
},
];
});
const menuTheme = computed(() => props.theme as ModeType);
const menuTheme = computed(() => theme as ModeType);
// 切换语言
const { changeLocale } = useLocale();
Expand Down
3 changes: 1 addition & 2 deletions src/layouts/components/MenuContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type { MenuRoute } from '@/types/interface';
type ListItemType = MenuRoute & { icon?: string };
const props = defineProps({
const { navData } = defineProps({
navData: {
type: Array as PropType<MenuRoute[]>,
default: () => [],
Expand All @@ -45,7 +45,6 @@ const active = computed(() => getActive());
const { locale } = useLocale();
const list = computed(() => {
const { navData } = props;
return getMenuList(navData);
});
Expand Down
5 changes: 1 addition & 4 deletions src/layouts/components/SideNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import MenuContent from './MenuContent.vue';
const MIN_POINT = 992 - 1;
const props = defineProps({
const { menu, showLogo, isFixed, layout, theme, isCompact } = defineProps({
menu: {
type: Array as PropType<MenuRoute[]>,
default: () => [],
Expand Down Expand Up @@ -97,11 +97,9 @@ const onExpanded = (value: MenuValue[]) => {
};
const sideMode = computed(() => {
const { theme } = props;
return theme === 'dark';
});
const sideNavCls = computed(() => {
const { isCompact } = props;
return [
`${prefix}-sidebar-layout`,
{
Expand All @@ -126,7 +124,6 @@ const versionCls = computed(() => {
];
});
const menuCls = computed(() => {
const { showLogo, isFixed, layout } = props;
return [
`${prefix}-side-nav`,
{
Expand Down
6 changes: 3 additions & 3 deletions src/pages/list/card/components/DialogForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const SELECT_OPTIONS = [
{ label: 'CVM', value: '3' },
];
const props = defineProps({
const { visible, data } = defineProps({
visible: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -100,14 +100,14 @@ watch(
);
watch(
() => props.visible,
() => visible,
(val) => {
formVisible.value = val;
},
);
watch(
() => props.data,
() => data,
(val) => {
formData.value = val;
},
Expand Down

0 comments on commit e06d023

Please sign in to comment.