mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): 添加exportDefaults替换defineProps
This commit is contained in:
@ -41,21 +41,25 @@ function generateBreadcrumb() {
|
||||
|
||||
/** 递归匹配路由获取面包屑数据 */
|
||||
function recursionBreadcrumb(routeMatched: RouteLocationMatched[]) {
|
||||
return routeMatched.map(item => {
|
||||
const routeName = item.name as RoutePathKey;
|
||||
const breadcrumItem: Breadcrumb = {
|
||||
key: routeName,
|
||||
label: (item.meta?.title as string) || '',
|
||||
disabled: item.path === EnumRoutePath.root,
|
||||
routeName,
|
||||
hasChildren: false
|
||||
};
|
||||
if (item.children && item.children.length) {
|
||||
breadcrumItem.hasChildren = true;
|
||||
breadcrumItem.children = recursionBreadcrumb(item.children as RouteLocationMatched[]);
|
||||
const list: Breadcrumb[] = [];
|
||||
routeMatched.forEach(item => {
|
||||
if (!item.meta?.isNotMenu) {
|
||||
const routeName = item.name as RoutePathKey;
|
||||
const breadcrumItem: Breadcrumb = {
|
||||
key: routeName,
|
||||
label: (item.meta?.title as string) || '',
|
||||
disabled: item.path === EnumRoutePath.root,
|
||||
routeName,
|
||||
hasChildren: false
|
||||
};
|
||||
if (item.children && item.children.length) {
|
||||
breadcrumItem.hasChildren = true;
|
||||
breadcrumItem.children = recursionBreadcrumb(item.children as RouteLocationMatched[]);
|
||||
}
|
||||
list.push(breadcrumItem);
|
||||
}
|
||||
return breadcrumItem;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
function dropdownSelect(optionKey: string) {
|
||||
|
@ -43,11 +43,13 @@ import {
|
||||
import { GlobalLogo } from '../common';
|
||||
import HeaderMenu from './components/HeaderMenu.vue';
|
||||
|
||||
defineProps({
|
||||
zIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
interface Props {
|
||||
/** 层级z-index */
|
||||
zIndex?: number;
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
zIndex: 0
|
||||
});
|
||||
|
||||
const theme = useThemeStore();
|
||||
|
@ -38,11 +38,13 @@ import { menus } from '@/router';
|
||||
import { GlobalMenuOption } from '@/interface';
|
||||
import { GlobalLogo } from '../../../common';
|
||||
|
||||
defineProps({
|
||||
zIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
interface Props {
|
||||
/** 层级z-index */
|
||||
zIndex?: number;
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
zIndex: 0
|
||||
});
|
||||
|
||||
const theme = useThemeStore();
|
||||
|
@ -17,30 +17,24 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import type { PropType, VNodeChild } from 'vue';
|
||||
import type { VNodeChild } from 'vue';
|
||||
import { useBoolean } from '@/hooks';
|
||||
|
||||
const props = defineProps({
|
||||
routeName: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
icon: {
|
||||
type: Function as PropType<() => VNodeChild>,
|
||||
required: true
|
||||
},
|
||||
activeRouteName: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
isMini: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
interface Props {
|
||||
/** 路由名称 */
|
||||
routeName: string;
|
||||
/** 路由名称文本 */
|
||||
label: string;
|
||||
/** 路由图标 */
|
||||
icon: VNodeChild;
|
||||
/** 当前激活状态的理由名称 */
|
||||
activeRouteName: string;
|
||||
/** mini尺寸的路由 */
|
||||
isMini?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
isMini: false
|
||||
});
|
||||
|
||||
const { bool: isHover, setTrue, setFalse } = useBoolean();
|
||||
|
@ -15,7 +15,7 @@
|
||||
:style="{ width: showDrawer ? theme.menuStyle.width + 'px' : '0px' }"
|
||||
>
|
||||
<header class="header-height flex-y-center justify-between">
|
||||
<h2 class="pl-8px text-16px g_text-primary font-bold">{{ title }}</h2>
|
||||
<h2 class="g_text-primary pl-8px text-16px font-bold">{{ title }}</h2>
|
||||
<div class="px-8px text-16px text-gray-600 cursor-pointer" @click="toggleFixedMixMenu">
|
||||
<icon-mdi:pin-off v-if="app.menu.fixedMix" />
|
||||
<icon-mdi:pin v-else />
|
||||
@ -39,15 +39,15 @@ import { useAppTitle } from '@/hooks';
|
||||
import { menus } from '@/router';
|
||||
import type { GlobalMenuOption } from '@/interface';
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
activeRouteName: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
interface Props {
|
||||
/** 菜单抽屉可见性 */
|
||||
visible?: boolean;
|
||||
/** 激活状态的路由名称 */
|
||||
activeRouteName: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
visible: false
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
|
@ -10,11 +10,13 @@ import { computed } from 'vue';
|
||||
import { useThemeStore } from '@/store';
|
||||
import { DefaultSider, VerticalMixSider } from './components';
|
||||
|
||||
const props = defineProps({
|
||||
zIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
interface Props {
|
||||
/** 层级z-index */
|
||||
zIndex?: number;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
zIndex: 0
|
||||
});
|
||||
|
||||
const theme = useThemeStore();
|
||||
|
@ -21,35 +21,33 @@ import { ROUTE_HOME } from '@/router';
|
||||
import { useReloadInject } from '@/context';
|
||||
import { dynamicIconRender } from '@/utils';
|
||||
|
||||
interface Props {
|
||||
/** 右键菜单可见性 */
|
||||
visible?: boolean;
|
||||
/** 当前是否是路由首页 */
|
||||
isRouteHome?: boolean;
|
||||
/** 当前路由路径 */
|
||||
currentPath?: string;
|
||||
/** 鼠标x坐标 */
|
||||
x: number;
|
||||
/** 鼠标y坐标 */
|
||||
y: number;
|
||||
}
|
||||
|
||||
type DropdownKey = 'reload-current' | 'close-current' | 'close-other' | 'close-all';
|
||||
type Option = DropdownOption & {
|
||||
key: DropdownKey;
|
||||
};
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isRouteHome: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
currentPath: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
x: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
y: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
visible: false,
|
||||
isRouteHome: false,
|
||||
currentPath: ''
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:visible']);
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const app = useAppStore();
|
||||
const { removeMultiTab, clearMultiTab } = useAppStore();
|
||||
|
@ -24,11 +24,13 @@ import { useThemeStore, useAppStore } from '@/store';
|
||||
import { BetterScroll } from '@/components';
|
||||
import { MultiTab, ReloadButton } from './components';
|
||||
|
||||
defineProps({
|
||||
zIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
interface Props {
|
||||
/** 层级z-index */
|
||||
zIndex?: number;
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
zIndex: 0
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
|
@ -17,25 +17,24 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import type { PropType } from 'vue';
|
||||
import { NTooltip } from 'naive-ui';
|
||||
import type { FollowerPlacement } from 'vueuc';
|
||||
import { EnumNavMode } from '@/enum';
|
||||
import type { NavMode } from '@/interface';
|
||||
|
||||
const props = defineProps({
|
||||
mode: {
|
||||
type: String as PropType<NavMode>,
|
||||
default: 'vertical'
|
||||
},
|
||||
checked: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
primaryColor: {
|
||||
type: String,
|
||||
default: '#409EFF'
|
||||
}
|
||||
interface Props {
|
||||
/** 导航模式 */
|
||||
mode?: NavMode;
|
||||
/** 选中状态 */
|
||||
checked?: boolean;
|
||||
/** 主题颜色 */
|
||||
primaryColor?: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
mode: 'vertical',
|
||||
checked: false,
|
||||
primaryColor: '#409EFF'
|
||||
});
|
||||
|
||||
const config = new Map<NavMode, { placement: FollowerPlacement; menuClass: string; mainClass: string }>([
|
||||
|
@ -11,15 +11,13 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
color: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
checked: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
interface Props {
|
||||
color: string;
|
||||
checked?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
checked: false
|
||||
});
|
||||
|
||||
const whiteColors = ['#ffffff', '#fff', 'rgb(255,255,255)'];
|
||||
|
@ -6,11 +6,11 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
defineProps({
|
||||
label: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
});
|
||||
interface Props {
|
||||
/** 文本 */
|
||||
label: string;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
</script>
|
||||
<style scoped></style>
|
||||
|
Reference in New Issue
Block a user