mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-19 02:51:47 +08:00
fix(core): fix error message missing (#11166)
This commit is contained in:
@@ -55,7 +55,7 @@ export const DesktopNotificationCard = ({
|
|||||||
{icon}
|
{icon}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className={styles.title}>{title ?? errorTitle}</div>
|
<div className={styles.title}>{title || errorTitle}</div>
|
||||||
|
|
||||||
{action ? (
|
{action ? (
|
||||||
<div className={clsx(styles.headAlignWrapper, styles.action)}>
|
<div className={clsx(styles.headAlignWrapper, styles.action)}>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useI18n } from '@affine/i18n';
|
||||||
import { CloseIcon, InformationFillDuotoneIcon } from '@blocksuite/icons/rc';
|
import { CloseIcon, InformationFillDuotoneIcon } from '@blocksuite/icons/rc';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
@@ -16,7 +17,14 @@ export function MobileNotificationCard({
|
|||||||
icon = <InformationFillDuotoneIcon />,
|
icon = <InformationFillDuotoneIcon />,
|
||||||
iconColor,
|
iconColor,
|
||||||
onDismiss,
|
onDismiss,
|
||||||
|
error,
|
||||||
} = notification;
|
} = notification;
|
||||||
|
const t = useI18n();
|
||||||
|
const errorI18nKey = error ? (`error.${error.name}` as const) : undefined;
|
||||||
|
const errorTitle =
|
||||||
|
errorI18nKey && errorI18nKey in t
|
||||||
|
? t[errorI18nKey](error?.data)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const [animated, setAnimated] = useState(false);
|
const [animated, setAnimated] = useState(false);
|
||||||
const [showDetail, setShowDetail] = useState(false);
|
const [showDetail, setShowDetail] = useState(false);
|
||||||
@@ -43,7 +51,9 @@ export function MobileNotificationCard({
|
|||||||
style={getCardVars(style, theme, iconColor)}
|
style={getCardVars(style, theme, iconColor)}
|
||||||
>
|
>
|
||||||
<span className={styles.toastIcon}>{icon}</span>
|
<span className={styles.toastIcon}>{icon}</span>
|
||||||
<span className={styles.toastLabel}>{notification.title}</span>
|
<span className={styles.toastLabel}>
|
||||||
|
{notification.title || errorTitle}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -62,7 +72,14 @@ const MobileNotifyDetail = ({
|
|||||||
message,
|
message,
|
||||||
footer,
|
footer,
|
||||||
action,
|
action,
|
||||||
|
error,
|
||||||
} = notification;
|
} = notification;
|
||||||
|
const t = useI18n();
|
||||||
|
const errorI18nKey = error ? (`error.${error.name}` as const) : undefined;
|
||||||
|
const errorTitle =
|
||||||
|
errorI18nKey && errorI18nKey in t
|
||||||
|
? t[errorI18nKey](error?.data)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const handleOpenChange = useCallback(
|
const handleOpenChange = useCallback(
|
||||||
(open: boolean) => {
|
(open: boolean) => {
|
||||||
@@ -91,7 +108,7 @@ const MobileNotifyDetail = ({
|
|||||||
<div className={styles.detailCard} onClick={e => e.stopPropagation()}>
|
<div className={styles.detailCard} onClick={e => e.stopPropagation()}>
|
||||||
<header className={styles.detailHeader}>
|
<header className={styles.detailHeader}>
|
||||||
<span className={styles.detailIcon}>{icon}</span>
|
<span className={styles.detailIcon}>{icon}</span>
|
||||||
<span className={styles.detailLabel}>{title}</span>
|
<span className={styles.detailLabel}>{title || errorTitle}</span>
|
||||||
<IconButton onClick={onClose} icon={<CloseIcon />} />
|
<IconButton onClick={onClose} icon={<CloseIcon />} />
|
||||||
</header>
|
</header>
|
||||||
<main className={styles.detailContent}>{message}</main>
|
<main className={styles.detailContent}>{message}</main>
|
||||||
|
|||||||
@@ -150,6 +150,16 @@ export function createI18nWrapper(getI18nFn: () => i18n) {
|
|||||||
|
|
||||||
return I18nMethod.t.bind(null, key);
|
return I18nMethod.t.bind(null, key);
|
||||||
},
|
},
|
||||||
|
has(self, key: string) {
|
||||||
|
if (key in self) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const i18n = getI18nFn();
|
||||||
|
if (i18n.exists(key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
}) as typeof I18nMethod &
|
}) as typeof I18nMethod &
|
||||||
ReturnType<typeof useAFFiNEI18N> & { [unknownKey: string]: () => string };
|
ReturnType<typeof useAFFiNEI18N> & { [unknownKey: string]: () => string };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user