Skip to content

Commit ec56278

Browse files
committed
Merge branch 'release/v1.1'
2 parents b62781e + 66ab70f commit ec56278

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

packages/message/custom_event_message.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ export class CustomEventMessage implements Message {
2424
protected isContent: boolean
2525
) {
2626
window.addEventListener((isContent ? "ct" : "fd") + flag, (event) => {
27-
if (event instanceof MouseEvent) {
27+
if (event instanceof MouseEvent && event.movementX && event.relatedTarget) {
2828
this.relatedTarget.set(event.movementX, event.relatedTarget!);
29-
return;
3029
} else if (event instanceof CustomEvent) {
3130
this.messageHandle(event.detail, new CustomEventPostMessage(this));
3231
}

src/pages/popup/App.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable prettier/prettier */
21
import { Discord, DocumentationSite, ExtVersion } from "@App/app/const";
32
import { Alert, Badge, Button, Card, Collapse, Dropdown, Menu, Switch } from "@arco-design/web-react";
43
import {
@@ -32,6 +31,7 @@ const iconStyle = {
3231
};
3332

3433
function App() {
34+
const [loading, setLoading] = useState(true);
3535
const [scriptList, setScriptList] = useState<ScriptMenu[]>([]);
3636
const [backScriptList, setBackScriptList] = useState<ScriptMenu[]>([]);
3737
const [showAlert, setShowAlert] = useState(false);
@@ -43,6 +43,7 @@ function App() {
4343
const [currentUrl, setCurrentUrl] = useState("");
4444
const [isEnableScript, setIsEnableScript] = useState(true);
4545
const [isBlacklist, setIsBlacklist] = useState(false);
46+
const [collapseActiveKey, setCollapseActiveKey] = useState<string[]>(["script"]);
4647
const { t } = useTranslation();
4748

4849
let url: URL | undefined;
@@ -83,6 +84,9 @@ function App() {
8384
setBackScriptList(resp.backScriptList || []);
8485
setIsBlacklist(resp.isBlacklist || false);
8586
checkScriptEnableAndUpdate();
87+
if (resp.backScriptList.length > 0) {
88+
setCollapseActiveKey(["script", "background"]);
89+
}
8690
})
8791
.catch((error) => {
8892
console.error("Failed to get popup data:", error);
@@ -91,6 +95,10 @@ function App() {
9195
setScriptList([]);
9296
setBackScriptList([]);
9397
setIsBlacklist(false);
98+
})
99+
.finally(() => {
100+
if (!isMounted) return;
101+
setLoading(false);
94102
});
95103
};
96104

@@ -199,8 +207,7 @@ function App() {
199207
const dropdown = dropdowns[0] as HTMLElement;
200208
console.log(dropdowns, dropdown.style.top);
201209
// 如果top是负数修改为0
202-
if (parseInt(dropdown
203-
.style.top) < 0) {
210+
if (parseInt(dropdown.style.top) < 0) {
204211
dropdown.style.top = "0px";
205212
}
206213
}
@@ -265,7 +272,10 @@ function App() {
265272
/>
266273
<Collapse
267274
bordered={false}
268-
defaultActiveKey={["script", ...(backScriptList.length > 0 ? ["background"] : [])]}
275+
activeKey={collapseActiveKey}
276+
onChange={(_, keys) => {
277+
setCollapseActiveKey(keys);
278+
}}
269279
style={{ maxWidth: 640, maxHeight: 500, overflow: "auto" }}
270280
>
271281
<CollapseItem
@@ -280,7 +290,11 @@ function App() {
280290
<CollapseItem
281291
header={t("enabled_background_scripts")}
282292
name="background"
283-
style={{ padding: "0" }}
293+
style={{
294+
padding: "0",
295+
// 未加载完成前不采用动画,避免collapseActiveKey变化时闪现
296+
...(loading ? { transform: "none" } : { transform: "height 0.2s cubic-bezier(0.34, 0.69, 0.1, 1)" }),
297+
}}
284298
contentStyle={{ padding: "0" }}
285299
>
286300
<ScriptMenuList script={backScriptList} isBackscript={true} currentUrl={currentUrl} />

0 commit comments

Comments
 (0)