mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
style(panel): align session migration card with modern borderless UI and bespoke controls
This commit is contained in:
+97
-59
@@ -20465,7 +20465,7 @@ return { BridgeStatusNotice };
|
||||
const { SessionMigrationCard } = (() => {
|
||||
/**
|
||||
* @fileoverview 跨端会话按需迁移设置卡片 (`SessionMigrationCard.js`)。
|
||||
* 仅当本机检测到 ≥2 个 Antigravity 客户端目录时展示,支持自由勾选根会话以新 UUID 无损克隆到目标端。
|
||||
* 仅当本机检测到 ≥2 个 Antigravity 客户端目录时展示,支持自由勾选根会话以完整迁移或克隆副本到目标端。
|
||||
*/
|
||||
|
||||
|
||||
@@ -20502,6 +20502,13 @@ function smigGetClientLabel(clientId) {
|
||||
return t('settings.oth.migClientDesktop');
|
||||
}
|
||||
|
||||
function smigGetModeOptions() {
|
||||
return [
|
||||
{ value: 'move', label: t('settings.oth.migModeMove') },
|
||||
{ value: 'clone', label: t('settings.oth.migModeClone') },
|
||||
];
|
||||
}
|
||||
|
||||
function smigFormatAge(epochMs) {
|
||||
const ts = Number(epochMs || 0);
|
||||
if (!Number.isFinite(ts) || ts <= 0) return '';
|
||||
@@ -20547,8 +20554,7 @@ const SessionMigrationCard = defineComponent({
|
||||
let sourceLabelEl = null;
|
||||
let targetLabelEl = null;
|
||||
let modeLabelEl = null;
|
||||
let modeMoveBtn = null;
|
||||
let modeCloneBtn = null;
|
||||
let modeSeg = null;
|
||||
let modeHintEl = null;
|
||||
let projectLabelEl = null;
|
||||
let sourceSelect = null;
|
||||
@@ -20556,9 +20562,11 @@ const SessionMigrationCard = defineComponent({
|
||||
let projectSelect = null;
|
||||
let projectFieldWrap = null;
|
||||
let searchInput = null;
|
||||
let searchClearBtn = null;
|
||||
let toggleAllBtn = null;
|
||||
let selectedCountEl = null;
|
||||
let listEl = null;
|
||||
let listScrollbar = null;
|
||||
let migrateBtnText = null;
|
||||
let migrateBtn = null;
|
||||
let resultBoxEl = null;
|
||||
@@ -20570,7 +20578,7 @@ const SessionMigrationCard = defineComponent({
|
||||
bodyMounted = true;
|
||||
|
||||
titleEl = h('span', { text: t('settings.oth.migTitle') });
|
||||
descEl = h('p', { className: 'smig-desc', text: t('settings.oth.migDesc') });
|
||||
descEl = h('p', { className: 'settings-hint-text smig-desc', text: t('settings.oth.migDesc') });
|
||||
refreshBtnText = h('span', { text: t('settings.oth.migRefreshBtn') });
|
||||
refreshBtn = h(
|
||||
'button',
|
||||
@@ -20584,38 +20592,27 @@ const SessionMigrationCard = defineComponent({
|
||||
[createSvgIcon('refresh', { size: 12 }), refreshBtnText]
|
||||
);
|
||||
|
||||
sourceLabelEl = h('span', { className: 'smig-field-label', text: t('settings.oth.migSourceLabel') });
|
||||
targetLabelEl = h('span', { className: 'smig-field-label', text: t('settings.oth.migTargetLabel') });
|
||||
modeLabelEl = h('span', { className: 'smig-field-label', text: t('settings.oth.migModeLabel') });
|
||||
modeMoveBtn = h('button', {
|
||||
type: 'button',
|
||||
className: 'smig-mode-btn is-active',
|
||||
text: t('settings.oth.migModeMove'),
|
||||
onClick: () => {
|
||||
if (migrationMode === 'move') return;
|
||||
migrationMode = 'move';
|
||||
lastResult = null;
|
||||
syncModeControls();
|
||||
renderResultBox();
|
||||
},
|
||||
});
|
||||
modeCloneBtn = h('button', {
|
||||
type: 'button',
|
||||
className: 'smig-mode-btn',
|
||||
text: t('settings.oth.migModeClone'),
|
||||
onClick: () => {
|
||||
if (migrationMode === 'clone') return;
|
||||
migrationMode = 'clone';
|
||||
sourceLabelEl = h('span', { className: 'form-label', text: t('settings.oth.migSourceLabel') });
|
||||
targetLabelEl = h('span', { className: 'form-label', text: t('settings.oth.migTargetLabel') });
|
||||
modeLabelEl = h('span', { className: 'form-label', text: t('settings.oth.migModeLabel') });
|
||||
modeSeg = SegmentedControl({
|
||||
ariaLabel: t('settings.oth.migModeLabel'),
|
||||
modelValue: migrationMode,
|
||||
options: smigGetModeOptions(),
|
||||
onUpdateModelValue: (val) => {
|
||||
if (!val || val === migrationMode) return;
|
||||
migrationMode = val;
|
||||
lastResult = null;
|
||||
syncModeControls();
|
||||
renderResultBox();
|
||||
},
|
||||
});
|
||||
modeSeg.el.classList?.add('smig-mode-seg');
|
||||
modeHintEl = h('span', {
|
||||
className: 'smig-mode-hint',
|
||||
className: 'settings-hint-text smig-mode-hint',
|
||||
text: t('settings.oth.migModeMoveHint'),
|
||||
});
|
||||
projectLabelEl = h('span', { className: 'smig-field-label', text: t('settings.oth.migProjectLabel') });
|
||||
projectLabelEl = h('span', { className: 'form-label', text: t('settings.oth.migProjectLabel') });
|
||||
|
||||
sourceSelect = CustomSelect({
|
||||
ariaLabel: t('settings.oth.migSourceLabel'),
|
||||
@@ -20653,21 +20650,46 @@ const SessionMigrationCard = defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
projectFieldWrap = h('div', { className: 'smig-field' }, [
|
||||
projectFieldWrap = h('div', { className: 'form-row smig-field' }, [
|
||||
projectLabelEl,
|
||||
projectSelect.el,
|
||||
]);
|
||||
|
||||
searchInput = h('input', {
|
||||
type: 'text',
|
||||
className: 'settings-text-input smig-search-input',
|
||||
className: 'smig-search-input',
|
||||
autocomplete: 'off',
|
||||
spellcheck: 'false',
|
||||
placeholder: t('settings.oth.migSearchPlaceholder'),
|
||||
value: '',
|
||||
});
|
||||
searchClearBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'smig-search-clear',
|
||||
hidden: true,
|
||||
'aria-label': t('select.clearSearch'),
|
||||
onClick: () => {
|
||||
searchQuery = '';
|
||||
searchInput.value = '';
|
||||
patchAttr(searchClearBtn, 'hidden', true);
|
||||
renderSessionList();
|
||||
searchInput.focus?.();
|
||||
},
|
||||
},
|
||||
[createSvgIcon('close', { size: 10 })]
|
||||
);
|
||||
searchInput.addEventListener?.('input', () => {
|
||||
searchQuery = String(searchInput.value || '').trim();
|
||||
patchAttr(searchClearBtn, 'hidden', !searchQuery);
|
||||
renderSessionList();
|
||||
});
|
||||
const searchWrap = h('div', { className: 'smig-search-wrap' }, [
|
||||
createSvgIcon('search', { size: 12, className: 'smig-search-icon' }),
|
||||
searchInput,
|
||||
searchClearBtn,
|
||||
]);
|
||||
|
||||
toggleAllBtn = h('button', {
|
||||
type: 'button',
|
||||
@@ -20688,6 +20710,10 @@ const SessionMigrationCard = defineComponent({
|
||||
|
||||
selectedCountEl = h('span', { className: 'smig-count-meta', text: '' });
|
||||
listEl = h('div', { className: 'smig-list', role: 'list' });
|
||||
listScrollbar = CustomScrollbar({
|
||||
className: 'smig-scroll-host',
|
||||
contentEl: listEl,
|
||||
});
|
||||
|
||||
migrateBtnText = h('span', {
|
||||
text: t('settings.oth.migActionBtn', { count: 0 }),
|
||||
@@ -20696,7 +20722,7 @@ const SessionMigrationCard = defineComponent({
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'btn-secondary smig-migrate-btn',
|
||||
className: 'btn-primary smig-migrate-btn',
|
||||
disabled: true,
|
||||
onClick: () => {
|
||||
void handleMigrate();
|
||||
@@ -20717,21 +20743,23 @@ const SessionMigrationCard = defineComponent({
|
||||
]),
|
||||
descEl,
|
||||
h('div', { className: 'smig-direction-grid' }, [
|
||||
h('div', { className: 'smig-field' }, [sourceLabelEl, sourceSelect.el]),
|
||||
h('div', { className: 'smig-field' }, [targetLabelEl, targetSelect.el]),
|
||||
h('div', { className: 'form-row smig-field' }, [sourceLabelEl, sourceSelect.el]),
|
||||
h('div', { className: 'form-row smig-field' }, [targetLabelEl, targetSelect.el]),
|
||||
]),
|
||||
h('div', { className: 'smig-field' }, [
|
||||
modeLabelEl,
|
||||
h('div', { className: 'smig-mode-bar' }, [modeMoveBtn, modeCloneBtn]),
|
||||
h('div', { className: 'smig-mode-block' }, [
|
||||
h('div', { className: 'settings-inline-row smig-mode-row' }, [
|
||||
modeLabelEl,
|
||||
modeSeg.el,
|
||||
]),
|
||||
modeHintEl,
|
||||
]),
|
||||
projectFieldWrap,
|
||||
h('div', { className: 'smig-toolbar' }, [
|
||||
searchInput,
|
||||
searchWrap,
|
||||
toggleAllBtn,
|
||||
selectedCountEl,
|
||||
]),
|
||||
listEl,
|
||||
listScrollbar.el,
|
||||
h('div', { className: 'smig-footer' }, [migrateBtn]),
|
||||
resultBoxEl,
|
||||
];
|
||||
@@ -20812,8 +20840,11 @@ const SessionMigrationCard = defineComponent({
|
||||
|
||||
function syncModeControls() {
|
||||
if (!bodyMounted) return;
|
||||
patchClasses(modeMoveBtn, { 'is-active': migrationMode === 'move' });
|
||||
patchClasses(modeCloneBtn, { 'is-active': migrationMode === 'clone' });
|
||||
modeSeg?.setProps({
|
||||
ariaLabel: t('settings.oth.migModeLabel'),
|
||||
modelValue: migrationMode,
|
||||
options: smigGetModeOptions(),
|
||||
});
|
||||
patchText(
|
||||
modeHintEl,
|
||||
migrationMode === 'clone'
|
||||
@@ -20923,13 +20954,18 @@ const SessionMigrationCard = defineComponent({
|
||||
} else {
|
||||
for (const item of filtered) {
|
||||
const checked = selectedIds.has(item.cascadeId);
|
||||
const checkboxEl = h('input', {
|
||||
type: 'checkbox',
|
||||
className: 'smig-checkbox',
|
||||
checked,
|
||||
disabled: Boolean(item.isRunning || isMigrating),
|
||||
});
|
||||
checkboxEl.checked = checked;
|
||||
const disabled = Boolean(item.isRunning || isMigrating);
|
||||
const checkIcon = createSvgIcon('check', { size: 10 });
|
||||
patchAttr(checkIcon, 'hidden', !checked);
|
||||
const checkboxEl = h(
|
||||
'span',
|
||||
{
|
||||
className: `select-checkbox smig-checkbox${checked ? ' is-checked' : ''}`,
|
||||
'aria-hidden': 'true',
|
||||
},
|
||||
[checkIcon]
|
||||
);
|
||||
|
||||
const toggleItem = () => {
|
||||
if (item.isRunning || isMigrating) return;
|
||||
if (selectedIds.has(item.cascadeId)) {
|
||||
@@ -20939,7 +20975,6 @@ const SessionMigrationCard = defineComponent({
|
||||
}
|
||||
renderSessionList();
|
||||
};
|
||||
checkboxEl.addEventListener?.('change', toggleItem);
|
||||
|
||||
const metaParts = [t('settings.oth.migStepsUnit', { count: item.stepCount })];
|
||||
const age = smigFormatAge(item.lastModifiedMs);
|
||||
@@ -20965,19 +21000,19 @@ const SessionMigrationCard = defineComponent({
|
||||
}
|
||||
|
||||
const rowEl = h(
|
||||
'div',
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
role: 'checkbox',
|
||||
'aria-checked': checked ? 'true' : 'false',
|
||||
disabled,
|
||||
className: `smig-item${checked ? ' is-selected' : ''}${item.isRunning ? ' is-running' : ''}`,
|
||||
role: 'listitem',
|
||||
onClick: (ev) => {
|
||||
if (ev?.target === checkboxEl) return;
|
||||
toggleItem();
|
||||
},
|
||||
onClick: toggleItem,
|
||||
},
|
||||
[
|
||||
checkboxEl,
|
||||
h('div', { className: 'smig-item-body' }, [
|
||||
h('div', { className: 'smig-item-top' }, [
|
||||
h('span', { className: 'smig-item-body' }, [
|
||||
h('span', { className: 'smig-item-top' }, [
|
||||
h('span', {
|
||||
className: 'smig-item-title',
|
||||
text: item.title || item.cascadeId.slice(0, 8),
|
||||
@@ -20986,7 +21021,7 @@ const SessionMigrationCard = defineComponent({
|
||||
h('span', { className: 'smig-item-meta', text: metaParts.join(' · ') }),
|
||||
]),
|
||||
...(subChildren.length > 0
|
||||
? [h('div', { className: 'smig-item-sub' }, subChildren)]
|
||||
? [h('span', { className: 'smig-item-sub' }, subChildren)]
|
||||
: []),
|
||||
]),
|
||||
]
|
||||
@@ -20995,6 +21030,8 @@ const SessionMigrationCard = defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
listScrollbar?.methods?.refresh?.();
|
||||
|
||||
patchAttr(migrateBtn, 'disabled', isMigrating || selectedIds.size === 0 || !targetClient);
|
||||
patchText(
|
||||
migrateBtnText,
|
||||
@@ -21172,11 +21209,10 @@ const SessionMigrationCard = defineComponent({
|
||||
patchText(sourceLabelEl, t('settings.oth.migSourceLabel'));
|
||||
patchText(targetLabelEl, t('settings.oth.migTargetLabel'));
|
||||
patchText(modeLabelEl, t('settings.oth.migModeLabel'));
|
||||
patchText(modeMoveBtn, t('settings.oth.migModeMove'));
|
||||
patchText(modeCloneBtn, t('settings.oth.migModeClone'));
|
||||
syncModeControls();
|
||||
patchText(projectLabelEl, t('settings.oth.migProjectLabel'));
|
||||
patchAttr(searchInput, 'placeholder', t('settings.oth.migSearchPlaceholder'));
|
||||
patchAttr(searchClearBtn, 'aria-label', t('select.clearSearch'));
|
||||
if (catalog?.available) {
|
||||
syncControlsAndList();
|
||||
}
|
||||
@@ -21188,6 +21224,8 @@ const SessionMigrationCard = defineComponent({
|
||||
clearTimeout(copiedTimer);
|
||||
copiedTimer = null;
|
||||
}
|
||||
modeSeg?.destroy?.();
|
||||
listScrollbar?.destroy?.();
|
||||
sourceSelect?.destroy?.();
|
||||
targetSelect?.destroy?.();
|
||||
projectSelect?.destroy?.();
|
||||
|
||||
Reference in New Issue
Block a user