chore: power-by and error-fallback (#917)

Co-authored-by: sealday <sealday@gmail.com>
Reviewed-on: daoyoucloud/tachybase#917
This commit is contained in:
sealday 2024-05-07 02:56:20 +08:00
parent adfb78d936
commit 1bbb769951
16 changed files with 22 additions and 110 deletions

View File

@ -37,7 +37,6 @@ export { default as locale } from './locale';
export * from './nocobase-buildin-plugin';
export * from './plugin-manager';
export * from './pm';
export * from './powered-by';
export * from './powered-by-v2';
export * from './record-provider';
export * from './route-switch';

View File

@ -755,7 +755,7 @@
"Column width": "Column width",
"Sortable": "Sortable",
"Enable link": "Enable link",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "This is likely a NocoBase internals bug. Please open an issue at <1>here</1>",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "This is likely a Tachybase internals bug. Please open an issue at <1>here</1>",
"Render Failed": "Render Failed",
"App error": "App error",
"Feedback": "Feedback",

View File

@ -738,7 +738,7 @@
"Column width": "Largeur de colonne",
"Sortable": "Triable",
"Enable link": "Activer le lien",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "Ceci est probablement un bogue interne de NocoBase. Veuillez ouvrir un problème <1>ici</1>",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "Ceci est probablement un bogue interne de Tachybase. Veuillez ouvrir un problème <1>ici</1>",
"Render Failed": "Échec du rendu",
"Feedback": "Commentaires",
"Try again": "Réessayer",

View File

@ -596,7 +596,7 @@
"Error message": "エラーメッセージ",
"Record picker": "レコードピッカー",
"Search and select collection": "コレクションを検索して選択",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "これはNocoBaseの内部バグの可能性があります。 <1>こちら</1>で問題を報告してください",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "これはTachybaseの内部バグの可能性があります。 <1>こちら</1>で問題を報告してください",
"Render Failed": "レンダリングに失敗しました",
"Feedback": "フィードバック",
"Try again": "再試行",

View File

@ -780,7 +780,7 @@
"Theme": "테마",
"Default theme": "기본 테마",
"Compact theme": "간소한 테마",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "이것은 아마도 NocoBase 내부 버그입니다. <1>여기</1>에서 문제를 열어주시기 바랍니다.",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "이것은 아마도 Tachybase 내부 버그입니다. <1>여기</1>에서 문제를 열어주시기 바랍니다.",
"Render Failed": "렌더링 실패",
"Feedback": "피드백",
"Try again": "다시 시도",

View File

@ -702,7 +702,7 @@
"Column width": "Largura da coluna",
"Sortable": "Classificável",
"Enable link": "Habilitar link",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "Isso provavelmente é um bug interno do NocoBase. Por favor, abra um problema em <1>aqui</1>",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "Isso provavelmente é um bug interno do Tachybase. Por favor, abra um problema em <1>aqui</1>",
"Render Failed": "Falha na renderização",
"Feedback": "Feedback",
"Try again": "Tente novamente",

View File

@ -500,7 +500,7 @@
"Single select and radio fields can be used as the grouping field": "Одиночное поле выбора и радиополя могут использоваться в качестве поля группировки",
"Sign up successfully, and automatically jump to the sign in page": "Зарегистрируйтесь успешно и автоматически перейдете на страницу входа",
"Search and select collection": "Поиск и выбор коллекции",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "Это, вероятно, ошибка внутреннего устройства NocoBase. Пожалуйста, откройте проблему <1>здесь</1>",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "Это, вероятно, ошибка внутреннего устройства Tachybase. Пожалуйста, откройте проблему <1>здесь</1>",
"Render Failed": "Ошибка рендеринга",
"Feedback": "Обратная связь",
"Try again": "Попробуйте еще раз",

View File

@ -500,7 +500,7 @@
"Single select and radio fields can be used as the grouping field": "Gruplama alanı olarak tek seçim ve radyo alanları kullanılabilir",
"Sign up successfully, and automatically jump to the sign in page": "Başarılı bir şekilde kaydolun ve otomatik olarak oturum açma sayfasına geçin",
"Search and select collection": "Koleksiyon ara ve seç",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "Bu, NocoBase iç işlevleri hatası olabilir. Lütfen <1>burada</1> bir sorun açın",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "Bu, Tachybase iç işlevleri hatası olabilir. Lütfen <1>burada</1> bir sorun açın",
"Render Failed": "Oluşturma başarısız",
"Feedback": "Geri bildirim",
"Try again": "Tekrar dene",

View File

@ -758,7 +758,7 @@
"Column width": "Ширина стовпця",
"Sortable": "Сортований",
"Enable link": "Включити посилання",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "Це, ймовірно, помилка внутрішніх компонентів NocoBase. Будь ласка, створіть проблему <1>тут</1>",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "Це, ймовірно, помилка внутрішніх компонентів Tachybase. Будь ласка, створіть проблему <1>тут</1>",
"Render Failed": "Помилка відображення",
"Feedback": "Зворотній зв'язок",
"Try again": "Спробуйте ще раз",

View File

@ -787,7 +787,7 @@
"Theme": "主题",
"Default theme": "默认主题",
"Compact theme": "紧凑主题",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "这可能是 NocoBase 内部的问题,你可以在<1>这里</1>将该错误反馈给我们,我们会尽快修复",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "这可能是 Tachybase 内部的问题,你可以在<1>这里</1>将该错误反馈给我们,我们会尽快修复",
"Render Failed": "渲染失败",
"Feedback": "反馈问题",
"Try again": "重试一下",

View File

@ -780,7 +780,7 @@
"Theme": "主題",
"Default theme": "預設主題",
"Compact theme": "緊湊主題",
"This is likely a NocoBase internals bug. Please open an issue at <1>here</1>": "這可能是 NocoBase 內部的問題,你可以在<1>這裡</1>將該錯誤反饋給我們,我們會盡快修復",
"This is likely a Tachybase internals bug. Please open an issue at <1>here</1>": "這可能是 Tachybase 內部的問題,你可以在<1>這裡</1>將該錯誤反饋給我們,我們會盡快修復",
"Render Failed": "渲染失敗",
"Feedback": "反饋問題",
"Try again": "重試一下",

View File

@ -19,7 +19,7 @@ export const PoweredByV2 = () => {
}
`}
>
©2023-{year} ICP备2023024678号
©2023-{year} TachyBase Team
</div>
);
};

View File

@ -1,42 +0,0 @@
import { css, cx } from '@emotion/css';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useToken } from '../style';
import { usePlugin } from '../application';
import { parseHTML } from '@nocobase/utils/client';
import { useCurrentAppInfo } from '../appInfo/CurrentAppInfoProvider';
export const PoweredBy = () => {
const { i18n } = useTranslation();
const { token } = useToken();
const customBrandPlugin: any = usePlugin('@nocobase/plugin-custom-brand');
const data = useCurrentAppInfo();
const urls = {
'en-US': 'https://www.nocobase.com',
'zh-CN': 'https://cn.nocobase.com',
};
const style = css`
text-align: center;
color: ${token.colorTextDescription};
a {
color: ${token.colorTextDescription};
&:hover {
color: ${token.colorText};
}
}
`;
const appVersion = `<span class="nb-app-version">v${data?.data?.version}</span>`;
return (
<div
className={cx(style, 'nb-brand')}
dangerouslySetInnerHTML={{
__html: parseHTML(
customBrandPlugin?.options?.options?.brand ||
`Powered by <a href="${urls[i18n.language] || urls['en-US']}" target="__blank">NocoBase</a>`,
{ appVersion },
),
}}
></div>
);
};

View File

@ -1,18 +1,18 @@
import { Button, Result, Typography } from 'antd';
import React, { FC } from 'react';
import React from 'react';
import { FallbackProps, useErrorBoundary } from 'react-error-boundary';
import { Trans, useTranslation } from 'react-i18next';
const { Paragraph, Text, Link } = Typography;
export const ErrorFallback: FC<FallbackProps> = ({ error }) => {
export const ErrorFallback = ({ error }: FallbackProps) => {
const { resetBoundary } = useErrorBoundary();
const { t } = useTranslation();
const subTitle = (
<Trans>
{'This is likely a NocoBase internals bug. Please open an issue at '}
<Link href="https://github.com/nocobase/nocobase/issues" target="_blank">
{'This is likely a TachyCode internals bug. Please open an issue at '}
<Link href="https://git.daoyoucloud.com/daoyoucloud/tachycode/issues" target="_blank">
here
</Link>
</Trans>
@ -26,7 +26,12 @@ export const ErrorFallback: FC<FallbackProps> = ({ error }) => {
title={t('Render Failed')}
subTitle={subTitle}
extra={[
<Button type="primary" key="feedback" href="https://github.com/nocobase/nocobase/issues" target="_blank">
<Button
type="primary"
key="feedback"
href="https://git.daoyoucloud.com/daoyoucloud/tachycode/issues"
target="_blank"
>
{t('Feedback')}
</Button>,
<Button key="try" onClick={resetBoundary}>

View File

@ -1,50 +0,0 @@
import { Button, Result, Typography } from 'antd';
import React, { FC } from 'react';
import { FallbackProps, useErrorBoundary } from 'react-error-boundary';
import { Trans, useTranslation } from 'react-i18next';
const { Paragraph, Text, Link } = Typography;
export const ErrorFallback: FC<FallbackProps> = ({ error }) => {
const { resetBoundary } = useErrorBoundary();
const { t } = useTranslation();
const subTitle = (
<Trans>
{'This is likely a TachyCode internals bug. Please open an issue at '}
<Link href="https://git.daoyoucloud.com/daoyoucloud/tachycode/issues" target="_blank">
here
</Link>
</Trans>
);
return (
<div style={{ backgroundColor: 'white' }}>
<Result
style={{ maxWidth: '60vw', margin: 'auto' }}
status="error"
title={t('Render Failed')}
subTitle={subTitle}
extra={[
<Button
type="primary"
key="feedback"
href="https://git.daoyoucloud.com/daoyoucloud/tachycode/issues"
target="_blank"
>
{t('Feedback')}
</Button>,
<Button key="try" onClick={resetBoundary}>
{t('Try again')}
</Button>,
]}
>
<Paragraph copyable>
<Text type="danger" style={{ whiteSpace: 'pre-line', textAlign: 'center' }}>
{error.stack}
</Text>
</Paragraph>
</Result>
</div>
);
};

View File

@ -1 +1 @@
export * from './ErrorFallback2';
export * from './ErrorFallback';