Commit 24077592 by liimin

feat(组件): 重构工具箱布局并使用un-fab组件

- 将自定义浮动按钮替换为uni-app官方un-fab组件,提升交互一致性
- 重构快捷操作和功能工具的网格布局,使用flex-wrap实现响应式排列
- 移除动态行计算逻辑,简化数据结构处理
- 优化触控反馈样式,调整图标和文字尺寸
- 添加横竖屏不同布局支持(竖屏4列,横屏3列)
1 parent f58b630c
......@@ -16,17 +16,17 @@
<text class="panel-close-text">×</text>
</view>
</view>
<view class="panel-body"
<scroll-view class="panel-body"
:style="scrollContainerStyle"
scroll-y="true"
@touchstart.stop
@touchmove.stop
@touchend.stop>
<view class="section-title">快捷操作</view>
<view class="fixed-group">
<view class="action-row">
<view class="action-col" v-for="(action, idx) in fixedActionSlots" :key="'fixed-' + idx">
<view v-if="action != null"
class="fab-item fixed-item"
<view class="action-grid">
<view class="action-item" v-for="(action, idx) in fixedActionSlots" :key="'fixed-' + idx">
<view class="fab-item fixed-item"
:class="{ 'fab-item-active': activeItemId == 'fixed-' + idx }"
@touchstart="handleActionTouchStart('fixed-' + idx)"
@touchend="handleActionTouchEnd"
......@@ -46,12 +46,11 @@
</view>
<view class="section-title" style="margin-top: 10px;">功能工具</view>
<view class="dynamic-group">
<view class="action-row" v-for="(row, rowIndex) in dynamicRows" :key="'row-' + rowIndex">
<view class="action-col" v-for="(action, idx) in row" :key="'dynamic-' + rowIndex + '-' + idx">
<view v-if="action != null"
class="fab-item dynamic-item"
:class="{ 'fab-item-active': activeItemId == 'dynamic-' + rowIndex + '-' + idx }"
@touchstart="handleActionTouchStart('dynamic-' + rowIndex + '-' + idx)"
<view class="action-grid">
<view class="action-item" v-for="(action, idx) in dynamicActions" :key="'dynamic-' + idx">
<view class="fab-item dynamic-item"
:class="{ 'fab-item-active': activeItemId == 'dynamic-' + idx }"
@touchstart="handleActionTouchStart('dynamic-' + idx)"
@touchend="handleActionTouchEnd"
@touchcancel="handleActionTouchEnd"
@click="onActionClick(action as ToolAction)">
......@@ -68,11 +67,11 @@
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
<view class="trigger-holder"
<!-- <view class="trigger-holder"
:style="triggerPositionStyle">
<view class="custom-trigger"
:class="{ 'custom-trigger-active': triggerDragging }"
......@@ -83,7 +82,23 @@
<un-icon name="folder" :size="24" color="#e2e8f0"></un-icon>
<text class="trigger-text">{{ triggerText }}</text>
</view>
</view>
</view> -->
<un-fab v-model:active="show"
:expandable="false"
inactive-icon="folder"
:offset-right="20"
:offset-top="120"
position="top-center"
:size="56"
type="primary"
@click="handleFabClick">
<template #trigger>
<view class="custom-trigger">
<un-icon name="folder" size="24" color="#fff"></un-icon>
<text class="trigger-text">文件夹</text>
</view>
</template>
</un-fab>
</view>
</template>
......@@ -267,7 +282,7 @@ const dynamicActions = computed<Array<ToolAction>>(() => {
return allActions.value;
});
const fixedActionSlots = computed<Array<ToolAction | null>>(() => {
const fixedActionSlots = computed<Array<ToolAction>>(() => {
const left = props.showPayBtn
? {
key: "fixed-pay",
......@@ -288,17 +303,15 @@ const fixedActionSlots = computed<Array<ToolAction | null>>(() => {
iconClass: "icon-tool-finish"
} as ToolAction
: null;
return [left, right];
});
const dynamicRows = computed<Array<Array<ToolAction | null>>>(() => {
const rows: Array<Array<ToolAction | null>> = [];
for (let i = 0; i < dynamicActions.value.length; i += 2) {
const left = dynamicActions.value[i];
const right = (i + 1) < dynamicActions.value.length ? dynamicActions.value[i + 1] : null;
rows.push([left, right]);
const slots: Array<ToolAction> = [];
if (left != null) {
slots.push(left);
}
return rows;
if (right != null) {
slots.push(right);
}
return slots;
});
const viewportBasedMaxHeight = computed<number>(() => {
......@@ -574,10 +587,10 @@ defineExpose({
}
.custom-trigger {
width: 48px;
width: 56px;
height: 56px;
background: linear-gradient(145deg, rgba(38, 45, 59, 0.95), rgba(52, 62, 82, 0.9));
border-radius: 16px 0 0 16px;
border-radius: 50%;//16px 0 0 16px;
display: flex;
align-items: center;
justify-content: center;
......@@ -700,18 +713,26 @@ defineExpose({
width: 100%;
}
.action-row {
.action-grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
justify-content: space-between;
margin-bottom: 8px;
margin-top: 8px;
}
.action-col {
.action-item {
display: flex;
flex-direction: column;
width: 48%; /* 给中间留出大约 4% 的间距 */
margin-bottom: 12px;
}
.tool-panel-portrait .action-item {
width: 25%; /* 竖屏 4个一行 */
}
.tool-panel-landscape .action-item {
width: 33.33%; /* 横屏侧边栏 3个一行 */
}
.fab-item {
......@@ -721,26 +742,21 @@ defineExpose({
align-items: center;
justify-content: center;
cursor: pointer;
transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
transition: transform 0.2s ease, opacity 0.2s ease;
width: 100%;
border-radius: 12px;
padding: 10px 6px;
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.04);
}
.fab-item-active {
transform: scale(0.96);
background: rgba(255, 255, 255, 0.08);
border-color: rgba(255, 255, 255, 0.15);
transform: scale(0.92);
opacity: 0.8;
}
.icon-box {
position: relative;
width: 42px;
height: 42px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
width: 38px;
height: 38px;
border-radius: 12px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
background: linear-gradient(180deg, rgba(240, 244, 255, 0.96), rgba(220, 230, 248, 0.92));
display: flex;
align-items: center;
......@@ -769,11 +785,11 @@ defineExpose({
.item-text {
margin-left: 0;
margin-top: 8px;
font-size: 11px;
margin-top: 6px;
font-size: 10px;
color: rgba(255, 255, 255, 0.85);
font-weight: 500;
line-height: 14px;
line-height: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!