mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:49:19 +08:00
feat: 优化缩小化
This commit is contained in:
@@ -27,6 +27,13 @@ function ensureShadow(host: HTMLElement): ShadowRoot {
|
|||||||
return host.shadowRoot ?? host.attachShadow({ mode: 'open' });
|
return host.shadowRoot ?? host.attachShadow({ mode: 'open' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setHostHidden(hidden: boolean) {
|
||||||
|
const host = document.getElementById(HOST_ID);
|
||||||
|
if (host) {
|
||||||
|
host.style.display = hidden ? 'none' : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeLauncher() {
|
function removeLauncher() {
|
||||||
document.getElementById(LAUNCHER_ID)?.remove();
|
document.getElementById(LAUNCHER_ID)?.remove();
|
||||||
}
|
}
|
||||||
@@ -70,12 +77,16 @@ function unmountApp() {
|
|||||||
if (host?.shadowRoot) {
|
if (host?.shadowRoot) {
|
||||||
host.shadowRoot.innerHTML = '';
|
host.shadowRoot.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
if (host) {
|
||||||
|
host.style.display = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mountApp() {
|
function mountApp() {
|
||||||
const host = ensureHost();
|
const host = ensureHost();
|
||||||
const shadow = ensureShadow(host);
|
const shadow = ensureShadow(host);
|
||||||
shadow.innerHTML = '';
|
shadow.innerHTML = '';
|
||||||
|
host.style.display = '';
|
||||||
|
|
||||||
const styleEl = document.createElement('style');
|
const styleEl = document.createElement('style');
|
||||||
styleEl.textContent = styles;
|
styleEl.textContent = styles;
|
||||||
@@ -87,8 +98,9 @@ function mountApp() {
|
|||||||
app = createApp(FloatingPanel, {
|
app = createApp(FloatingPanel, {
|
||||||
onClose: () => setFloatingVisible(false),
|
onClose: () => setFloatingVisible(false),
|
||||||
onMinimize: () => {
|
onMinimize: () => {
|
||||||
|
// 只隐藏,不销毁 Vue,保留已累计的多日数据
|
||||||
minimized = true;
|
minimized = true;
|
||||||
unmountApp();
|
setHostHidden(true);
|
||||||
showLauncher();
|
showLauncher();
|
||||||
visible = true;
|
visible = true;
|
||||||
emitFeatureEvent(FEATURE_ID, 'minimized');
|
emitFeatureEvent(FEATURE_ID, 'minimized');
|
||||||
@@ -115,10 +127,9 @@ export function setFloatingVisible(next: boolean): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
visible = true;
|
visible = true;
|
||||||
|
minimized = false;
|
||||||
removeLauncher();
|
removeLauncher();
|
||||||
if (minimized) {
|
setHostHidden(false);
|
||||||
minimized = false;
|
|
||||||
}
|
|
||||||
if (!app) {
|
if (!app) {
|
||||||
mountApp();
|
mountApp();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"updatedAt": "2026-08-16T12:42:11.994Z",
|
"updatedAt": "2026-08-16T12:53:27.630Z",
|
||||||
"features": [
|
"features": [
|
||||||
{
|
{
|
||||||
"id": "pdd-ad-fee",
|
"id": "pdd-ad-fee",
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"https://yingxiao.pinduoduo.com/"
|
"https://yingxiao.pinduoduo.com/"
|
||||||
],
|
],
|
||||||
"entry": "pdd-ad-fee.js",
|
"entry": "pdd-ad-fee.js",
|
||||||
"sha256": "6bd6e3ac7ca697fe9f6dd67b1cf17013959981c6e7cae8d95d175c95325071ed",
|
"sha256": "da5e94dde412aff60347b39e73a321be517b55ba5e801f44432070fdce439c4b",
|
||||||
"executionWorld": "main"
|
"executionWorld": "main"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user