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 @@ ...@@ -3,7 +3,7 @@
"configurations" : [ "configurations" : [
{ {
"customPlaygroundType" : "local", "customPlaygroundType" : "local",
"playground" : "standard", "playground" : "custom",
"type" : "uni-app:app-android" "type" : "uni-app:app-android"
}, },
{ {
......
...@@ -63,8 +63,14 @@ import { resolutionState } from "@/services/adapter/index.uts"; ...@@ -63,8 +63,14 @@ import { resolutionState } from "@/services/adapter/index.uts";
import { computed } from "vue"; import { computed } from "vue";
import type { AppResolutionConfig } from "@/services/adapter/types/index.uts"; import type { AppResolutionConfig } from "@/services/adapter/types/index.uts";
// 使用 computed 响应式获取最新的分辨率配置 // 使用 computed 响应式获取最新的分辨率配置
const windowHeight = computed(() => resolutionState.windowHeight); const windowHeight = computed(() => {
console.log('windowHeight:', resolutionState.windowHeight)
return resolutionState.windowHeight
}
);
type UserInfo = UTSJSONObject type UserInfo = UTSJSONObject
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<view class="select-content"> <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> <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" <uni-icons class="arrow"
:size="16" size="16"
type="down"> type="down">
</uni-icons> </uni-icons>
</view> </view>
...@@ -546,6 +546,7 @@ defineExpose({ open, close }); ...@@ -546,6 +546,7 @@ defineExpose({ open, close });
.popup-content { .popup-content {
width: 100%; width: 100%;
max-width: 375px; max-width: 375px;
min-width: 325px;
background: #ffffff; background: #ffffff;
border-radius: 16px; border-radius: 16px;
overflow: hidden; overflow: hidden;
......
...@@ -64,6 +64,15 @@ ...@@ -64,6 +64,15 @@
*/ */
// ============================================================================ // ============================================================================
// 类型定义
// ============================================================================
type ToolItem = {
id?: number | string
shortTitle?: string
shortTitleUrl?: string
}
// ============================================================================
// Props 定义 // Props 定义
// ============================================================================ // ============================================================================
interface Props { interface Props {
...@@ -107,15 +116,6 @@ const emit = defineEmits<{ ...@@ -107,15 +116,6 @@ const emit = defineEmits<{
}>(); }>();
// ============================================================================ // ============================================================================
// 类型定义
// ============================================================================
type ToolItem = {
id?: number | string
shortTitle?: string
shortTitleUrl?: string
}
// ============================================================================
// 响应式状态 // 响应式状态
// ============================================================================ // ============================================================================
const show = ref<boolean>(false); // 初始收起 const show = ref<boolean>(false); // 初始收起
...@@ -128,18 +128,20 @@ const show = ref<boolean>(false); // 初始收起 ...@@ -128,18 +128,20 @@ const show = ref<boolean>(false); // 初始收起
*/ */
const displayData = computed<Array<ToolItem>>(() => { const displayData = computed<Array<ToolItem>>(() => {
if (props.data == null || props.data.length === 0) { if (props.data == null || props.data.length === 0) {
console.log('[ToolBox] data is empty'); console.log('[ToolBox] data is empty.');
return [] as Array<ToolItem>; return [];
} }
return props.data.map((element: any) => { const result: Array<ToolItem> = [];
const el = element as UTSJSONObject; for (let i = 0; i < props.data.length; i++) {
return { const element = props.data[i] as UTSJSONObject;
id: el.id, result.push({
shortTitleUrl: el.shortTitleUrl, id: element.id as string | number | null,
shortTitle: el.shortTitle shortTitleUrl: element.shortTitleUrl as string | null,
}; shortTitle: element.shortTitle as string | null
}) as Array<ToolItem>; });
}
return result;
}); });
/** /**
...@@ -170,9 +172,9 @@ const handleFabClick = (): void => { ...@@ -170,9 +172,9 @@ const handleFabClick = (): void => {
* 选择工具项 * 选择工具项
* @param item - 选中的工具项 * @param item - 选中的工具项
*/ */
const selectItem = (item: ToolItem): void => { const selectItem = (item: any): void => {
show.value = false; // 自动收起 show.value = false; // 自动收起
emit('choose', item); emit('choose', item as ToolItem);
}; };
/** /**
...@@ -198,7 +200,7 @@ const hide = (): void => { ...@@ -198,7 +200,7 @@ const hide = (): void => {
// ============================================================================ // ============================================================================
// 暴露给父组件的方法 // 暴露给父组件的方法
// ============================================================================ // ==========================================================================
defineExpose({ defineExpose({
hide hide
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!