Skip to content

Commit

Permalink
Update index.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming committed Jan 6, 2025
1 parent d9f38e0 commit 3fbb544
Showing 1 changed file with 39 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,24 @@ function CloseDialog({ onClose, side }: { onClose: () => void; side: 'left' | 'r
useOutsideClick(dialogRef, onClose);
const handleDisable = useCallback(() => {
void (
globalThis as unknown as {
$onekey: {
$private: {
request: (arg: { method: string }) => Promise<void>;
};
window.$onekey as {
$private: {
request: (arg: { method: string }) => Promise<void>;
};
}
).$onekey.$private.request({
).$private.request({
method: 'wallet_disableFloatingButton',
});
removeIcon();
}, [])
const handleHideOnSite = useCallback(() => {
void (
globalThis as unknown as {
$onekey: {
$private: {
request: (arg: { method: string; params: { url: string } }) => Promise<void>;
};
window.$onekey as {
$private: {
request: (arg: { method: string; params: { url: string } }) => Promise<void>;
};
}
).$onekey.$private.request({
).$private.request({
method: 'wallet_hideFloatingButtonOnSite',
params: { url: window.location.origin },
});
Expand Down Expand Up @@ -572,16 +568,14 @@ const savePosition = (params: {
bottom: string;
}) => {
void (
globalThis as unknown as {
$onekey: {
$private: {
request: (
arg: { method: string; params: IFloatingIconSettings }
) => Promise<void>
}
window.$onekey as {
$private: {
request: (
arg: { method: string; params: IFloatingIconSettings }
) => Promise<void>
}
}
).$onekey.$private.request({
).$private.request({
method: 'wallet_saveFloatingIconSettings',
params: {
position: params
Expand Down Expand Up @@ -611,18 +605,14 @@ function App() {
setIsExpanded(!isExpanded);
setIsShowSecurityInfo(true);
if (!securityInfo) {
const result = await (
window as unknown as {
$onekey: {
$private: {
request: (arg: {
method: string;
params: { url: string };
}) => Promise<{ securityInfo: IHostSecurity }>;
};
};
}
).$onekey.$private.request({
const result = await (window.$onekey as {
$private: {
request: (arg: {
method: string;
params: { url: string };
}) => Promise<{ securityInfo: IHostSecurity }>;
};
}).$private.request({
method: 'wallet_detectRiskLevel',
params: { url: window.location.origin },
});
Expand Down Expand Up @@ -677,7 +667,7 @@ function App() {
if (isDraggingTimerIdRef.current) {
clearTimeout(isDraggingTimerIdRef.current)
}
if (isDraggingRef.current) {
if (isDraggingRef.current) {
isDraggingRef.current = false
setTimeout(() => {
setIsDragging(false);
Expand Down Expand Up @@ -794,20 +784,18 @@ function App() {

async function injectIcon() {
const { isShow, i18n: i18nResponse, settings } = await (
globalThis as unknown as {
$onekey: {
$private: {
request: (
arg: { method: string; params: { url: string } }
) => Promise<{
isShow: boolean,
settings: IFloatingIconSettings,
i18n: i18nText
}>
}
window.$onekey as {
$private: {
request: (
arg: { method: string; params: { url: string } }
) => Promise<{
isShow: boolean,
settings: IFloatingIconSettings,
i18n: i18nText
}>
}
}
).$onekey.$private.request({
).$private.request({
method: 'wallet_isShowFloatingButton',
params: { url: window.location.origin },
});
Expand Down Expand Up @@ -840,15 +828,13 @@ export function injectFloatingButton() {
if (window.top !== window.self) {
return
}
(globalThis as unknown as {
$onekey: {
$private: {
onNotifyFloatingIconChanged: (
arg: ((params: { showFloatingIcon: boolean }) => void)
) => void
}
(window.$onekey as {
$private: {
onNotifyFloatingIconChanged: (
arg: ((params: { showFloatingIcon: boolean }) => void)
) => void
}
}).$onekey.$private.onNotifyFloatingIconChanged(({ showFloatingIcon }: { showFloatingIcon: boolean }) => {
}).$private.onNotifyFloatingIconChanged(({ showFloatingIcon }: { showFloatingIcon: boolean }) => {
if (showFloatingIcon) {
void injectIcon();
} else {
Expand Down

0 comments on commit 3fbb544

Please sign in to comment.