@michengai/dsh-im-connect 1.0.48 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/CHANGELOG.zh-CN.md +10 -0
- package/client.js +206 -70
- package/lib/client.js +206 -70
- package/lib/manager.d.ts +11 -5
- package/lib/manager.d.ts.map +1 -1
- package/lib/manager.js +63 -7
- package/lib/manager.js.map +1 -1
- package/package.json +1 -1
- package/src/manager.ts +75 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.49] - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Sidebar Channel Sessions Grouped by Account Instance & Quick Settings (#78)
|
|
6
|
+
|
|
7
|
+
- **Account-level session grouping**: When multiple accounts are configured for the same messaging platform, sidebar sessions are neatly organized into dedicated groups per account instance, preventing conversations across accounts from mixing together.
|
|
8
|
+
- **Clear & intuitive group titles**: Displays a clean platform title (e.g., "WeChat", "WeCom") in single-account environments, and automatically appends account remarks or custom names (e.g., "WeChat · Support") in multi-account environments.
|
|
9
|
+
- **Direct account settings via context menu**: Right-clicking any channel group heading now opens the settings and diagnostics panel for that specific account directly, making it faster to adjust credentials and remarks.
|
|
10
|
+
- **Instant title refresh on remark change**: Updating an account's remark name immediately refreshes the sidebar group title in real time without requiring a reload or restart.
|
|
11
|
+
- **Context menu presentation cleanup**: Fixed an issue where right-clicking a channel group could inadvertently leave the menu item labeled as "Rename", and eliminated extraneous blank space and divider lines at the bottom of the menu for a cleaner look.
|
|
12
|
+
|
|
3
13
|
## [1.0.48] - 2026-11-20
|
|
4
14
|
|
|
5
15
|
### WeCom Custom WebSocket URL for On-Premise Deployments (#76)
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [1.0.49] - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### 侧边栏频道会话按账号独立分组与快捷设置(#78)
|
|
6
|
+
|
|
7
|
+
- **账号独立分组展示**:同一聊天平台下绑定多个账号时,侧边栏会话列表自动按各账号实例独立成组,避免多账号消息混杂在同一组内。
|
|
8
|
+
- **清晰直观的分组标题**:单账号场景简洁呈现平台名称(如「微信」、「企业微信」);多账号场景自动追加账号备注名或自定义标识(如「微信 · 客服号」),账号归属一目了然。
|
|
9
|
+
- **右键菜单直达账号设置**:在侧边栏右键点击任意频道分组,可直接打开该具体账号的设置与诊断面板,修改备注或凭据更快捷。
|
|
10
|
+
- **备注变更即时刷新**:修改或保存账号备注名后,侧边栏分组标题即时同步更新,无需重启插件或刷新页面。
|
|
11
|
+
- **分组右键菜单体验优化**:修复右键点击频道分组时菜单项文案偶现残留为「重命名」的问题,并移除菜单底部残留的多余空白与分割线,保持快捷设置菜单干净整洁。
|
|
12
|
+
|
|
3
13
|
## [1.0.48] - 2026-11-20
|
|
4
14
|
|
|
5
15
|
### 企业微信私有化部署 WebSocket URL 支持(#76)
|
package/client.js
CHANGED
|
@@ -428,8 +428,13 @@ window.__ModuleLoader__.load({
|
|
|
428
428
|
function parseChannelSettingsRequest(value) {
|
|
429
429
|
if (!value || typeof value !== "object") return undefined;
|
|
430
430
|
const channelId = typeof value.channelId === "string" ? value.channelId.trim() : "";
|
|
431
|
-
|
|
432
|
-
|
|
431
|
+
const accountId = typeof value.accountId === "string" ? value.accountId.trim() : "";
|
|
432
|
+
if (!channelId && !accountId) return undefined;
|
|
433
|
+
return {
|
|
434
|
+
channelId,
|
|
435
|
+
accountId: accountId || undefined,
|
|
436
|
+
name: typeof value.name === "string" ? value.name : "",
|
|
437
|
+
};
|
|
433
438
|
}
|
|
434
439
|
function writeChannelSettingsRequest(storage, request) {
|
|
435
440
|
try { storage && storage.setItem(CHANNEL_SETTINGS_STORAGE_KEY, JSON.stringify(request)); } catch { /* ignore */ }
|
|
@@ -452,10 +457,20 @@ window.__ModuleLoader__.load({
|
|
|
452
457
|
function resolveChannelSettingsTarget(request, channels) {
|
|
453
458
|
const parsed = parseChannelSettingsRequest(request);
|
|
454
459
|
if (!parsed || !Array.isArray(channels)) return undefined;
|
|
455
|
-
|
|
460
|
+
if (parsed.accountId) {
|
|
461
|
+
for (const channel of channels) {
|
|
462
|
+
const account = (channel.accounts || []).find((a) => a && a.id === parsed.accountId);
|
|
463
|
+
if (account) return { channelId: channel.id, accountId: account.id };
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const channel = channels.find((item) => item && (item.id === parsed.channelId || (item.accounts || []).some((a) => a && a.id === parsed.channelId)));
|
|
456
467
|
if (!channel) return undefined;
|
|
457
468
|
const accounts = channel.accounts || [];
|
|
458
|
-
|
|
469
|
+
const matchedAccount = accounts.find((a) => a && (a.id === parsed.accountId || a.id === parsed.channelId));
|
|
470
|
+
return {
|
|
471
|
+
channelId: channel.id,
|
|
472
|
+
accountId: matchedAccount ? matchedAccount.id : (accounts.length === 1 ? accounts[0].id : undefined),
|
|
473
|
+
};
|
|
459
474
|
}
|
|
460
475
|
function pickSettingsSectionButton(buttons, labels) {
|
|
461
476
|
const normalize = (value) => String(value || "").replace(/\s+/g, "").trim().toLowerCase();
|
|
@@ -3297,15 +3312,33 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
3297
3312
|
let requestHostSessionRefresh = () => {};
|
|
3298
3313
|
let channelSessionIds = new Set();
|
|
3299
3314
|
let channelSessionChannels = new Map();
|
|
3315
|
+
let channelSessionAccounts = new Map();
|
|
3316
|
+
let channelAccountMeta = new Map();
|
|
3300
3317
|
let channelMembershipRevision = 0;
|
|
3301
3318
|
const channelMembershipListeners = new Set();
|
|
3319
|
+
function parsePlatformFromChannelId(id) {
|
|
3320
|
+
const val = String(id || "");
|
|
3321
|
+
const split = val.indexOf("_");
|
|
3322
|
+
return split > 0 ? val.slice(0, split) : val;
|
|
3323
|
+
}
|
|
3302
3324
|
function updateChannelMembership(groups) {
|
|
3303
3325
|
const next = new Set();
|
|
3304
3326
|
const channels = new Map();
|
|
3305
|
-
|
|
3327
|
+
const accounts = new Map();
|
|
3328
|
+
const meta = new Map();
|
|
3329
|
+
for (const group of groups || []) {
|
|
3330
|
+
const platform = group.platform || parsePlatformFromChannelId(group.id);
|
|
3331
|
+
const accountId = group.accountId || group.id;
|
|
3332
|
+
meta.set(accountId, {
|
|
3333
|
+
id: accountId,
|
|
3334
|
+
accountId,
|
|
3335
|
+
platform,
|
|
3336
|
+
label: group.label || "",
|
|
3337
|
+
});
|
|
3306
3338
|
for (const session of group.sessions || []) {
|
|
3307
3339
|
next.add(session.sessionId);
|
|
3308
|
-
channels.set(String(session.sessionId),
|
|
3340
|
+
channels.set(String(session.sessionId), platform);
|
|
3341
|
+
accounts.set(String(session.sessionId), accountId);
|
|
3309
3342
|
}
|
|
3310
3343
|
}
|
|
3311
3344
|
let changed = next.size !== channelSessionIds.size || [...next].some(id => !channelSessionIds.has(id));
|
|
@@ -3314,15 +3347,35 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
3314
3347
|
if (channelSessionChannels.get(id) !== channel) { changed = true; break; }
|
|
3315
3348
|
}
|
|
3316
3349
|
}
|
|
3350
|
+
if (!changed) {
|
|
3351
|
+
for (const [id, account] of accounts) {
|
|
3352
|
+
if (channelSessionAccounts.get(id) !== account) { changed = true; break; }
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
if (!changed) {
|
|
3356
|
+
if (meta.size !== channelAccountMeta.size) {
|
|
3357
|
+
changed = true;
|
|
3358
|
+
} else {
|
|
3359
|
+
for (const [id, item] of meta) {
|
|
3360
|
+
const prev = channelAccountMeta.get(id);
|
|
3361
|
+
if (!prev || prev.label !== item.label || prev.platform !== item.platform) {
|
|
3362
|
+
changed = true;
|
|
3363
|
+
break;
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3317
3368
|
if (changed) {
|
|
3318
3369
|
channelSessionIds = next;
|
|
3319
3370
|
channelSessionChannels = channels;
|
|
3371
|
+
channelSessionAccounts = accounts;
|
|
3372
|
+
channelAccountMeta = meta;
|
|
3320
3373
|
channelMembershipRevision += 1;
|
|
3321
3374
|
for (const listener of channelMembershipListeners) listener();
|
|
3322
3375
|
}
|
|
3323
3376
|
try { requestHostSessionRefresh(changed); } catch { /* 下次频道轮询继续重试 */ }
|
|
3324
3377
|
}
|
|
3325
|
-
/** IM 会话 ID
|
|
3378
|
+
/** IM 会话 ID 所属渠道平台(如 weixin/feishu),供会话行图标展示。 */
|
|
3326
3379
|
function channelIdOfSession(sessionId) {
|
|
3327
3380
|
const value = String(sessionId || "");
|
|
3328
3381
|
const mapped = channelSessionChannels.get(value);
|
|
@@ -3335,6 +3388,17 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
3335
3388
|
const platform = instance.split("_", 1)[0];
|
|
3336
3389
|
return platform || undefined;
|
|
3337
3390
|
}
|
|
3391
|
+
/** IM 会话 ID 所属具体账号实例(如 feishu_1)。 */
|
|
3392
|
+
function accountIdOfSession(sessionId) {
|
|
3393
|
+
const value = String(sessionId || "");
|
|
3394
|
+
const mapped = channelSessionAccounts.get(value);
|
|
3395
|
+
if (mapped) return mapped;
|
|
3396
|
+
if (!value.startsWith("im:")) return channelSessionChannels.get(value);
|
|
3397
|
+
const rest = value.slice(3);
|
|
3398
|
+
const split = rest.indexOf(":");
|
|
3399
|
+
const instance = split > 0 ? rest.slice(0, split) : rest;
|
|
3400
|
+
return instance || undefined;
|
|
3401
|
+
}
|
|
3338
3402
|
// 新旧两代 IM 前缀都要认,否则存量会话升级后会掉出渠道页签。
|
|
3339
3403
|
const isChannelSession = (id) => {
|
|
3340
3404
|
const value = String(id);
|
|
@@ -5269,7 +5333,6 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5269
5333
|
// ---------------------------------------------------------------------
|
|
5270
5334
|
|
|
5271
5335
|
const CHANNEL_WORKSPACE_PREFIX = "dsh-im-channel:";
|
|
5272
|
-
const CHANNEL_GROUP_IDS = ["weixin", "wecom", "qq", "feishu", "lark", "dingtalk", "telegram", "discord", "slack"];
|
|
5273
5336
|
const EMPTY_SESSION_STATE = { ids: [], byId: {}, current: null };
|
|
5274
5337
|
const EMPTY_WORKSPACE_STATE = { items: [], archivedSessionIds: [], pinnedSessionIds: [], state: "idle", phase: "ready", error: null };
|
|
5275
5338
|
const CHANNEL_GROUP_OPTION_ATTR = "data-ima-channel-group-option";
|
|
@@ -5397,16 +5460,34 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5397
5460
|
}
|
|
5398
5461
|
|
|
5399
5462
|
function channelGroupsFromSessionState(state, t) {
|
|
5400
|
-
const groups = new Map(
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5463
|
+
const groups = new Map();
|
|
5464
|
+
const metaMap = channelAccountMeta;
|
|
5465
|
+
for (const [accountId, meta] of metaMap) {
|
|
5466
|
+
groups.set(accountId, {
|
|
5467
|
+
id: accountId,
|
|
5468
|
+
platform: meta.platform,
|
|
5469
|
+
label: meta.label || channelLabel({ id: meta.platform }, t),
|
|
5470
|
+
sessions: [],
|
|
5471
|
+
});
|
|
5472
|
+
}
|
|
5405
5473
|
const src = state || EMPTY_SESSION_STATE;
|
|
5406
5474
|
for (const id of src.ids || []) {
|
|
5407
|
-
const
|
|
5475
|
+
const platform = channelIdOfSession(id);
|
|
5476
|
+
if (!platform) continue;
|
|
5477
|
+
const accountId = accountIdOfSession(id) || platform;
|
|
5478
|
+
let group = groups.get(accountId);
|
|
5479
|
+
if (!group) {
|
|
5480
|
+
const meta = metaMap.get(accountId);
|
|
5481
|
+
group = {
|
|
5482
|
+
id: accountId,
|
|
5483
|
+
platform,
|
|
5484
|
+
label: (meta && meta.label) || channelLabel({ id: platform }, t),
|
|
5485
|
+
sessions: [],
|
|
5486
|
+
};
|
|
5487
|
+
groups.set(accountId, group);
|
|
5488
|
+
}
|
|
5408
5489
|
const session = src.byId && src.byId[id];
|
|
5409
|
-
if (
|
|
5490
|
+
if (session) group.sessions.push({ sessionId: id, updatedAt: session.updatedAt });
|
|
5410
5491
|
}
|
|
5411
5492
|
return [...groups.values()].filter((group) => group.sessions.length > 0);
|
|
5412
5493
|
}
|
|
@@ -5428,7 +5509,7 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5428
5509
|
const src = state || EMPTY_WORKSPACE_STATE;
|
|
5429
5510
|
const key = groups.map((group) => [
|
|
5430
5511
|
group.id,
|
|
5431
|
-
channelLabel(group, t),
|
|
5512
|
+
group.label || channelLabel(group, t),
|
|
5432
5513
|
channelGroupCreatedAt(group),
|
|
5433
5514
|
(group.sessions || []).map((session) => session.sessionId).join(","),
|
|
5434
5515
|
].join("\0")).join("\0\0");
|
|
@@ -5439,7 +5520,7 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5439
5520
|
return {
|
|
5440
5521
|
workspaceId,
|
|
5441
5522
|
id: workspaceId,
|
|
5442
|
-
title: channelLabel(group, t),
|
|
5523
|
+
title: group.label || channelLabel(group, t),
|
|
5443
5524
|
path: "",
|
|
5444
5525
|
sessionIds: (group.sessions || []).map((session) => session.sessionId),
|
|
5445
5526
|
createdAt: channelGroupCreatedAt(group),
|
|
@@ -5466,8 +5547,6 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5466
5547
|
return result;
|
|
5467
5548
|
}
|
|
5468
5549
|
|
|
5469
|
-
let channelIconCssValue;
|
|
5470
|
-
|
|
5471
5550
|
/** 把 React 元素渲染成可直接注入官方 DOM 的 HTML。 */
|
|
5472
5551
|
function channelMarkup(element) {
|
|
5473
5552
|
if (typeof document === "undefined") return "";
|
|
@@ -5494,7 +5573,7 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5494
5573
|
}
|
|
5495
5574
|
|
|
5496
5575
|
const channelLogoUrlCache = new Map();
|
|
5497
|
-
/** 频道品牌标 data URL
|
|
5576
|
+
/** 频道品牌标 data URL,供工作区图标和会话行复用。 */
|
|
5498
5577
|
function channelLogoUrl(id) {
|
|
5499
5578
|
if (channelLogoUrlCache.has(id)) return channelLogoUrlCache.get(id);
|
|
5500
5579
|
const markup = channelMarkup(h(BrandMark, { id, compact: true }));
|
|
@@ -5503,26 +5582,6 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5503
5582
|
return url;
|
|
5504
5583
|
}
|
|
5505
5584
|
|
|
5506
|
-
/** 频道分组头图标:用品牌标覆盖官方文件夹图标,并保持悬停时可见。 */
|
|
5507
|
-
function channelIconCss() {
|
|
5508
|
-
if (channelIconCssValue !== undefined) return channelIconCssValue;
|
|
5509
|
-
if (typeof document === "undefined") {
|
|
5510
|
-
channelIconCssValue = "";
|
|
5511
|
-
return channelIconCssValue;
|
|
5512
|
-
}
|
|
5513
|
-
channelIconCssValue = CHANNEL_GROUP_IDS.map((id) => {
|
|
5514
|
-
const logo = channelLogoUrl(id);
|
|
5515
|
-
if (!logo) return "";
|
|
5516
|
-
const row = `[data-row-key="workspace:${channelWorkspaceId(id)}"]`;
|
|
5517
|
-
return `.ima-channel-official ${row}>span:first-child>svg{display:none!important}`
|
|
5518
|
-
+ `.ima-channel-official ${row}>span:first-child{display:inline-flex!important;background:${logo} center/contain no-repeat!important}`
|
|
5519
|
-
// 宿主在悬停时用 chevron 换掉文件夹;频道分组保持品牌图标可见。
|
|
5520
|
-
+ `.ima-channel-official ${row}:hover>span:first-child{display:inline-flex!important}`
|
|
5521
|
-
+ `.ima-channel-official ${row}:hover>span:nth-child(2){display:none!important}`;
|
|
5522
|
-
}).join("");
|
|
5523
|
-
return channelIconCssValue;
|
|
5524
|
-
}
|
|
5525
|
-
|
|
5526
5585
|
let channelWorkspaceIconCache = { key: "", css: "" };
|
|
5527
5586
|
/**
|
|
5528
5587
|
* 按工作区/工作区树分组时,如果某个工作区的频道会话都来自同一个频道,
|
|
@@ -5559,6 +5618,55 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5559
5618
|
return css;
|
|
5560
5619
|
}
|
|
5561
5620
|
|
|
5621
|
+
/**
|
|
5622
|
+
* 替换菜单项内的图标与文案,兼容各种带有嵌套包装、CSS Module 类名或纯结构节点的宿主 DOM。
|
|
5623
|
+
*/
|
|
5624
|
+
function replaceMenuItemContent(button, templateText, label, icon) {
|
|
5625
|
+
const ownerDoc = button.ownerDocument || (typeof document !== "undefined" ? document : null);
|
|
5626
|
+
let iconContainer = button.querySelector('[class*="itemIcon"], [class*="Icon"]');
|
|
5627
|
+
if (!iconContainer && button.firstElementChild) {
|
|
5628
|
+
const first = button.firstElementChild;
|
|
5629
|
+
const isSvg = first.tagName && first.tagName.toLowerCase() === "svg";
|
|
5630
|
+
const isImg = first.tagName && first.tagName.toLowerCase() === "img";
|
|
5631
|
+
if (isSvg || isImg || button.children.length > 1) {
|
|
5632
|
+
iconContainer = first;
|
|
5633
|
+
}
|
|
5634
|
+
}
|
|
5635
|
+
const isInsideIcon = (el) => iconContainer && typeof iconContainer.contains === "function" && iconContainer.contains(el);
|
|
5636
|
+
const labelContainer = button.querySelector('[class*="itemLabel"], [class*="Label"]')
|
|
5637
|
+
|| [...button.querySelectorAll("span, div")].find((el) => el !== iconContainer && !isInsideIcon(el) && (el.textContent || "").trim() === templateText)
|
|
5638
|
+
|| (button.children.length > 1 ? button.children[1] : null)
|
|
5639
|
+
|| (button.lastElementChild !== iconContainer ? button.lastElementChild : null);
|
|
5640
|
+
|
|
5641
|
+
if (icon !== undefined) {
|
|
5642
|
+
if (!iconContainer && ownerDoc && typeof ownerDoc.createElement === "function") {
|
|
5643
|
+
iconContainer = ownerDoc.createElement("span");
|
|
5644
|
+
if (typeof iconContainer.setAttribute === "function") {
|
|
5645
|
+
iconContainer.setAttribute("class", "ima-menu-item-icon");
|
|
5646
|
+
iconContainer.setAttribute("aria-hidden", "true");
|
|
5647
|
+
}
|
|
5648
|
+
button.insertBefore(iconContainer, button.firstChild);
|
|
5649
|
+
}
|
|
5650
|
+
if (iconContainer) {
|
|
5651
|
+
iconContainer.innerHTML = icon;
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
if (labelContainer && labelContainer !== iconContainer) {
|
|
5655
|
+
labelContainer.textContent = label;
|
|
5656
|
+
} else {
|
|
5657
|
+
const remaining = [...button.children].filter((el) => el !== iconContainer);
|
|
5658
|
+
if (remaining.length >= 1) {
|
|
5659
|
+
remaining[0].textContent = label;
|
|
5660
|
+
} else if (ownerDoc && typeof ownerDoc.createElement === "function") {
|
|
5661
|
+
const textNode = ownerDoc.createElement("span");
|
|
5662
|
+
textNode.textContent = label;
|
|
5663
|
+
button.appendChild(textNode);
|
|
5664
|
+
} else {
|
|
5665
|
+
button.textContent = label;
|
|
5666
|
+
}
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
|
|
5562
5670
|
/**
|
|
5563
5671
|
* 官方视图选项菜单没有扩展位,注入第四个分组项「按频道」。
|
|
5564
5672
|
* 只在频道页签挂载期间生效。
|
|
@@ -5585,11 +5693,11 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5585
5693
|
button.removeAttribute("disabled");
|
|
5586
5694
|
button.disabled = false;
|
|
5587
5695
|
button.classList.remove("danger");
|
|
5588
|
-
for (const
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5696
|
+
for (const child of [...button.children]) {
|
|
5697
|
+
if (child.tagName && child.tagName.toLowerCase() === "svg") child.remove();
|
|
5698
|
+
}
|
|
5699
|
+
for (const check of button.querySelectorAll('[class*="check"], svg[class*="check"]')) check.remove();
|
|
5700
|
+
replaceMenuItemContent(button, (first.textContent || "").trim(), options.label, channelMarkup(h(IconQueueOutline, { size: 16 })));
|
|
5593
5701
|
if (options.checked) {
|
|
5594
5702
|
const check = document.createElement("span");
|
|
5595
5703
|
check.innerHTML = channelMarkup(h(IconCheckOutline, { size: 16 }));
|
|
@@ -5646,23 +5754,53 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5646
5754
|
}
|
|
5647
5755
|
if (target.closest('[role="menu"]') === null) channelId = undefined;
|
|
5648
5756
|
};
|
|
5649
|
-
const
|
|
5757
|
+
const hiddenElements = new Map();
|
|
5758
|
+
const hideElement = (el) => {
|
|
5759
|
+
if (!el || typeof el.getAttribute !== "function") return;
|
|
5760
|
+
if (!hiddenElements.has(el)) {
|
|
5761
|
+
hiddenElements.set(el, {
|
|
5762
|
+
display: el.style.display || "",
|
|
5763
|
+
ariaHidden: el.getAttribute("aria-hidden"),
|
|
5764
|
+
});
|
|
5765
|
+
}
|
|
5766
|
+
el.style.display = "none";
|
|
5767
|
+
el.setAttribute("aria-hidden", "true");
|
|
5768
|
+
};
|
|
5769
|
+
const purgeDetached = () => {
|
|
5770
|
+
for (const el of hiddenElements.keys()) {
|
|
5771
|
+
if (typeof document.contains === "function" && !document.contains(el)) {
|
|
5772
|
+
hiddenElements.delete(el);
|
|
5773
|
+
}
|
|
5774
|
+
}
|
|
5775
|
+
};
|
|
5650
5776
|
const hideOthers = (menu, ours) => {
|
|
5777
|
+
purgeDetached();
|
|
5651
5778
|
for (const item of menu.querySelectorAll('button[role="menuitem"]')) {
|
|
5652
5779
|
if (ours.has(item)) continue;
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5780
|
+
hideElement(item);
|
|
5781
|
+
const wrapper = item.parentElement;
|
|
5782
|
+
if (wrapper && wrapper !== menu && wrapper.parentElement === menu) {
|
|
5783
|
+
let containsOurs = false;
|
|
5784
|
+
for (const o of ours) {
|
|
5785
|
+
if (typeof wrapper.contains === "function" && wrapper.contains(o)) {
|
|
5786
|
+
containsOurs = true;
|
|
5787
|
+
break;
|
|
5788
|
+
}
|
|
5789
|
+
}
|
|
5790
|
+
if (!containsOurs) hideElement(wrapper);
|
|
5658
5791
|
}
|
|
5659
|
-
|
|
5660
|
-
|
|
5792
|
+
}
|
|
5793
|
+
for (const sep of menu.querySelectorAll('[role="separator"], hr, [class*="separator"], [class*="divider"]')) {
|
|
5794
|
+
hideElement(sep);
|
|
5661
5795
|
}
|
|
5662
5796
|
};
|
|
5663
5797
|
const inject = (menu) => {
|
|
5664
5798
|
if (channelId === undefined || performance.now() - rememberedAt > 2000) return;
|
|
5665
|
-
|
|
5799
|
+
const existing = menu.querySelector(`button[${CHANNEL_GROUP_MENU_ATTR}="true"]`);
|
|
5800
|
+
if (existing !== null) {
|
|
5801
|
+
hideOthers(menu, new Set([existing]));
|
|
5802
|
+
return;
|
|
5803
|
+
}
|
|
5666
5804
|
const items = [...menu.querySelectorAll('button[role="menuitem"]')];
|
|
5667
5805
|
if (items.length === 0) return;
|
|
5668
5806
|
const menuText = items.map((item) => item.textContent || "").join(" ");
|
|
@@ -5682,15 +5820,15 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5682
5820
|
button.removeAttribute(CHANNEL_GROUP_MENU_ATTR);
|
|
5683
5821
|
button.removeAttribute("aria-disabled");
|
|
5684
5822
|
button.removeAttribute("disabled");
|
|
5823
|
+
button.removeAttribute("aria-keyshortcuts");
|
|
5824
|
+
button.removeAttribute("aria-describedby");
|
|
5685
5825
|
button.disabled = false;
|
|
5686
5826
|
button.style.opacity = "";
|
|
5687
5827
|
button.style.cursor = "";
|
|
5688
5828
|
button.classList.remove("danger");
|
|
5689
5829
|
button.setAttribute(CHANNEL_GROUP_MENU_ATTR, "true");
|
|
5690
|
-
const
|
|
5691
|
-
|
|
5692
|
-
if (spans[1] !== undefined) spans[1].textContent = label;
|
|
5693
|
-
else button.textContent = label;
|
|
5830
|
+
for (const extra of button.querySelectorAll('[class*="check"], [class*="shortcut"]')) extra.remove();
|
|
5831
|
+
replaceMenuItemContent(button, (template.textContent || "").trim(), label, icon);
|
|
5694
5832
|
let fired = false;
|
|
5695
5833
|
const activate = (event) => {
|
|
5696
5834
|
if (fired) return;
|
|
@@ -5731,12 +5869,12 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5731
5869
|
observer.disconnect();
|
|
5732
5870
|
document.removeEventListener("pointerdown", remember, true);
|
|
5733
5871
|
document.removeEventListener("click", remember, true);
|
|
5734
|
-
for (const [
|
|
5735
|
-
|
|
5736
|
-
if (previous.ariaHidden === null)
|
|
5737
|
-
else
|
|
5872
|
+
for (const [el, previous] of hiddenElements) {
|
|
5873
|
+
el.style.display = previous.display;
|
|
5874
|
+
if (previous.ariaHidden === null) el.removeAttribute("aria-hidden");
|
|
5875
|
+
else el.setAttribute("aria-hidden", previous.ariaHidden);
|
|
5738
5876
|
}
|
|
5739
|
-
|
|
5877
|
+
hiddenElements.clear();
|
|
5740
5878
|
for (const item of document.querySelectorAll(`[${CHANNEL_GROUP_MENU_ATTR}="true"]`)) item.parentElement?.remove();
|
|
5741
5879
|
};
|
|
5742
5880
|
}
|
|
@@ -5791,7 +5929,6 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5791
5929
|
const groups = useMemo(() => channelGroupsFromSessionState(sessionSource, t), [membershipRevision, sessionSource, t]);
|
|
5792
5930
|
const groupsRef = useRef(groups);
|
|
5793
5931
|
groupsRef.current = groups;
|
|
5794
|
-
const [channelIcons, setChannelIcons] = useState("");
|
|
5795
5932
|
const [workspaceIcons, setWorkspaceIcons] = useState("");
|
|
5796
5933
|
const open = props.openSession || hostProps.open || hostProps.openSession;
|
|
5797
5934
|
const openChannelSettings = props.openChannelSettings || hostProps.openChannelSettings;
|
|
@@ -5799,10 +5936,6 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5799
5936
|
|
|
5800
5937
|
useEffect(() => { ensureStyle(); }, []);
|
|
5801
5938
|
|
|
5802
|
-
useEffect(() => {
|
|
5803
|
-
if (groupBy === "channel" && channelIcons === "") setChannelIcons(channelIconCss());
|
|
5804
|
-
}, [channelIcons, groupBy]);
|
|
5805
|
-
|
|
5806
5939
|
const memberKey = groups.map((group) => group.id + ":" + (group.sessions || []).map((session) => session.sessionId).join(",")).join("|");
|
|
5807
5940
|
const memberIds = useMemo(() => {
|
|
5808
5941
|
const ids = new Set();
|
|
@@ -5870,7 +6003,11 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5870
6003
|
resolve: (channelId) => groupsRef.current.find((group) => group.id === channelId),
|
|
5871
6004
|
onSettings: (group) => {
|
|
5872
6005
|
if (typeof openChannelSettings === "function") {
|
|
5873
|
-
openChannelSettings({
|
|
6006
|
+
openChannelSettings({
|
|
6007
|
+
channelId: group.platform || group.id,
|
|
6008
|
+
accountId: group.accountId || group.id,
|
|
6009
|
+
name: group.label || channelLabel(group, t),
|
|
6010
|
+
});
|
|
5874
6011
|
return;
|
|
5875
6012
|
}
|
|
5876
6013
|
openImSettings();
|
|
@@ -5938,7 +6075,6 @@ body:not([data-ds-dark-theme]) .ima-section-card{background:var(--dsw-alias-bg-l
|
|
|
5938
6075
|
|
|
5939
6076
|
return h(React.Fragment, null,
|
|
5940
6077
|
h("div", { className: "ima-channel-official", "data-mode": groupBy },
|
|
5941
|
-
groupBy === "channel" && channelIcons !== "" && h("style", null, channelIcons),
|
|
5942
6078
|
groupBy !== "channel" && workspaceIcons !== "" && h("style", null, workspaceIcons),
|
|
5943
6079
|
// 宿主列表失败时 phase 仍停在 pending,没有横幅就是整页空白。
|
|
5944
6080
|
groupsError && h("div", { className: "ima-channel-error", role: "alert" }, t("error.load")),
|