Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: adjust the style of the floating icon. #269

Merged
merged 12 commits into from
Dec 19, 2024
2 changes: 1 addition & 1 deletion packages/core/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export const EXT_PORT_UI_TO_BG = 'onekey@EXT_PORT_UI_TO_BG';
export const DEBUG_LOGGER_STORAGE_KEY = '$$ONEKEY_DEBUG_LOGGER';
export const WALLET_INFO_LOACAL_KEY = 'onekey_wallet_info_local_key'
export const WALLET_INFO_LOACAL_KEY_V5 = "onekey_wallet_info_local_key_v5";
export const ONEKEY_ALIGN_PRIMARY_ACCOUNT = '$$ONEKEY_ALIGN_PRIMARY_ACCOUNT';
export const ONEKEY_REQUEST_TO_ALL_CS = '$$ONEKEY_REQUEST_TO_ALL_CS';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as uuid from 'uuid';

import { JsBridgeBase, consts } from '@onekeyfe/cross-inpage-provider-core';

const { EXT_PORT_OFFSCREEN_TO_BG, EXT_PORT_CS_TO_BG, EXT_PORT_UI_TO_BG, ONEKEY_ALIGN_PRIMARY_ACCOUNT } = consts;
const { EXT_PORT_OFFSCREEN_TO_BG, EXT_PORT_CS_TO_BG, EXT_PORT_UI_TO_BG, ONEKEY_REQUEST_TO_ALL_CS } = consts;

class JsBridgeExtBackground extends JsBridgeBase {
constructor(config: IJsBridgeConfig) {
Expand Down Expand Up @@ -143,7 +143,7 @@ class JsBridgeExtBackground extends JsBridgeBase {
data = await data({ origin });
}
// Send a notification to the port of the specified origin
if (!targetOrigin || targetOrigin === origin || targetOrigin === ONEKEY_ALIGN_PRIMARY_ACCOUNT) {
if (!targetOrigin || targetOrigin === origin || targetOrigin === ONEKEY_REQUEST_TO_ALL_CS) {
// TODO check ports disconnected
this.requestSync({
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ function SecurityInfo({
color: 'rgba(0, 0, 0, 0.88)',
fontSize: '13px',
fontWeight: '500',
overflow: 'hidden',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

文本溢出处理优化

添加了文本溢出处理,防止长文本破坏布局。建议进一步完善:

 style={{ 
   width: '100%', 
   overflow: 'hidden', 
   textOverflow: 'ellipsis' 
+  whiteSpace: 'nowrap'
 }}

Also applies to: 505-513

}}
>
{securityInfo?.dapp?.logo ? (
Expand Down Expand Up @@ -500,13 +501,17 @@ function SecurityInfo({
/>
</svg>
)}
{securityInfo?.dapp?.name || securityInfo?.host}
<span style={{ width: '100%', overflow: 'hidden' }}>
{securityInfo?.dapp?.name || securityInfo?.host}
</span>
</div>
<div
style={{
width: "24",
height: "24",
cursor: "pointer"
cursor: "pointer",
display: 'flex',
alignItems: 'center',
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
}}
onClick={() => {
onClose();
Expand Down Expand Up @@ -670,7 +675,7 @@ function App() {
style={{
position: 'fixed',
zIndex: 999_999,
top: '20%',
bottom: '25%',
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
right: '-146px',
background: 'rgba(255, 255, 255, 1)',
borderWidth: '0.33px',
Expand Down Expand Up @@ -711,7 +716,7 @@ function App() {
);
}

export async function injectFloatingButton() {
async function injectIcon() {
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
const { isShow, i18n: i18nResponse } = await (globalThis as unknown as {
$onekey: {
$private: {
Expand Down Expand Up @@ -744,3 +749,18 @@ export async function injectFloatingButton() {
document.body.appendChild(div);
render(<App />, document.body, div);
}

huhuanming marked this conversation as resolved.
Show resolved Hide resolved
export function injectFloatingButton() {
(globalThis as unknown as {
$onekey: {
$private: {
onNotifyFloatingIconChanged: (
arg: ((params: { showFloatingIcon: boolean }) => void)
) => void
}
}
}).$onekey.$private.onNotifyFloatingIconChanged(({ showFloatingIcon }: { showFloatingIcon: boolean }) => {
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
console.log(showFloatingIcon);
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
});
void injectIcon();
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
}
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ const PROVIDER_EVENTS = {

const METHODS = {
wallet_events_ext_switch_changed: 'wallet_events_ext_switch_changed',
wallet_events_dapp_network_changed: 'wallet_events_dapp_network_changed'
wallet_events_dapp_network_changed: 'wallet_events_dapp_network_changed',
wallet_events_floating_icon_changed: 'wallet_events_floating_icon_changed',
};

class ProviderPrivate extends ProviderBase {
_listeners: { type: string, callback: (params: any) => void }[] = []
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
constructor(props: IInpageProviderConfig) {
super(props);
try {
Expand Down Expand Up @@ -85,13 +87,24 @@ class ProviderPrivate extends ProviderBase {
}
} else if (method === METHODS.wallet_events_dapp_network_changed) {
this.notifyNetworkChanged(params as {networkChangedText: string})
} else if (method === METHODS.wallet_events_floating_icon_changed) {
console.log('wallet_events_floating_icon_changed ===>>>> : ', params);
// this._listeners.forEach((listener) => {
// if (listener.type === method) {
// listener.callback(params)
// }
// })
}
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
});
} catch (e) {
console.error(e);
}
}

onNotifyFloatingIconChanged(callback: (params: {showFloatingIcon: boolean}) => void) {
this._listeners.push({ type: METHODS.wallet_events_floating_icon_changed, callback })
}
huhuanming marked this conversation as resolved.
Show resolved Hide resolved

protected providerName: IInjectedProviderNamesStrings = IInjectedProviderNames.$private;

request(data: unknown) {
Expand Down
Loading