Skip to content

Commit

Permalink
Merge branch 'ztjhz:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzt committed Apr 17, 2023
2 parents 1fc2dee + 627e1cc commit 948143c
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 5 deletions.
4 changes: 3 additions & 1 deletion electron/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ const createServer = () => {
const server = http.createServer((request, response) => {
// Get the file path from the URL
let filePath =
request.url === '/' ? '../dist/index.html' : `../dist/${request.url}`;
request.url === '/'
? `${path.join(__dirname, '../dist/index.html')}`
: `${path.join(__dirname, `../dist/${request.url}`)}`;

// Get the file extension from the filePath
let extname = path.extname(filePath);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "better-chatgpt",
"private": true,
"version": "1.0.2",
"version": "1.0.3",
"type": "module",
"homepage": "./",
"main": "electron/index.cjs",
Expand Down
1 change: 1 addition & 0 deletions public/locales/da/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Billede",
"autoTitle": "Auto generer titel",
"advancedMode": "Avanceret tilstand",
"inlineLatex": "Indlejret LaTeX",
"prompt": "Opgave",
"promptLibrary": "Opgavebibliotek",
"name": "Navn",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en-US/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Image",
"autoTitle": "Auto generate title",
"advancedMode": "Advanced mode",
"inlineLatex": "Inline Latex",
"prompt": "Prompt",
"promptLibrary": "Prompt Library",
"name": "Name",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Image",
"autoTitle": "Auto generate title",
"advancedMode": "Advanced mode",
"inlineLatex": "Inline Latex",
"prompt": "Prompt",
"promptLibrary": "Prompt Library",
"name": "Name",
Expand Down
1 change: 1 addition & 0 deletions public/locales/es/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Imagen",
"autoTitle": "Generar automáticamente el título de la conversación.",
"advancedMode": "Modo avanzado",
"inlineLatex": "Latex en línea",
"prompt": "Prompt",
"promptLibrary": "Librería de Prompts",
"name": "Nombre",
Expand Down
1 change: 1 addition & 0 deletions public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Image",
"autoTitle": "Générer le titre automatiquement",
"advancedMode": "Mode avancé",
"inlineLatex": "Latex en ligne",
"prompt": "Incitation",
"promptLibrary": "Bibliothèque de prompt",
"name": "Nom",
Expand Down
1 change: 1 addition & 0 deletions public/locales/it/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Immagine",
"autoTitle": "Genera automaticamente il titolo",
"advancedMode": "Modalità avanzata",
"inlineLatex": "Latex in linea",
"prompt": "Prompt",
"promptLibrary": "Libreria Prompt",
"name": "Nome",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "画像",
"autoTitle": "タイトルを自動生成",
"advancedMode": "上級モード",
"inlineLatex": "インライン LaTeX",
"prompt": "プロンプト",
"promptLibrary": "プロンプトライブラリ",
"name": "名前",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ms/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Imej",
"autoTitle": "Jana tajuk secara automatik",
"advancedMode": "Mod lanjutan",
"inlineLatex": "Latex Sebaris",
"prompt": "Arahan",
"promptLibrary": "Pustaka Arahan",
"name": "Nama",
Expand Down
1 change: 1 addition & 0 deletions public/locales/nb/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Bilde",
"autoTitle": "Auto generer tittel",
"advancedMode": "Avansert modus",
"inlineLatex": "Inline Latex",
"prompt": "Oppgave",
"promptLibrary": "Oppgavebibliotek",
"name": "Navn",
Expand Down
1 change: 1 addition & 0 deletions public/locales/sv/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "Bild",
"autoTitle": "Auto generera titel",
"advancedMode": "Avancerat läge",
"inlineLatex": "Inline Latex",
"prompt": "Uppmaning",
"promptLibrary": "Uppmaningsbibliotek",
"name": "Namn",
Expand Down
1 change: 1 addition & 0 deletions public/locales/zh-CN/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "图片",
"autoTitle": "自动生成标题",
"advancedMode": "高级模式",
"inlineLatex": "行内 Latex",
"prompt": "提示词",
"promptLibrary": "提示词资料库",
"name": "名称",
Expand Down
1 change: 1 addition & 0 deletions public/locales/zh-HK/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "圖片",
"autoTitle": "自動生成標題",
"advancedMode": "高級模式",
"inlineLatex": "行內 Latex",
"prompt": "Prompt",
"promptLibrary": "Prompt 資料庫",
"name": "",
Expand Down
1 change: 1 addition & 0 deletions public/locales/zh-TW/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"image": "圖片",
"autoTitle": "自動生成標題",
"advancedMode": "高級模式",
"inlineLatex": "行內 Latex",
"prompt": "提示詞",
"promptLibrary": "提示詞資料庫",
"name": "名稱",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Chat/ChatContent/Message/MessageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const ContentView = React.memo(
const lastMessageIndex = useStore((state) =>
state.chats ? state.chats[state.currentChatIndex].messages.length - 1 : 0
);
const inlineLatex = useStore((state) => state.inlineLatex);

const handleDelete = () => {
const updatedChats: ChatInterface[] = JSON.parse(
Expand Down Expand Up @@ -139,7 +140,7 @@ const ContentView = React.memo(
<ReactMarkdown
remarkPlugins={[
remarkGfm,
[remarkMath, { singleDollarTextMath: false }],
[remarkMath, { singleDollarTextMath: inlineLatex }],
]}
rehypePlugins={[
rehypeKatex,
Expand Down
28 changes: 28 additions & 0 deletions src/components/SettingsMenu/InlineLatexToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import useStore from '@store/store';
import Toggle from '@components/Toggle';

const InlineLatexToggle = () => {
const { t } = useTranslation();

const setInlineLatex = useStore((state) => state.setInlineLatex);

const [isChecked, setIsChecked] = useState<boolean>(
useStore.getState().inlineLatex
);

useEffect(() => {
setInlineLatex(isChecked);
}, [isChecked]);

return (
<Toggle
label={t('inlineLatex') as string}
isChecked={isChecked}
setIsChecked={setIsChecked}
/>
);
};

export default InlineLatexToggle;
4 changes: 3 additions & 1 deletion src/components/SettingsMenu/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import ThemeSwitcher from '@components/Menu/MenuOptions/ThemeSwitcher';
import LanguageSelector from '@components/LanguageSelector';
import AutoTitleToggle from './AutoTitleToggle';
import AdvancedModeToggle from './AdvencedModeToggle';
import InlineLatexToggle from './InlineLatexToggle';

import PromptLibraryMenu from '@components/PromptLibraryMenu';
import ChatConfigMenu from '@components/ChatConfigMenu';
import EnterToSubmitToggle from './EnterToSubmitToggle';


const SettingsMenu = () => {
const { t } = useTranslation();

Expand Down Expand Up @@ -45,6 +46,7 @@ const SettingsMenu = () => {
<div className='flex flex-col gap-3'>
<AutoTitleToggle />
<EnterToSubmitToggle />
<InlineLatexToggle />
<AdvancedModeToggle />
</div>
<PromptLibraryMenu />
Expand Down
9 changes: 9 additions & 0 deletions src/store/config-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ConfigSlice {
defaultSystemMessage: string;
hideSideMenu: boolean;
enterToSubmit: boolean;
inlineLatex: boolean;
setOpenConfig: (openConfig: boolean) => void;
setTheme: (theme: Theme) => void;
setAutoTitle: (autoTitle: boolean) => void;
Expand All @@ -22,6 +23,7 @@ export interface ConfigSlice {
setHideMenuOptions: (hideMenuOptions: boolean) => void;
setHideSideMenu: (hideSideMenu: boolean) => void;
setEnterToSubmit: (enterToSubmit: boolean) => void;
setInlineLatex: (inlineLatex: boolean) => void;
}

export const createConfigSlice: StoreSlice<ConfigSlice> = (set, get) => ({
Expand All @@ -34,6 +36,7 @@ export const createConfigSlice: StoreSlice<ConfigSlice> = (set, get) => ({
advancedMode: true,
defaultChatConfig: _defaultChatConfig,
defaultSystemMessage: _defaultSystemMessage,
inlineLatex: false,
setOpenConfig: (openConfig: boolean) => {
set((prev: ConfigSlice) => ({
...prev,
Expand Down Expand Up @@ -88,4 +91,10 @@ export const createConfigSlice: StoreSlice<ConfigSlice> = (set, get) => ({
enterToSubmit: enterToSubmit,
}));
},
setInlineLatex: (inlineLatex: boolean) => {
set((prev: ConfigSlice) => ({
...prev,
inlineLatex: inlineLatex,
}));
},
});
1 change: 1 addition & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const createPartializedState = (state: StoreState) => ({
hideSideMenu: state.hideSideMenu,
folders: state.folders,
enterToSubmit: state.enterToSubmit,
inlineLatex: state.inlineLatex,
});

const useStore = create<StoreState>()(
Expand Down
9 changes: 8 additions & 1 deletion tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ module.exports = {
'Segoe UI Symbol',
'Noto Color Emoji',
],
mono: ['Söhne Mono', 'Monaco', 'Andale Mono', 'Ubuntu Mono', 'monospace'],
mono: [
'Söhne Mono',
'Monaco',
'Andale Mono',
'Ubuntu Mono',
'Consolas',
'monospace',
],
},
extend: {
typography: {
Expand Down

0 comments on commit 948143c

Please sign in to comment.