Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
bentwnghk committed Jan 21, 2024
2 parents 2877408 + 5d611dc commit 82fc899
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 18 deletions.
1 change: 1 addition & 0 deletions locales/ar/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "إغلاق",
"confirmRemoveSessionItemAlert": "سيتم حذف هذا المساعد قريبًا، وبمجرد الحذف لن يمكن استعادته، يرجى تأكيد الإجراء",
"copy": "نسخ",
"copyFail": "فشل في النسخ",
"copySuccess": "تم النسخ بنجاح",
"defaultAgent": "مساعد افتراضي",
"defaultSession": "جلسة افتراضية",
Expand Down
1 change: 1 addition & 0 deletions locales/de-DE/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Schließen",
"confirmRemoveSessionItemAlert": "Möchten Sie diesen Assistenten wirklich löschen? Nach dem Löschen kann er nicht wiederhergestellt werden. Bitte bestätigen Sie Ihre Aktion.",
"copy": "Kopieren",
"copyFail": "Kopieren fehlgeschlagen",
"copySuccess": "Kopieren erfolgreich",
"defaultAgent": "Standardassistent",
"defaultSession": "Standardassistent",
Expand Down
1 change: 1 addition & 0 deletions locales/en-US/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Close",
"confirmRemoveSessionItemAlert": "You are about to delete this agent. Once deleted, it cannot be recovered. Please confirm your action.",
"copy": "Copy",
"copyFail": "Copy failed",
"copySuccess": "Copied successfully",
"defaultAgent": "Default Agent",
"defaultSession": "Default Agent",
Expand Down
1 change: 1 addition & 0 deletions locales/es-ES/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Cerrar",
"confirmRemoveSessionItemAlert": "Estás a punto de eliminar este asistente. Una vez eliminado, no se podrá recuperar. Por favor, confirma tu acción",
"copy": "Copiar",
"copyFail": "Fallo al copiar",
"copySuccess": "¡Copia exitosa!",
"defaultAgent": "Asistente predeterminado",
"defaultSession": "Sesión predeterminada",
Expand Down
1 change: 1 addition & 0 deletions locales/fr-FR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Fermer",
"confirmRemoveSessionItemAlert": "Vous êtes sur le point de supprimer cet agent. Une fois supprimé, il ne pourra pas être récupéré. Veuillez confirmer votre action.",
"copy": "Copier",
"copyFail": "Échec de la copie",
"copySuccess": "Copie réussie",
"defaultAgent": "Agent par défaut",
"defaultSession": "Session par défaut",
Expand Down
1 change: 1 addition & 0 deletions locales/it-IT/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Chiudi",
"confirmRemoveSessionItemAlert": "Stai per eliminare questo assistente. Una volta eliminato, non sarà possibile recuperarlo. Confermi l'operazione?",
"copy": "Copia",
"copyFail": "Copia non riuscita",
"copySuccess": "Copia riuscita",
"defaultAgent": "Assistente predefinito",
"defaultSession": "Sessione predefinita",
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "閉じる",
"confirmRemoveSessionItemAlert": "このエージェントを削除します。削除後は元に戻すことはできません。操作を確認してください。",
"copy": "コピー",
"copyFail": "コピーに失敗しました",
"copySuccess": "コピーが成功しました",
"defaultAgent": "デフォルトエージェント",
"defaultSession": "デフォルトセッション",
Expand Down
1 change: 1 addition & 0 deletions locales/ko-KR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "닫기",
"confirmRemoveSessionItemAlert": "이 에이전트를 삭제하려고 합니다. 삭제 후에는 복구할 수 없습니다. 작업을 확인하십시오.",
"copy": "복사",
"copyFail": "복사 실패",
"copySuccess": "복사 성공",
"defaultAgent": "기본 에이전트",
"defaultSession": "기본 세션",
Expand Down
1 change: 1 addition & 0 deletions locales/nl-NL/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Sluiten",
"confirmRemoveSessionItemAlert": "U staat op het punt deze assistent te verwijderen. Na verwijdering kan deze niet worden hersteld. Weet u zeker dat u door wilt gaan?",
"copy": "Kopiëren",
"copyFail": "Kopiëren mislukt",
"copySuccess": "Kopiëren gelukt",
"defaultAgent": "Standaard assistent",
"defaultSession": "Standaard assistent",
Expand Down
1 change: 1 addition & 0 deletions locales/pl-PL/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Zamknij",
"confirmRemoveSessionItemAlert": "Czy na pewno chcesz usunąć tego asystenta? Po usunięciu nie będzie możliwe jego odzyskanie.",
"copy": "Kopiuj",
"copyFail": "Nie udało się skopiować",
"copySuccess": "Skopiowano pomyślnie",
"defaultAgent": "Domyślny asystent",
"defaultSession": "Domyślna sesja",
Expand Down
1 change: 1 addition & 0 deletions locales/pt-BR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Fechar",
"confirmRemoveSessionItemAlert": "Você está prestes a excluir este assistente. Após a exclusão, não será possível recuperá-lo. Por favor, confirme sua ação.",
"copy": "Copiar",
"copyFail": "Falha ao copiar",
"copySuccess": "Cópia bem-sucedida",
"defaultAgent": "Assistente padrão",
"defaultSession": "Sessão padrão",
Expand Down
1 change: 1 addition & 0 deletions locales/ru-RU/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Закрыть",
"confirmRemoveSessionItemAlert": "Вы собираетесь удалить этого агента. После удаления его будет невозможно восстановить. Подтвердите ваше действие",
"copy": "Копировать",
"copyFail": "Не удалось скопировать",
"copySuccess": "Успешно скопировано",
"defaultAgent": "Пользовательский агент",
"defaultSession": "Пользовательский агент",
Expand Down
1 change: 1 addition & 0 deletions locales/tr-TR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Kapat",
"confirmRemoveSessionItemAlert": "Bu asistanı silmek üzeresiniz. Silindikten sonra geri alınamaz. Lütfen eyleminizi onaylayın.",
"copy": "Kopyala",
"copyFail": "Kopyalama başarısız oldu",
"copySuccess": "Kopyalama Başarılı",
"defaultAgent": "Varsayılan Asistan",
"defaultSession": "Varsayılan Asistan",
Expand Down
1 change: 1 addition & 0 deletions locales/vi-VN/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "Đóng",
"confirmRemoveSessionItemAlert": "Bạn sắp xóa trợ lý này. Sau khi xóa, bạn sẽ không thể khôi phục. Vui lòng xác nhận hành động của bạn",
"copy": "Sao chép",
"copyFail": "Sao chép thất bại",
"copySuccess": "Sao chép thành công",
"defaultAgent": "Trợ lý mặc định",
"defaultSession": "Phiên mặc định",
Expand Down
1 change: 1 addition & 0 deletions locales/zh-CN/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "关闭",
"confirmRemoveSessionItemAlert": "即将删除该助手,删除后该将无法找回,请确认你的操作",
"copy": "复制",
"copyFail": "复制失败",
"copySuccess": "复制成功",
"defaultAgent": "自定义助手",
"defaultSession": "自定义助手",
Expand Down
1 change: 1 addition & 0 deletions locales/zh-TW/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"close": "關閉",
"confirmRemoveSessionItemAlert": "即將刪除此助手,刪除後將無法復原,請確認您的操作",
"copy": "複製",
"copyFail": "複製失敗",
"copySuccess": "複製成功",
"defaultAgent": "預設助手",
"defaultSession": "預設助手",
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@
"@lobehub/tts": "latest",
"@vercel/analytics": "^1",
"ahooks": "^3",
"ai": "^2.2.22",
"antd": "^5.12.7",
"ai": "^2",
"antd": "^5",
"antd-style": "^3",
"brotli-wasm": "^2.0.0",
"brotli-wasm": "^2",
"chroma-js": "^2",
"copy-to-clipboard": "^3",
"dayjs": "^1",
Expand All @@ -104,16 +104,16 @@
"lucide-react": "latest",
"modern-screenshot": "^4",
"nanoid": "^5",
"next": "^14.0.2",
"next": "^14.1",
"nuqs": "^1.15.4",
"openai": "^4.17.3",
"openai": "^4.22",
"polished": "^4",
"posthog-js": "^1",
"query-string": "^8",
"react": "^18",
"react-dom": "^18",
"react-hotkeys-hook": "^4.4.3",
"react-i18next": "^14.0.0",
"react-hotkeys-hook": "^4",
"react-i18next": "^14",
"react-intersection-observer": "^9",
"react-layout-kit": "^1",
"react-lazy-load": "^4",
Expand All @@ -122,9 +122,9 @@
"remark": "^14",
"remark-gfm": "^3",
"remark-html": "^15",
"rtl-detect": "^1.1.2",
"rtl-detect": "^1",
"semver": "^7",
"sharp": "0.33.1",
"sharp": "^0.33.2",
"swr": "^2",
"systemjs": "^6",
"ts-md5": "^1",
Expand All @@ -148,27 +148,27 @@
"@testing-library/jest-dom": "^6",
"@testing-library/react": "^14",
"@types/chroma-js": "^2",
"@types/json-schema": "^7.0.15",
"@types/json-schema": "^7",
"@types/lodash": "^4",
"@types/lodash-es": "^4",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/rtl-detect": "^1.0.3",
"@types/rtl-detect": "^1",
"@types/semver": "^7",
"@types/systemjs": "^6",
"@types/ua-parser-js": "^0.7",
"@types/uuid": "^9",
"@umijs/lint": "^4",
"@vitest/coverage-v8": "^1.1.3",
"@vitest/coverage-v8": "^1",
"commitlint": "^18",
"consola": "^3",
"dpdm": "^3",
"eslint": "^8",
"fake-indexeddb": "^5",
"glob": "^10",
"husky": "^8",
"jsdom": "^23.0.0",
"jsdom": "^23",
"just-diff": "^6",
"lint-staged": "^15",
"lodash": "^4",
Expand All @@ -184,8 +184,8 @@
"typescript": "^5",
"unified": "^11",
"unist-util-visit": "^5",
"vitest": "^1.1.3",
"vitest-canvas-mock": "^0.3.3"
"vitest": "^1",
"vitest-canvas-mock": "^0.3"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion src/app/chat/features/ChatHeader/ShareButton/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useStyles = createStyles(({ css, token, stylish, cx }, withBackgrou
overflow: hidden scroll;
width: 100%;
max-height: 40vh;
max-height: 40dvh;
background: ${token.colorBgLayout};
border: 1px solid ${token.colorBorder};
Expand Down
1 change: 1 addition & 0 deletions src/locales/default/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
close: '关闭',
confirmRemoveSessionItemAlert: '即将删除该助手,删除后该将无法找回,请确认你的操作',
copy: '复制',
copyFail: '复制失败',
copySuccess: '复制成功',
defaultAgent: '自定义助手',
defaultSession: '自定义助手',
Expand Down
117 changes: 117 additions & 0 deletions src/store/global/slices/settings/action.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { act, renderHook } from '@testing-library/react';
import { DeepPartial } from 'utility-types';
import { describe, expect, it, vi } from 'vitest';

import { DEFAULT_AGENT, DEFAULT_SETTINGS } from '@/const/settings';
import { useGlobalStore } from '@/store/global';
import { SettingsTabs } from '@/store/global/initialState';
import { LobeAgentSettings } from '@/types/session';
import { GlobalSettings, OpenAIConfig } from '@/types/settings';

beforeEach(() => {
vi.clearAllMocks();
});

vi.mock('@/utils/uuid', () => ({
nanoid: vi.fn(() => 'unique-id'),
}));

describe('SettingsAction', () => {
describe('importAppSettings', () => {
it('should import app settings', () => {
const { result } = renderHook(() => useGlobalStore());
const newSettings: GlobalSettings = {
...DEFAULT_SETTINGS,
themeMode: 'dark',
};

act(() => {
result.current.importAppSettings(newSettings);
});

expect(result.current.settings).toEqual(newSettings);
});
});

describe('resetSettings', () => {
it('should reset settings to default', () => {
const { result } = renderHook(() => useGlobalStore());

act(() => {
result.current.resetSettings();
});

expect(result.current.settings).toEqual(DEFAULT_SETTINGS);
});
});

describe('setOpenAIConfig', () => {
it('should set OpenAI configuration', () => {
const { result } = renderHook(() => useGlobalStore());
const openAIConfig: Partial<OpenAIConfig> = { OPENAI_API_KEY: 'test' };

act(() => {
result.current.setOpenAIConfig(openAIConfig);
});

expect(result.current.settings.languageModel.openAI.OPENAI_API_KEY).toEqual(
openAIConfig.OPENAI_API_KEY,
);
});
});

describe('setSettings', () => {
it('should set partial settings', () => {
const { result } = renderHook(() => useGlobalStore());
const partialSettings: Partial<GlobalSettings> = { themeMode: 'dark' };

act(() => {
result.current.setSettings(partialSettings);
});

expect(result.current.settings.themeMode).toEqual('dark');
});
});

describe('switchSettingTabs', () => {
it('should switch settings tabs', () => {
const { result } = renderHook(() => useGlobalStore());

act(() => {
result.current.switchSettingTabs(SettingsTabs.Agent);
});

expect(result.current.settingsTab).toEqual(SettingsTabs.Agent);
});
});

describe('switchThemeMode', () => {
it('should switch theme mode', () => {
const { result } = renderHook(() => useGlobalStore());

act(() => {
result.current.switchThemeMode('light');
});

expect(result.current.settings.themeMode).toEqual('light');
});
});

describe('updateDefaultAgent', () => {
it('should update default agent settings', () => {
const { result } = renderHook(() => useGlobalStore());
const updatedAgent: DeepPartial<LobeAgentSettings> = {
meta: { title: 'docs' },
};

act(() => {
result.current.updateDefaultAgent(updatedAgent);
});

expect(result.current.settings.defaultAgent).toEqual({
...DEFAULT_AGENT,
...updatedAgent,
});
});
});
});
2 changes: 1 addition & 1 deletion src/store/session/slices/session/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const createSessionSlice: StateCreator<

// duplicate Session Error
if (!newId) {
message.error('复制失败');
message.error(t('copyFail', { ns: 'common' }));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default ({ prefixCls }: { prefixCls: string }) => css`
position: relative;
overscroll-behavior: none;
height: 100% !important;
min-height: 100% !important;
max-height: 100dvh !important;
::-webkit-scrollbar {
display: none;
Expand Down

0 comments on commit 82fc899

Please sign in to comment.