From bde1d36005f195b39717b2a88fd603a4e1f5c045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=98=E9=A3=8E?= Date: Tue, 16 Dec 2025 16:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84GroupContextMenu=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=9A=E8=B0=83=E6=95=B4=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=9A=84=E6=A0=B7=E5=BC=8F=E5=B9=B6=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=E7=BB=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E7=A6=81=E7=94=A8=E9=BB=98=E8=AE=A4=E7=BB=84=E6=88=96?= =?UTF-8?q?=E6=9C=AA=E5=88=86=E7=BB=84=E7=BB=84=E7=9A=84=E7=BC=96=E8=BE=91?= =?UTF-8?q?/=E5=88=A0=E9=99=A4=E6=93=8D=E4=BD=9C=E3=80=82=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=81=94=E7=B3=BB=E4=BA=BA=E7=BB=84=E7=9A=84=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BB=A5=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=BB=84=E5=92=8C=E6=9C=AA=E5=88=86=E7=BB=84?= =?UTF-8?q?=E7=BB=84=E7=9A=84=E4=BC=98=E5=85=88=E7=BA=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GroupContextMenu/index.module.scss | 7 +++--- .../src/components/GroupContextMenu/index.tsx | 13 ++++++++-- .../src/store/module/weChat/contacts.new.ts | 25 ++++++++++++++++--- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Touchkebao/src/components/GroupContextMenu/index.module.scss b/Touchkebao/src/components/GroupContextMenu/index.module.scss index 82be8b1d..f9f194bf 100644 --- a/Touchkebao/src/components/GroupContextMenu/index.module.scss +++ b/Touchkebao/src/components/GroupContextMenu/index.module.scss @@ -9,10 +9,9 @@ } .contextMenu { - min-width: 180px; - padding: 4px 0; + min-width: 120px; + padding: 2px 0; background: #ffffff; border-radius: 6px; - box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25); - border: 1px solid rgba(148, 163, 184, 0.5); + border: 1px solid rgba(148, 163, 184, 0.4); } diff --git a/Touchkebao/src/components/GroupContextMenu/index.tsx b/Touchkebao/src/components/GroupContextMenu/index.tsx index 81b0e3ba..0136d866 100644 --- a/Touchkebao/src/components/GroupContextMenu/index.tsx +++ b/Touchkebao/src/components/GroupContextMenu/index.tsx @@ -49,6 +49,12 @@ export const GroupContextMenu: React.FC = ({ onEditClick, onDeleteClick, }) => { + // 默认群分组 / 未分组:id 为 0,且 groupType 为 1 或 2 + const isDefaultOrUngrouped = + !!group && + group.id === 0 && + (group.groupType === 1 || group.groupType === 2); + // 处理新增分组 const handleAdd = () => { onClose(); @@ -57,14 +63,14 @@ export const GroupContextMenu: React.FC = ({ // 处理编辑分组 const handleEdit = () => { - if (!group) return; + if (!group || isDefaultOrUngrouped) return; onClose(); onEditClick?.(group); }; // 处理删除分组 const handleDelete = () => { - if (!group) return; + if (!group || isDefaultOrUngrouped) return; onClose(); onDeleteClick?.(group); }; @@ -84,6 +90,7 @@ export const GroupContextMenu: React.FC = ({ label: "编辑分组", icon: , onClick: handleEdit, + disabled: isDefaultOrUngrouped, }, { key: "delete", @@ -91,6 +98,7 @@ export const GroupContextMenu: React.FC = ({ icon: , danger: true, onClick: handleDelete, + disabled: isDefaultOrUngrouped, }, ] : []), @@ -112,6 +120,7 @@ export const GroupContextMenu: React.FC = ({ left: x, top: y, zIndex: 1000, + boxShadow: "0 12px 32px rgba(15, 23, 42, 0.32)", }} items={menuItems} onClick={onClose} diff --git a/Touchkebao/src/store/module/weChat/contacts.new.ts b/Touchkebao/src/store/module/weChat/contacts.new.ts index 6a7ae7a7..e8e2964c 100644 --- a/Touchkebao/src/store/module/weChat/contacts.new.ts +++ b/Touchkebao/src/store/module/weChat/contacts.new.ts @@ -81,10 +81,27 @@ export const useContactStoreNew = createPersistStore( * 设置分组列表 */ setGroups: async (groups: ContactGroup[]) => { - // 按sort排序 - const sortedGroups = [...groups].sort( - (a, b) => (a.sort || 0) - (b.sort || 0), - ); + // 按自定义规则排序: + // 1. 默认群分组(groupType=2 且 id=0)始终在最前 + // 2. 未分组(groupType=1 且 id=99999999)始终在最后 + // 3. 其他分组按 sort 升序 + const sortedGroups = [...groups].sort((a, b) => { + const isDefaultGroupA = a.groupType === 2 && a.id === 0; + const isDefaultGroupB = b.groupType === 2 && b.id === 0; + const isUngroupedA = a.groupType === 1 && a.id === 99999999; + const isUngroupedB = b.groupType === 1 && b.id === 99999999; + + // 默认群分组始终最前 + if (isDefaultGroupA && !isDefaultGroupB) return -1; + if (!isDefaultGroupA && isDefaultGroupB) return 1; + + // 未分组始终最后 + if (isUngroupedA && !isUngroupedB) return 1; + if (!isUngroupedA && isUngroupedB) return -1; + + // 其他按 sort 排序 + return (a.sort || 0) - (b.sort || 0); + }); set({ groups: sortedGroups }); // 缓存分组列表