refactor: adjust all sample pages and use page components (#4118)
This commit is contained in:
@@ -5,7 +5,6 @@ import type {
|
||||
AvatarRootProps,
|
||||
} from 'radix-vue';
|
||||
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import {
|
||||
@@ -16,9 +15,9 @@ import {
|
||||
|
||||
interface Props extends AvatarRootProps, AvatarFallbackProps, AvatarImageProps {
|
||||
alt?: string;
|
||||
class?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
dot?: boolean;
|
||||
dotClass?: HTMLAttributes['class'];
|
||||
dotClass?: any;
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { LoaderCircle } from '@vben-core/icons';
|
||||
@@ -12,7 +11,7 @@ import { cn } from '@vben-core/shared';
|
||||
import { Primitive, type PrimitiveProps } from 'radix-vue';
|
||||
|
||||
interface Props extends PrimitiveProps {
|
||||
class?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
disabled?: boolean;
|
||||
loading?: boolean;
|
||||
size?: ButtonVariants['size'];
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { ButtonVariants } from '@vben-core/shadcn-ui/components/ui/button';
|
||||
|
||||
import { computed, type HTMLAttributes, useSlots } from 'vue';
|
||||
import { computed, useSlots } from 'vue';
|
||||
|
||||
import { VbenTooltip } from '@vben-core/shadcn-ui/components/tooltip';
|
||||
import { cn } from '@vben-core/shared';
|
||||
@@ -11,7 +11,7 @@ import { type PrimitiveProps } from 'radix-vue';
|
||||
import VbenButton from './button.vue';
|
||||
|
||||
interface Props extends PrimitiveProps {
|
||||
class?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
disabled?: boolean;
|
||||
onClick?: () => void;
|
||||
tooltip?: string;
|
||||
|
@@ -7,7 +7,6 @@ import type {
|
||||
|
||||
import type { IContextMenuItem } from './interface';
|
||||
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import {
|
||||
@@ -23,11 +22,11 @@ import { useForwardPropsEmits } from 'radix-vue';
|
||||
|
||||
const props = defineProps<
|
||||
{
|
||||
class?: HTMLAttributes['class'];
|
||||
contentClass?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
contentClass?: any;
|
||||
contentProps?: ContextMenuContentProps;
|
||||
handlerData?: Record<string, any>;
|
||||
itemClass?: HTMLAttributes['class'];
|
||||
itemClass?: any;
|
||||
menus: (data: any) => IContextMenuItem[];
|
||||
} & ContextMenuRootProps
|
||||
>();
|
||||
|
@@ -5,7 +5,6 @@ import type {
|
||||
HoverCardRootProps,
|
||||
} from 'radix-vue';
|
||||
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import {
|
||||
@@ -16,13 +15,13 @@ import {
|
||||
|
||||
import { useForwardPropsEmits } from 'radix-vue';
|
||||
|
||||
const props = defineProps<
|
||||
{
|
||||
class?: HTMLAttributes['class'];
|
||||
contentClass?: HTMLAttributes['class'];
|
||||
contentProps?: HoverCardContentProps;
|
||||
} & HoverCardRootProps
|
||||
>();
|
||||
interface Props extends HoverCardRootProps {
|
||||
class?: any;
|
||||
contentClass?: any;
|
||||
contentProps?: HoverCardContentProps;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const emits = defineEmits<HoverCardRootEmits>();
|
||||
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
|
||||
interface InputProps {
|
||||
class?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
/**
|
||||
* 错误提示信息
|
||||
*/
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
|
||||
import { cn } from '@vben-core/shared';
|
||||
|
||||
import { Primitive, type PrimitiveProps } from 'radix-vue';
|
||||
|
||||
interface Props extends PrimitiveProps {
|
||||
class?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
href: string;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,3 @@
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
|
||||
interface PinInputProps {
|
||||
/**
|
||||
* 发送验证码按钮loading
|
||||
@@ -9,7 +7,7 @@ interface PinInputProps {
|
||||
* 发送验证码按钮文本
|
||||
*/
|
||||
btnText?: string;
|
||||
class?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
/**
|
||||
* 验证码长度
|
||||
*/
|
||||
|
@@ -5,7 +5,6 @@ import type {
|
||||
PopoverRootProps,
|
||||
} from 'radix-vue';
|
||||
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import {
|
||||
@@ -16,16 +15,13 @@ import {
|
||||
|
||||
import { useForwardPropsEmits } from 'radix-vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<
|
||||
{
|
||||
class?: HTMLAttributes['class'];
|
||||
contentClass?: HTMLAttributes['class'];
|
||||
contentProps?: PopoverContentProps;
|
||||
} & PopoverRootProps
|
||||
>(),
|
||||
{},
|
||||
);
|
||||
interface Props extends PopoverRootProps {
|
||||
class?: any;
|
||||
contentClass?: any;
|
||||
contentProps?: PopoverContentProps;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {});
|
||||
|
||||
const emits = defineEmits<PopoverRootEmits>();
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import {
|
||||
@@ -9,9 +8,9 @@ import {
|
||||
import { cn } from '@vben-core/shared';
|
||||
|
||||
interface Props {
|
||||
class?: HTMLAttributes['class'];
|
||||
class?: any;
|
||||
horizontal?: boolean;
|
||||
scrollBarClass?: HTMLAttributes['class'];
|
||||
scrollBarClass?: any;
|
||||
shadow?: boolean;
|
||||
shadowBorder?: boolean;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, type HTMLAttributes } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { cn } from '@vben-core/shared';
|
||||
|
||||
@@ -9,9 +9,7 @@ import {
|
||||
useForwardProps,
|
||||
} from 'radix-vue';
|
||||
|
||||
const props = defineProps<
|
||||
{ class?: HTMLAttributes['class'] } & TabsIndicatorProps
|
||||
>();
|
||||
const props = defineProps<{ class?: any } & TabsIndicatorProps>();
|
||||
|
||||
const delegatedProps = computed(() => {
|
||||
const { class: _, ...delegated } = props;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { TooltipContentProps } from 'radix-vue';
|
||||
|
||||
import type { HTMLAttributes } from 'vue';
|
||||
import type { StyleValue } from 'vue';
|
||||
|
||||
import {
|
||||
Tooltip,
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
} from '@vben-core/shadcn-ui/components/ui/tooltip';
|
||||
|
||||
interface Props {
|
||||
contentClass?: HTMLAttributes['class'];
|
||||
contentStyle?: HTMLAttributes['style'];
|
||||
contentClass?: any;
|
||||
contentStyle?: StyleValue;
|
||||
delayDuration?: number;
|
||||
side: TooltipContentProps['side'];
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
## Effects 目录
|
||||
|
||||
`effects` 目录专门用于存放与副作用相关的代码和逻辑。如果你的包具有以下特点,建议将其放置在 `effects` 目录下:
|
||||
`effects` 目录专门用于存放与轻微耦合相关的代码和逻辑。如果你的包具有以下特点,建议将其放置在 `effects` 目录下:
|
||||
|
||||
- **状态管理**:使用状态管理框架 `pinia`,并包含处理副作用(如异步操作、API 调用)的部分。
|
||||
- **用户偏好设置**:使用 `@vben-core/preferences` 处理用户偏好设置,涉及本地存储或浏览器缓存逻辑(如使用 `localStorage`)。
|
||||
|
@@ -23,7 +23,7 @@ interface Props {
|
||||
* 提示框位置
|
||||
* @default 'top'
|
||||
*/
|
||||
placement: 'bottom' | 'left' | 'right' | 'top';
|
||||
placement?: 'bottom' | 'left' | 'right' | 'top';
|
||||
/**
|
||||
* 是否启用文本提示框
|
||||
* @default true
|
||||
@@ -49,7 +49,7 @@ interface Props {
|
||||
* 提示框内容区域样式
|
||||
* @default { textAlign: 'justify' }
|
||||
*/
|
||||
tooltipOverlayStyle?: CSSProperties; // 提示框内容区域样式
|
||||
tooltipOverlayStyle?: CSSProperties;
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
expand: false,
|
||||
@@ -99,6 +99,14 @@ function onExpand() {
|
||||
|
||||
emit('expandChange', !isExpanded);
|
||||
}
|
||||
|
||||
function handleExpand() {
|
||||
if (props.expand) {
|
||||
onExpand();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VbenTooltip
|
||||
@@ -110,7 +118,6 @@ function onExpand() {
|
||||
backgroundColor: tooltipBackgroundColor,
|
||||
}"
|
||||
:disabled="!showTooltip"
|
||||
:overlay-style="tooltipOverlayStyle"
|
||||
:side="placement"
|
||||
>
|
||||
<slot name="tooltip">
|
||||
@@ -127,7 +134,7 @@ function onExpand() {
|
||||
}"
|
||||
:style="`-webkit-line-clamp: ${line}; max-width: ${textMaxWidth};`"
|
||||
class="cursor-text overflow-hidden"
|
||||
@click="expand ? onExpand() : () => false"
|
||||
@click="handleExpand"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<slot></slot>
|
2
packages/effects/common-ui/src/components/index.ts
Normal file
2
packages/effects/common-ui/src/components/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './ellipsis-text';
|
||||
export * from './page';
|
@@ -10,11 +10,9 @@ const props = defineProps<PageHeaderProps>();
|
||||
|
||||
<template>
|
||||
<div class="bg-card px-6 py-4">
|
||||
<div class="flex justify-between text-lg font-bold">
|
||||
<div class="mb-2 flex justify-between text-xl font-bold leading-10">
|
||||
{{ props.title }}
|
||||
</div>
|
||||
<div class="pt-3">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
@@ -1,11 +1,11 @@
|
||||
interface PageHeaderProps {
|
||||
title?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface Props extends PageHeaderProps {
|
||||
headerSticky?: boolean;
|
||||
contentClass?: string;
|
||||
showFooter?: boolean;
|
||||
showHeader?: boolean;
|
||||
}
|
||||
|
||||
export type { PageHeaderProps, Props };
|
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { Props } from './page.ts';
|
||||
import type { Props } from './page';
|
||||
|
||||
import PageFooter from './page-footer.vue';
|
||||
import PageHeader from './page-header.vue';
|
||||
@@ -9,20 +9,24 @@ defineOptions({
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
description: '',
|
||||
showFooter: false,
|
||||
showHeader: true,
|
||||
title: '',
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative h-full">
|
||||
<PageHeader v-if="props.showHeader" :title="props.title">
|
||||
<PageHeader
|
||||
v-if="description || $slots.description || title"
|
||||
:title="props.title"
|
||||
>
|
||||
<template #default>
|
||||
<slot name="header"></slot>
|
||||
<template v-if="description">{{ description }}</template>
|
||||
<slot v-else name="description"></slot>
|
||||
</template>
|
||||
</PageHeader>
|
||||
<div class="m-4 overflow-hidden">
|
||||
<div :class="contentClass" class="m-4">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<PageFooter v-if="props.showFooter">
|
@@ -1,7 +1,3 @@
|
||||
export * from './about';
|
||||
export * from './authentication';
|
||||
export * from './dashboard';
|
||||
export * from './ellipsis-text';
|
||||
export * from './fallback';
|
||||
export * from './page';
|
||||
export * from './components';
|
||||
export * from './ui';
|
||||
export { useToast } from '@vben-core/shadcn-ui';
|
||||
|
@@ -10,6 +10,8 @@ import {
|
||||
} from '@vben/constants';
|
||||
import { VbenLink, VbenRenderContent } from '@vben-core/shadcn-ui';
|
||||
|
||||
import { Page } from '../../components';
|
||||
|
||||
interface Props extends AboutProps {}
|
||||
|
||||
defineOptions({
|
||||
@@ -119,18 +121,18 @@ const devDependenciesItems = Object.keys(devDependencies).map((key) => ({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="m-5">
|
||||
<Page :title="title">
|
||||
<template #description>
|
||||
<p class="text-foreground mt-3 text-sm leading-6">
|
||||
<VbenLink :href="VBEN_GITHUB_URL">
|
||||
{{ name }}
|
||||
</VbenLink>
|
||||
{{ description }}
|
||||
</p>
|
||||
</template>
|
||||
<div class="card-box p-5">
|
||||
<div>
|
||||
<h3 class="text-foreground text-2xl font-semibold leading-7">
|
||||
{{ title }}
|
||||
</h3>
|
||||
<p class="text-foreground mt-3 text-sm leading-6">
|
||||
<VbenLink :href="VBEN_GITHUB_URL">
|
||||
{{ name }}
|
||||
</VbenLink>
|
||||
{{ description }}
|
||||
</p>
|
||||
<h5 class="text-foreground text-lg">基本信息</h5>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<dl class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
|
||||
@@ -186,5 +188,5 @@ const devDependenciesItems = Object.keys(devDependencies).map((key) => ({
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
4
packages/effects/common-ui/src/ui/index.ts
Normal file
4
packages/effects/common-ui/src/ui/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './about';
|
||||
export * from './authentication';
|
||||
export * from './dashboard';
|
||||
export * from './fallback';
|
Reference in New Issue
Block a user