fix(sidebar): 修复删除工作区不生效与控制台 TDZ 报错
- ConversationSidebar: immediate watcher 在 setup 阶段同步执行,却引用了 之后才声明的 isGroupByWorkspaceActive,触发 TDZ ReferenceError; 调整声明顺序并加注释防回退 - WorkspaceSwitcher: onDocClick 为捕获阶段监听,未排除 teleport 到 body 的二级菜单,点击菜单项(删除/重命名)会先关闭整个浮层,导致内联 确认框永远不可见、删除流程无法走完;补充 .ws-menu-floating 排除 - WorkspaceSwitcher: 删除确认按钮区靠右对齐
This commit is contained in:
parent
c6151e86fe
commit
a900d6cc61
@ -994,6 +994,12 @@ watch(
|
|||||||
{ immediate: true, deep: true }
|
{ immediate: true, deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isGroupByWorkspaceActive = computed(
|
||||||
|
() => props.groupByWorkspace && props.hostWorkspaceEnabled && Array.isArray(props.workspaces) && props.workspaces.length > 0
|
||||||
|
);
|
||||||
|
|
||||||
|
/* 注意:本 watcher 声明必须放在 isGroupByWorkspaceActive 之后——
|
||||||
|
immediate 回调会在 setup 阶段同步执行,提前引用会触发 TDZ 报错。 */
|
||||||
watch(
|
watch(
|
||||||
() => props.currentWorkspaceId,
|
() => props.currentWorkspaceId,
|
||||||
async () => {
|
async () => {
|
||||||
@ -1011,10 +1017,6 @@ watch(
|
|||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const isGroupByWorkspaceActive = computed(
|
|
||||||
() => props.groupByWorkspace && props.hostWorkspaceEnabled && Array.isArray(props.workspaces) && props.workspaces.length > 0
|
|
||||||
);
|
|
||||||
const sortedWorkspaces = computed(() => {
|
const sortedWorkspaces = computed(() => {
|
||||||
const list = Array.isArray(props.workspaces) ? [...props.workspaces] : [];
|
const list = Array.isArray(props.workspaces) ? [...props.workspaces] : [];
|
||||||
return list.sort((a: any, b: any) => {
|
return list.sort((a: any, b: any) => {
|
||||||
|
|||||||
@ -400,6 +400,10 @@ watch(
|
|||||||
const onDocClick = (event: MouseEvent) => {
|
const onDocClick = (event: MouseEvent) => {
|
||||||
const target = event.target as Node | null;
|
const target = event.target as Node | null;
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
|
/* 二级菜单 teleport 到 body、与 popoverEl 是兄弟节点;capture 阶段会先于此处
|
||||||
|
触发,若不排除会导致点击菜单项(删除/重命名)时整个浮层先被关闭,
|
||||||
|
菜单动作设置的内联状态(deletingId/renamingId)永远不可见。 */
|
||||||
|
if ((target as Element).closest?.('.ws-menu-floating')) return;
|
||||||
if (popoverEl.value && !popoverEl.value.contains(target)) {
|
if (popoverEl.value && !popoverEl.value.contains(target)) {
|
||||||
/* 点击入口按钮:交给按钮自身的 toggle 处理(已展开则收起),
|
/* 点击入口按钮:交给按钮自身的 toggle 处理(已展开则收起),
|
||||||
避免 capture 阶段先 close、按钮 click 又重新打开导致重播动画 */
|
避免 capture 阶段先 close、按钮 click 又重新打开导致重播动画 */
|
||||||
@ -698,6 +702,7 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
.ws-confirm-actions {
|
.ws-confirm-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user