Commit 24077592 by liimin

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

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