refactor(shadcn): 优化 Button 组件并更新相关依赖

- 更新 @types/node 版本至 24.3.0
- 更新 @vue/tsconfig 版本至 0.8.0
- 更新 eslint-plugin-oxlint 和 oxlint 版本至 1.12.0
- 优化 HCesiumManager 中的卫星实体创建逻辑
- 修复 ShadcnVue 页面中的 Button 组件用法
- 优化 Button 组件的 Props 类型定义
- 更新 buttonVariants 的导入路径
This commit is contained in:
严浩
2025-08-18 10:18:03 +08:00
parent 3b25b0dc7b
commit 46e5fd3e49
7 changed files with 123 additions and 107 deletions

View File

@@ -6,9 +6,9 @@ import type { I卫星 } from './HCesiumManager.types';
import { type OrbitCalculationResult, SatelliteCalculator } from '../calculators/SatelliteCalculator';
interface ManagedSatelliteEntities {
coverageEntity?: Cesium.Entity;
coverageEntity?: Cesium.Entity | null;
mainEntity: Cesium.Entity;
orbitEntity?: Cesium.Entity;
orbitEntity?: Cesium.Entity | null;
}
export class HCesiumSatelliteManager {
@@ -108,8 +108,8 @@ export class HCesiumSatelliteManager {
// 存储实体引用
this.currentSatelliteEntities.set(id, {
mainEntity: addedMainEntity, // 存储实际添加成功的实体
orbitEntity: addedOrbitEntity ?? undefined,
coverageEntity: addedCoverageEntity ?? undefined,
orbitEntity: addedOrbitEntity,
coverageEntity: addedCoverageEntity,
});
}
@@ -124,21 +124,10 @@ export class HCesiumSatelliteManager {
options: I卫星,
): Cesium.Entity {
// 动态轨迹路径 (Path) - 注意:这与完整轨道线 (Polyline) 不同
const path: Cesium.PathGraphics.ConstructorOptions = {
resolution: 1,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.15,
color: randomBaseColor,
}),
width: 2,
leadTime: (options.orbitDurationSeconds ?? 3600 * 2) / 2, // 默认1小时
trailTime: (options.orbitDurationSeconds ?? 3600 * 2) / 2, // 默认1小时
};
return new Cesium.Entity({
const entityOptions: Cesium.Entity.ConstructorOptions = {
id,
name,
path: options.showPath ? path : undefined, // 根据 options.showPath 控制是否显示路径
position: sampledPositionProperty, // 使用计算好的位置属性
orientation: new Cesium.VelocityOrientationProperty(sampledPositionProperty),
point: {
@@ -157,7 +146,22 @@ export class HCesiumSatelliteManager {
fillColor: Cesium.Color.WHITE,
outlineColor: Cesium.Color.BLACK,
},
});
};
if (options.showPath) {
entityOptions.path = {
resolution: 1,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.15,
color: randomBaseColor,
}),
width: 2,
leadTime: (options.orbitDurationSeconds ?? 3600 * 2) / 2, // 默认1小时
trailTime: (options.orbitDurationSeconds ?? 3600 * 2) / 2, // 默认1小时
};
}
return new Cesium.Entity(entityOptions);
}
/**

View File

@@ -8,7 +8,7 @@ const onClick = () => {
<template>
<div>
<ShadcnButton :onClick>ShadcnButton</ShadcnButton>
<ShadcnButton as="button" :onClick>ShadcnButton</ShadcnButton>
</div>
</template>

View File

@@ -1,24 +1,26 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import type { PrimitiveProps } from "reka-ui"
import type { HTMLAttributes } from "vue"
import type { ButtonVariants } from "."
import { Primitive } from "reka-ui"
import { cn } from '@/shadcn/lib/utils'
import { Primitive, type PrimitiveProps } from 'reka-ui'
import { type ButtonVariants, buttonVariants } from '.'
import { buttonVariants } from "."
interface Props extends PrimitiveProps {
variant?: ButtonVariants['variant']
size?: ButtonVariants['size']
class?: HTMLAttributes['class']
variant?: ButtonVariants["variant"]
size?: ButtonVariants["size"]
class?: HTMLAttributes["class"]
}
const props = withDefaults(defineProps<Props>(), {
as: 'button',
as: "button",
})
</script>
<template>
<Primitive
:as="as"
:as-child="asChild"
:as="props.as"
:as-child="props.asChild"
:class="cn(buttonVariants({ variant, size }), props.class)"
>
<slot />

View File

@@ -1,33 +1,34 @@
import { cva, type VariantProps } from 'class-variance-authority'
import type { VariantProps } from "class-variance-authority"
import { cva } from "class-variance-authority"
export { default as Button } from './Button.vue'
export { default as Button } from "./Button.vue"
export const buttonVariants = cva(
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive:
'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline:
'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
secondary:
'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: 'h-9 px-4 py-2',
xs: 'h-7 rounded px-2',
sm: 'h-8 rounded-md px-3 text-xs',
lg: 'h-10 rounded-md px-8',
icon: 'h-9 w-9',
default: "h-9 px-4 py-2",
xs: "h-7 rounded px-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: 'default',
size: 'default',
variant: "default",
size: "default",
},
},
)

View File

@@ -4,8 +4,8 @@ import { cn } from '@/shadcn/lib/utils'
import { useVModel } from '@vueuse/core'
const props = defineProps<{
defaultValue?: string | number
modelValue?: string | number
defaultValue: string | number | undefined
modelValue: string | number | undefined
class?: HTMLAttributes['class']
}>()