🐛 fix: Fix type

pull/568/head
canisminor1990 2024-05-15 22:54:39 +08:00
parent 8fd035cf41
commit a070ab9b2b
4 changed files with 40 additions and 148 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import { FC } from 'react';
import { memo, useMemo } from 'react';
import pkg from '@/../package.json';
import { ldModule } from '@/components/StructuredData/ld';
@ -6,14 +6,18 @@ import { ldModule } from '@/components/StructuredData/ld';
const TITLE = 'Stable Diffusion · LobeHub';
const DESC = pkg.description;
const StructuredData: FC = () => {
const ld = ldModule.generate({
description: DESC,
image:
'https://repository-images.githubusercontent.com/606329910/7fd79db5-fd91-450c-9e95-8ccce8ffdc0b',
title: TITLE,
url: '/',
});
const StructuredData = memo(() => {
const ld = useMemo(
() =>
ldModule.generate({
description: DESC,
image:
'https://repository-images.githubusercontent.com/606329910/7fd79db5-fd91-450c-9e95-8ccce8ffdc0b',
title: TITLE,
url: '/',
}),
[],
);
return (
<script
@ -22,5 +26,5 @@ const StructuredData: FC = () => {
type="application/ld+json"
/>
);
};
});
export default StructuredData;

View File

@ -2,7 +2,6 @@ import { SiDiscord, SiGithub, SiMedium, SiX } from '@icons-pack/react-simple-ico
import { ActionIcon } from '@lobehub/ui';
import { createStyles } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';
import { DISCORD_URL, GITHUB_REPO_URL, MEDIDUM_URL, X } from '@/const/url';
@ -25,32 +24,19 @@ const useStyles = createStyles(({ css, token }) => {
const Follow = memo(() => {
const { styles } = useStyles();
const { t } = useTranslation('common');
return (
<Flexbox gap={8} horizontal>
<a href={GITHUB_REPO_URL} rel="noreferrer" target={'_blank'}>
<ActionIcon
className={styles.icon}
icon={SiGithub as any}
title={t('follow', { name: 'GitHub' })}
/>
<ActionIcon className={styles.icon} icon={SiGithub as any} title={'GitHub'} />
</a>
<a href={X} rel="noreferrer" target={'_blank'}>
<ActionIcon className={styles.icon} icon={SiX as any} title={t('follow', { name: 'X' })} />
<ActionIcon className={styles.icon} icon={SiX as any} title={'X / Twitter'} />
</a>
<a href={DISCORD_URL} rel="noreferrer" target={'_blank'}>
<ActionIcon
className={styles.icon}
icon={SiDiscord as any}
title={t('follow', { name: 'Discord' })}
/>
<ActionIcon className={styles.icon} icon={SiDiscord as any} title={'Discord'} />
</a>
<a href={MEDIDUM_URL} rel="noreferrer" target={'_blank'}>
<ActionIcon
className={styles.icon}
icon={SiMedium as any}
title={t('follow', { name: 'Medium' })}
/>
<ActionIcon className={styles.icon} icon={SiMedium as any} title={'Medium'} />
</a>
</Flexbox>
);

View File

@ -1,98 +0,0 @@
// import { act, renderHook } from '@testing-library/react';
// import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
//
// import * as api from './api';
// import { useAppStore } from './index';
//
// vi.mock('./api', () => ({
// getLatestVersion: vi.fn(),
// getLocaleOptions: vi.fn(),
// getSetting: vi.fn(),
// getVersion: vi.fn(),
// postSetting: vi.fn(),
// }));
//
// // Mock for localStorage
// const localStorageMock = (function () {
// let store: any = {};
// return {
// clear: () => {
// store = {};
// },
// getItem: vi.fn((key) => store[key] || null),
// setItem: vi.fn((key, value) => {
// store[key] = value.toString();
// }),
// };
// })();
//
// (global as any).localStorage = localStorageMock;
//
// beforeAll(() => {
// // Initialize mocks before all tests
// vi.mocked(api.getSetting).mockResolvedValue(undefined);
// vi.mocked(api.postSetting).mockResolvedValue(undefined);
// vi.mocked(api.getVersion).mockResolvedValue('1.0.0');
// vi.mocked(api.getLatestVersion).mockResolvedValue('1.0.1');
// vi.mocked(api.getLocaleOptions).mockResolvedValue([]);
// });
//
// afterEach(() => {
// // Clear all mocks after each test
// vi.clearAllMocks();
// localStorage.clear();
// });
//
// describe('Store Actions', () => {
// it('onInit should initialize the store correctly', async () => {
// const { result } = renderHook(() => useAppStore());
//
// act(() => {
// result.current.onInit();
// });
//
// expect(result.current.loading).toBe(false);
// expect(result.current.version).toBe('1.0.0');
// expect(result.current.latestVersion).toBe('1.0.1');
// expect(result.current.localeOptions).toEqual([]);
// });
//
// it('onLoadSetting should load settings correctly', async () => {
// const { result } = renderHook(() => useAppStore());
//
// const mockSetting = {
// confirmPageUnload: true,
// enableSidebar: false,
// };
//
// // Simulate local storage having a setting
// localStorage.setItem('SD-LOBE-SETTING', JSON.stringify(mockSetting));
//
// act(() => {
// result.current.onLoadSetting();
// });
//
// expect(result.current.setting).toEqual(expect.objectContaining(mockSetting));
// });
//
// it('onSetSetting should update the setting correctly', async () => {
// const { result } = renderHook(() => useAppStore());
//
// const newSetting = {
// confirmPageUnload: false,
// };
//
// await act(async () => {
// await result.current.onSetSetting(newSetting);
// });
//
// expect(localStorage.setItem).toHaveBeenCalledWith(
// 'SD-LOBE-SETTING',
// JSON.stringify(expect.objectContaining(newSetting)),
// );
// expect(result.current.setting).toEqual(expect.objectContaining(newSetting));
// expect(api.postSetting).toHaveBeenCalledWith(expect.objectContaining(newSetting));
// });
//
// // Add more tests for each action as required...
// });