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 }); // 缓存分组列表