Commit a686bb58 by liimin

fix(ui): 修复工具箱组件类型定义和样式问题

- 将 launch.json 中的 playground 配置从 standard 改为 custom
- 在 CarBrands 组件中添加 console.log 调试 windowHeight 计算
- 修复 FinishStep 组件中 uni-icons 的 size 属性语法错误
- 为 FinishStep 弹窗内容添加最小宽度限制 325px
- 重构 ToolBox 组件的数据处理逻辑,改进类型安全
- 调整 ToolBox 组件中 selectItem 函数的类型注解
- 优化 ToolBox 组件的代码结构和注释格式
1 parent 56dea666
......@@ -3,7 +3,7 @@
"configurations" : [
{
"customPlaygroundType" : "local",
"playground" : "standard",
"playground" : "custom",
"type" : "uni-app:app-android"
},
{
......
......@@ -63,8 +63,14 @@ import { resolutionState } from "@/services/adapter/index.uts";
import { computed } from "vue";
import type { AppResolutionConfig } from "@/services/adapter/types/index.uts";
// 使用 computed 响应式获取最新的分辨率配置
const windowHeight = computed(() => resolutionState.windowHeight);
const windowHeight = computed(() => {
console.log('windowHeight:', resolutionState.windowHeight)
return resolutionState.windowHeight
}
);
type UserInfo = UTSJSONObject
......
......@@ -51,7 +51,7 @@
<view class="select-content">
<text class="select-text" :class="[(formData as UTSJSONObject)[i.key] == '' ? 'select-text-placeholder' : '']">{{ (formData as UTSJSONObject)[i.key] != '' ? (formData as UTSJSONObject)[i.key] : i.placeholder }}</text>
<uni-icons class="arrow"
:size="16"
size="16"
type="down">
</uni-icons>
</view>
......@@ -546,6 +546,7 @@ defineExpose({ open, close });
.popup-content {
width: 100%;
max-width: 375px;
min-width: 325px;
background: #ffffff;
border-radius: 16px;
overflow: hidden;
......
......@@ -19,19 +19,19 @@
<template #default>
<view class="list-wrapper">
<!-- 动态数据项 -->
<view v-for="(item, index) in displayData"
<view v-for="(item, index) in displayData"
:key="index"
class="fab-item"
@click="selectItem(item)">
<view class="icon-box">
<image v-if="item.shortTitleUrl"
<image v-if="item.shortTitleUrl"
class="btn-icon"
mode="aspectFill"
:src="item.shortTitleUrl" />
<text class="item-text">{{ item.shortTitle }}</text>
</view>
</view>
<!-- 付款方式 -->
<view v-if="showPayBtn"
class="fab-item"
......@@ -41,7 +41,7 @@
<text class="item-text">付款方式</text>
</view>
</view>
<!-- 完成接待 -->
<view v-if="type !== 'preview'"
class="fab-item"
......@@ -64,6 +64,15 @@
*/
// ============================================================================
// 类型定义
// ============================================================================
type ToolItem = {
id?: number | string
shortTitle?: string
shortTitleUrl?: string
}
// ============================================================================
// Props 定义
// ============================================================================
interface Props {
......@@ -107,15 +116,6 @@ const emit = defineEmits<{
}>();
// ============================================================================
// 类型定义
// ============================================================================
type ToolItem = {
id?: number | string
shortTitle?: string
shortTitleUrl?: string
}
// ============================================================================
// 响应式状态
// ============================================================================
const show = ref<boolean>(false); // 初始收起
......@@ -128,18 +128,20 @@ const show = ref<boolean>(false); // 初始收起
*/
const displayData = computed<Array<ToolItem>>(() => {
if (props.data == null || props.data.length === 0) {
console.log('[ToolBox] data is empty');
return [] as Array<ToolItem>;
console.log('[ToolBox] data is empty.');
return [];
}
return props.data.map((element: any) => {
const el = element as UTSJSONObject;
return {
id: el.id,
shortTitleUrl: el.shortTitleUrl,
shortTitle: el.shortTitle
};
}) as Array<ToolItem>;
const result: Array<ToolItem> = [];
for (let i = 0; i < props.data.length; i++) {
const element = props.data[i] as UTSJSONObject;
result.push({
id: element.id as string | number | null,
shortTitleUrl: element.shortTitleUrl as string | null,
shortTitle: element.shortTitle as string | null
});
}
return result;
});
/**
......@@ -170,9 +172,9 @@ const handleFabClick = (): void => {
* 选择工具项
* @param item - 选中的工具项
*/
const selectItem = (item: ToolItem): void => {
const selectItem = (item: any): void => {
show.value = false; // 自动收起
emit('choose', item);
emit('choose', item as ToolItem);
};
/**
......@@ -198,7 +200,7 @@ const hide = (): void => {
// ============================================================================
// 暴露给父组件的方法
// ============================================================================
// ==========================================================================
defineExpose({
hide
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!