ChatGPT Logo

This commit is contained in:
Hao Jia 2024-05-16 15:03:14 +08:00
parent 01c9dbc1fd
commit bfdb47a7ed
8 changed files with 608 additions and 673 deletions

View File

@ -50,33 +50,33 @@ export function AuthPage() {
); );
}} }}
/> />
{!accessStore.hideUserApiKey ? ( {/*{!accessStore.hideUserApiKey ? (*/}
<> {/* <>*/}
<div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div> {/* <div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div>*/}
<input {/* <input*/}
className={styles["auth-input"]} {/* className={styles["auth-input"]}*/}
type="password" {/* type="password"*/}
placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder} {/* placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}*/}
value={accessStore.openaiApiKey} {/* value={accessStore.openaiApiKey}*/}
onChange={(e) => { {/* onChange={(e) => {*/}
accessStore.update( {/* accessStore.update(*/}
(access) => (access.openaiApiKey = e.currentTarget.value), {/* (access) => (access.openaiApiKey = e.currentTarget.value),*/}
); {/* );*/}
}} {/* }}*/}
/> {/* />*/}
<input {/* <input*/}
className={styles["auth-input"]} {/* className={styles["auth-input"]}*/}
type="password" {/* type="password"*/}
placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder} {/* placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder}*/}
value={accessStore.googleApiKey} {/* value={accessStore.googleApiKey}*/}
onChange={(e) => { {/* onChange={(e) => {*/}
accessStore.update( {/* accessStore.update(*/}
(access) => (access.googleApiKey = e.currentTarget.value), {/* (access) => (access.googleApiKey = e.currentTarget.value),*/}
); {/* );*/}
}} {/* }}*/}
/> {/* />*/}
</> {/* </>*/}
) : null} {/*) : null}*/}
<div className={styles["auth-actions"]}> <div className={styles["auth-actions"]}>
<IconButton <IconButton

View File

@ -490,79 +490,79 @@ export function ChatActions(props: {
return ( return (
<div className={styles["chat-input-actions"]}> <div className={styles["chat-input-actions"]}>
{couldStop && ( {/*{couldStop && (*/}
<ChatAction {/* <ChatAction*/}
onClick={stopAll} {/* onClick={stopAll}*/}
text={Locale.Chat.InputActions.Stop} {/* text={Locale.Chat.InputActions.Stop}*/}
icon={<StopIcon />} {/* icon={<StopIcon />}*/}
/> {/* />*/}
)} {/*)}*/}
{!props.hitBottom && ( {/*{!props.hitBottom && (*/}
<ChatAction {/* <ChatAction*/}
onClick={props.scrollToBottom} {/* onClick={props.scrollToBottom}*/}
text={Locale.Chat.InputActions.ToBottom} {/* text={Locale.Chat.InputActions.ToBottom}*/}
icon={<BottomIcon />} {/* icon={<BottomIcon />}*/}
/> {/* />*/}
)} {/*)}*/}
{props.hitBottom && ( {/*{props.hitBottom && (*/}
<ChatAction {/* <ChatAction*/}
onClick={props.showPromptModal} {/* onClick={props.showPromptModal}*/}
text={Locale.Chat.InputActions.Settings} {/* text={Locale.Chat.InputActions.Settings}*/}
icon={<SettingsIcon />} {/* icon={<SettingsIcon />}*/}
/> {/* />*/}
)} {/*)}*/}
{showUploadImage && ( {/*{showUploadImage && (*/}
<ChatAction {/* <ChatAction*/}
onClick={props.uploadImage} {/* onClick={props.uploadImage}*/}
text={Locale.Chat.InputActions.UploadImage} {/* text={Locale.Chat.InputActions.UploadImage}*/}
icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />} {/* icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />}*/}
/> {/* />*/}
)} {/*)}*/}
<ChatAction {/*<ChatAction*/}
onClick={nextTheme} {/* onClick={nextTheme}*/}
text={Locale.Chat.InputActions.Theme[theme]} {/* text={Locale.Chat.InputActions.Theme[theme]}*/}
icon={ {/* icon={*/}
<> {/* <>*/}
{theme === Theme.Auto ? ( {/* {theme === Theme.Auto ? (*/}
<AutoIcon /> {/* <AutoIcon />*/}
) : theme === Theme.Light ? ( {/* ) : theme === Theme.Light ? (*/}
<LightIcon /> {/* <LightIcon />*/}
) : theme === Theme.Dark ? ( {/* ) : theme === Theme.Dark ? (*/}
<DarkIcon /> {/* <DarkIcon />*/}
) : null} {/* ) : null}*/}
</> {/* </>*/}
} {/* }*/}
/> {/*/>*/}
<ChatAction {/*<ChatAction*/}
onClick={props.showPromptHints} {/* onClick={props.showPromptHints}*/}
text={Locale.Chat.InputActions.Prompt} {/* text={Locale.Chat.InputActions.Prompt}*/}
icon={<PromptIcon />} {/* icon={<PromptIcon />}*/}
/> {/*/>*/}
<ChatAction {/*<ChatAction*/}
onClick={() => { {/* onClick={() => {*/}
navigate(Path.Masks); {/* navigate(Path.Masks);*/}
}} {/* }}*/}
text={Locale.Chat.InputActions.Masks} {/* text={Locale.Chat.InputActions.Masks}*/}
icon={<MaskIcon />} {/* icon={<MaskIcon />}*/}
/> {/*/>*/}
<ChatAction {/*<ChatAction*/}
text={Locale.Chat.InputActions.Clear} {/* text={Locale.Chat.InputActions.Clear}*/}
icon={<BreakIcon />} {/* icon={<BreakIcon />}*/}
onClick={() => { {/* onClick={() => {*/}
chatStore.updateCurrentSession((session) => { {/* chatStore.updateCurrentSession((session) => {*/}
if (session.clearContextIndex === session.messages.length) { {/* if (session.clearContextIndex === session.messages.length) {*/}
session.clearContextIndex = undefined; {/* session.clearContextIndex = undefined;*/}
} else { {/* } else {*/}
session.clearContextIndex = session.messages.length; {/* session.clearContextIndex = session.messages.length;*/}
session.memoryPrompt = ""; // will clear memory {/* session.memoryPrompt = ""; // will clear memory*/}
} {/* }*/}
}); {/* });*/}
}} {/* }}*/}
/> {/*/>*/}
<ChatAction <ChatAction
onClick={() => setShowModelSelector(true)} onClick={() => setShowModelSelector(true)}
@ -1088,7 +1088,6 @@ function _Chat() {
if (payload.url) { if (payload.url) {
accessStore.update((access) => (access.openaiUrl = payload.url!)); accessStore.update((access) => (access.openaiUrl = payload.url!));
} }
accessStore.update((access) => (access.useCustomConfig = true));
}); });
} }
} catch { } catch {
@ -1233,25 +1232,25 @@ function _Chat() {
</div> </div>
</div> </div>
<div className="window-actions"> <div className="window-actions">
{!isMobileScreen && ( {/*{!isMobileScreen && (*/}
<div className="window-action-button"> {/* <div className="window-action-button">*/}
<IconButton {/* <IconButton*/}
icon={<RenameIcon />} {/* icon={<RenameIcon />}*/}
bordered {/* bordered*/}
onClick={() => setIsEditingMessage(true)} {/* onClick={() => setIsEditingMessage(true)}*/}
/> {/* />*/}
</div> {/* </div>*/}
)} {/*)}*/}
<div className="window-action-button"> {/*<div className="window-action-button">*/}
<IconButton {/* <IconButton*/}
icon={<ExportIcon />} {/* icon={<ExportIcon />}*/}
bordered {/* bordered*/}
title={Locale.Chat.Actions.Export} {/* title={Locale.Chat.Actions.Export}*/}
onClick={() => { {/* onClick={() => {*/}
setShowExport(true); {/* setShowExport(true);*/}
}} {/* }}*/}
/> {/* />*/}
</div> {/*</div>*/}
{showMaxIcon && ( {showMaxIcon && (
<div className="window-action-button"> <div className="window-action-button">
<IconButton <IconButton

View File

@ -703,80 +703,80 @@ export function Settings() {
</Popover> </Popover>
</ListItem> </ListItem>
<ListItem {/*<ListItem*/}
title={Locale.Settings.Update.Version(currentVersion ?? "unknown")} {/* title={Locale.Settings.Update.Version(currentVersion ?? "unknown")}*/}
subTitle={ {/* subTitle={*/}
checkingUpdate {/* checkingUpdate*/}
? Locale.Settings.Update.IsChecking {/* ? Locale.Settings.Update.IsChecking*/}
: hasNewVersion {/* : hasNewVersion*/}
? Locale.Settings.Update.FoundUpdate(remoteId ?? "ERROR") {/* ? Locale.Settings.Update.FoundUpdate(remoteId ?? "ERROR")*/}
: Locale.Settings.Update.IsLatest {/* : Locale.Settings.Update.IsLatest*/}
} {/* }*/}
> {/*>*/}
{checkingUpdate ? ( {/* {checkingUpdate ? (*/}
<LoadingIcon /> {/* <LoadingIcon />*/}
) : hasNewVersion ? ( {/* ) : hasNewVersion ? (*/}
<Link href={updateUrl} target="_blank" className="link"> {/* <Link href={updateUrl} target="_blank" className="link">*/}
{Locale.Settings.Update.GoToUpdate} {/* {Locale.Settings.Update.GoToUpdate}*/}
</Link> {/* </Link>*/}
) : ( {/* ) : (*/}
<IconButton {/* <IconButton*/}
icon={<ResetIcon></ResetIcon>} {/* icon={<ResetIcon></ResetIcon>}*/}
text={Locale.Settings.Update.CheckUpdate} {/* text={Locale.Settings.Update.CheckUpdate}*/}
onClick={() => checkUpdate(true)} {/* onClick={() => checkUpdate(true)}*/}
/> {/* />*/}
)} {/* )}*/}
</ListItem> {/*</ListItem>*/}
<ListItem title={Locale.Settings.SendKey}> {/*<ListItem title={Locale.Settings.SendKey}>*/}
<Select {/* <Select*/}
value={config.submitKey} {/* value={config.submitKey}*/}
onChange={(e) => { {/* onChange={(e) => {*/}
updateConfig( {/* updateConfig(*/}
(config) => {/* (config) =>*/}
(config.submitKey = e.target.value as any as SubmitKey), {/* (config.submitKey = e.target.value as any as SubmitKey),*/}
); {/* );*/}
}} {/* }}*/}
> {/* >*/}
{Object.values(SubmitKey).map((v) => ( {/* {Object.values(SubmitKey).map((v) => (*/}
<option value={v} key={v}> {/* <option value={v} key={v}>*/}
{v} {/* {v}*/}
</option> {/* </option>*/}
))} {/* ))}*/}
</Select> {/* </Select>*/}
</ListItem> {/*</ListItem>*/}
<ListItem title={Locale.Settings.Theme}> {/*<ListItem title={Locale.Settings.Theme}>*/}
<Select {/* <Select*/}
value={config.theme} {/* value={config.theme}*/}
onChange={(e) => { {/* onChange={(e) => {*/}
updateConfig( {/* updateConfig(*/}
(config) => (config.theme = e.target.value as any as Theme), {/* (config) => (config.theme = e.target.value as any as Theme),*/}
); {/* );*/}
}} {/* }}*/}
> {/* >*/}
{Object.values(Theme).map((v) => ( {/* {Object.values(Theme).map((v) => (*/}
<option value={v} key={v}> {/* <option value={v} key={v}>*/}
{v} {/* {v}*/}
</option> {/* </option>*/}
))} {/* ))}*/}
</Select> {/* </Select>*/}
</ListItem> {/*</ListItem>*/}
<ListItem title={Locale.Settings.Lang.Name}> {/*<ListItem title={Locale.Settings.Lang.Name}>*/}
<Select {/* <Select*/}
value={getLang()} {/* value={getLang()}*/}
onChange={(e) => { {/* onChange={(e) => {*/}
changeLang(e.target.value as any); {/* changeLang(e.target.value as any);*/}
}} {/* }}*/}
> {/* >*/}
{AllLangs.map((lang) => ( {/* {AllLangs.map((lang) => (*/}
<option value={lang} key={lang}> {/* <option value={lang} key={lang}>*/}
{ALL_LANG_OPTIONS[lang]} {/* {ALL_LANG_OPTIONS[lang]}*/}
</option> {/* </option>*/}
))} {/* ))}*/}
</Select> {/* </Select>*/}
</ListItem> {/*</ListItem>*/}
<ListItem <ListItem
title={Locale.Settings.FontSize.Title} title={Locale.Settings.FontSize.Title}
@ -797,454 +797,389 @@ export function Settings() {
></InputRange> ></InputRange>
</ListItem> </ListItem>
<ListItem {/*<ListItem*/}
title={Locale.Settings.AutoGenerateTitle.Title} {/* title={Locale.Settings.AutoGenerateTitle.Title}*/}
subTitle={Locale.Settings.AutoGenerateTitle.SubTitle} {/* subTitle={Locale.Settings.AutoGenerateTitle.SubTitle}*/}
> {/*>*/}
<input {/* <input*/}
type="checkbox" {/* type="checkbox"*/}
checked={config.enableAutoGenerateTitle} {/* checked={config.enableAutoGenerateTitle}*/}
onChange={(e) => {/* onChange={(e) =>*/}
updateConfig( {/* updateConfig(*/}
(config) => {/* (config) =>*/}
(config.enableAutoGenerateTitle = e.currentTarget.checked), {/* (config.enableAutoGenerateTitle = e.currentTarget.checked),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/*</ListItem>*/}
<ListItem {/*<ListItem*/}
title={Locale.Settings.SendPreviewBubble.Title} {/* title={Locale.Settings.SendPreviewBubble.Title}*/}
subTitle={Locale.Settings.SendPreviewBubble.SubTitle} {/* subTitle={Locale.Settings.SendPreviewBubble.SubTitle}*/}
> {/*>*/}
<input {/* <input*/}
type="checkbox" {/* type="checkbox"*/}
checked={config.sendPreviewBubble} {/* checked={config.sendPreviewBubble}*/}
onChange={(e) => {/* onChange={(e) =>*/}
updateConfig( {/* updateConfig(*/}
(config) => {/* (config) =>*/}
(config.sendPreviewBubble = e.currentTarget.checked), {/* (config.sendPreviewBubble = e.currentTarget.checked),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/*</ListItem>*/}
</List> </List>
<SyncItems /> {/*<SyncItems />*/}
<List> {/*<List>*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Mask.Splash.Title} {/* title={Locale.Settings.Mask.Splash.Title}*/}
subTitle={Locale.Settings.Mask.Splash.SubTitle} {/* subTitle={Locale.Settings.Mask.Splash.SubTitle}*/}
> {/* >*/}
<input {/* <input*/}
type="checkbox" {/* type="checkbox"*/}
checked={!config.dontShowMaskSplashScreen} {/* checked={!config.dontShowMaskSplashScreen}*/}
onChange={(e) => {/* onChange={(e) =>*/}
updateConfig( {/* updateConfig(*/}
(config) => {/* (config) =>*/}
(config.dontShowMaskSplashScreen = {/* (config.dontShowMaskSplashScreen =*/}
!e.currentTarget.checked), {/* !e.currentTarget.checked),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/* </ListItem>*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Mask.Builtin.Title} {/* title={Locale.Settings.Mask.Builtin.Title}*/}
subTitle={Locale.Settings.Mask.Builtin.SubTitle} {/* subTitle={Locale.Settings.Mask.Builtin.SubTitle}*/}
> {/* >*/}
<input {/* <input*/}
type="checkbox" {/* type="checkbox"*/}
checked={config.hideBuiltinMasks} {/* checked={config.hideBuiltinMasks}*/}
onChange={(e) => {/* onChange={(e) =>*/}
updateConfig( {/* updateConfig(*/}
(config) => {/* (config) =>*/}
(config.hideBuiltinMasks = e.currentTarget.checked), {/* (config.hideBuiltinMasks = e.currentTarget.checked),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/* </ListItem>*/}
</List> {/*</List>*/}
<List> {/*<List>*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Prompt.Disable.Title} {/* title={Locale.Settings.Prompt.Disable.Title}*/}
subTitle={Locale.Settings.Prompt.Disable.SubTitle} {/* subTitle={Locale.Settings.Prompt.Disable.SubTitle}*/}
> {/* >*/}
<input {/* <input*/}
type="checkbox" {/* type="checkbox"*/}
checked={config.disablePromptHint} {/* checked={config.disablePromptHint}*/}
onChange={(e) => {/* onChange={(e) =>*/}
updateConfig( {/* updateConfig(*/}
(config) => {/* (config) =>*/}
(config.disablePromptHint = e.currentTarget.checked), {/* (config.disablePromptHint = e.currentTarget.checked),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/* </ListItem>*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Prompt.List} {/* title={Locale.Settings.Prompt.List}*/}
subTitle={Locale.Settings.Prompt.ListCount( {/* subTitle={Locale.Settings.Prompt.ListCount(*/}
builtinCount, {/* builtinCount,*/}
customCount, {/* customCount,*/}
)} {/* )}*/}
> {/* >*/}
<IconButton {/* <IconButton*/}
icon={<EditIcon />} {/* icon={<EditIcon />}*/}
text={Locale.Settings.Prompt.Edit} {/* text={Locale.Settings.Prompt.Edit}*/}
onClick={() => setShowPromptModal(true)} {/* onClick={() => setShowPromptModal(true)}*/}
/> {/* />*/}
</ListItem> {/* </ListItem>*/}
</List> {/*</List>*/}
<List id={SlotID.CustomModel}> {/*<List id={SlotID.CustomModel}>*/}
{showAccessCode && ( {/* {showAccessCode && (*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Access.AccessCode.Title} {/* title={Locale.Settings.Access.AccessCode.Title}*/}
subTitle={Locale.Settings.Access.AccessCode.SubTitle} {/* subTitle={Locale.Settings.Access.AccessCode.SubTitle}*/}
> {/* >*/}
<PasswordInput {/* <PasswordInput*/}
value={accessStore.accessCode} {/* value={accessStore.accessCode}*/}
type="text" {/* type="text"*/}
placeholder={Locale.Settings.Access.AccessCode.Placeholder} {/* placeholder={Locale.Settings.Access.AccessCode.Placeholder}*/}
onChange={(e) => { {/* onChange={(e) => {*/}
accessStore.update( {/* accessStore.update(*/}
(access) => (access.accessCode = e.currentTarget.value), {/* (access) => (access.accessCode = e.currentTarget.value),*/}
); {/* );*/}
}} {/* }}*/}
/> {/* />*/}
</ListItem> {/* </ListItem>*/}
)} {/* )}*/}
{!accessStore.hideUserApiKey && ( {/* {!accessStore.hideUserApiKey && (*/}
<> {/* <>*/}
{ {/* {*/}
// Conditionally render the following ListItem based on clientConfig.isApp {/* // Conditionally render the following ListItem based on clientConfig.isApp*/}
!clientConfig?.isApp && ( // only show if isApp is false {/* !clientConfig?.isApp && ( // only show if isApp is false*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Access.CustomEndpoint.Title} {/* title={Locale.Settings.Access.CustomEndpoint.Title}*/}
subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle} {/* subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}*/}
> {/* >*/}
<input {/* <input*/}
type="checkbox" {/* type="checkbox"*/}
checked={accessStore.useCustomConfig} {/* checked={accessStore.useCustomConfig}*/}
onChange={(e) => {/* onChange={(e) =>*/}
accessStore.update( {/* accessStore.update(*/}
(access) => {/* (access) =>*/}
(access.useCustomConfig = e.currentTarget.checked), {/* (access.useCustomConfig = e.currentTarget.checked),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/* </ListItem>*/}
) {/* )*/}
} {/* }*/}
{accessStore.useCustomConfig && ( {/* {accessStore.useCustomConfig && (*/}
<> {/* <>*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Access.Provider.Title} {/* title={Locale.Settings.Access.Provider.Title}*/}
subTitle={Locale.Settings.Access.Provider.SubTitle} {/* subTitle={Locale.Settings.Access.Provider.SubTitle}*/}
> {/* >*/}
<Select {/* <Select*/}
value={accessStore.provider} {/* value={accessStore.provider}*/}
onChange={(e) => { {/* onChange={(e) => {*/}
accessStore.update( {/* accessStore.update(*/}
(access) => {/* (access) =>*/}
(access.provider = e.target {/* (access.provider = e.target*/}
.value as ServiceProvider), {/* .value as ServiceProvider),*/}
); {/* );*/}
}} {/* }}*/}
> {/* >*/}
{Object.entries(ServiceProvider).map(([k, v]) => ( {/* {Object.entries(ServiceProvider).map(([k, v]) => (*/}
<option value={v} key={k}> {/* <option value={v} key={k}>*/}
{k} {/* {k}*/}
</option> {/* </option>*/}
))} {/* ))}*/}
</Select> {/* </Select>*/}
</ListItem> {/* </ListItem>*/}
{accessStore.provider === ServiceProvider.OpenAI && ( {/* {accessStore.provider === "OpenAI" ? (*/}
<> {/* <>*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Access.OpenAI.Endpoint.Title} {/* title={Locale.Settings.Access.OpenAI.Endpoint.Title}*/}
subTitle={ {/* subTitle={*/}
Locale.Settings.Access.OpenAI.Endpoint.SubTitle {/* Locale.Settings.Access.OpenAI.Endpoint.SubTitle*/}
} {/* }*/}
> {/* >*/}
<input {/* <input*/}
type="text" {/* type="text"*/}
value={accessStore.openaiUrl} {/* value={accessStore.openaiUrl}*/}
placeholder={OPENAI_BASE_URL} {/* placeholder={OPENAI_BASE_URL}*/}
onChange={(e) => {/* onChange={(e) =>*/}
accessStore.update( {/* accessStore.update(*/}
(access) => {/* (access) =>*/}
(access.openaiUrl = e.currentTarget.value), {/* (access.openaiUrl = e.currentTarget.value),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/* </ListItem>*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Access.OpenAI.ApiKey.Title} {/* title={Locale.Settings.Access.OpenAI.ApiKey.Title}*/}
subTitle={Locale.Settings.Access.OpenAI.ApiKey.SubTitle} {/* subTitle={Locale.Settings.Access.OpenAI.ApiKey.SubTitle}*/}
> {/* >*/}
<PasswordInput {/* <PasswordInput*/}
value={accessStore.openaiApiKey} {/* value={accessStore.openaiApiKey}*/}
type="text" {/* type="text"*/}
placeholder={ {/* placeholder={*/}
Locale.Settings.Access.OpenAI.ApiKey.Placeholder {/* Locale.Settings.Access.OpenAI.ApiKey.Placeholder*/}
} {/* }*/}
onChange={(e) => { {/* onChange={(e) => {*/}
accessStore.update( {/* accessStore.update(*/}
(access) => {/* (access) =>*/}
(access.openaiApiKey = e.currentTarget.value), {/* (access.openaiApiKey = e.currentTarget.value),*/}
); {/* );*/}
}} {/* }}*/}
/> {/* />*/}
</ListItem> {/* </ListItem>*/}
</> {/* </>*/}
)} {/* ) : accessStore.provider === "Azure" ? (*/}
{accessStore.provider === ServiceProvider.Azure && ( {/* <>*/}
<> {/* <ListItem*/}
<ListItem {/* title={Locale.Settings.Access.Azure.Endpoint.Title}*/}
title={Locale.Settings.Access.Azure.Endpoint.Title} {/* subTitle={*/}
subTitle={ {/* Locale.Settings.Access.Azure.Endpoint.SubTitle +*/}
Locale.Settings.Access.Azure.Endpoint.SubTitle + {/* Azure.ExampleEndpoint*/}
Azure.ExampleEndpoint {/* }*/}
} {/* >*/}
> {/* <input*/}
<input {/* type="text"*/}
type="text" {/* value={accessStore.azureUrl}*/}
value={accessStore.azureUrl} {/* placeholder={Azure.ExampleEndpoint}*/}
placeholder={Azure.ExampleEndpoint} {/* onChange={(e) =>*/}
onChange={(e) => {/* accessStore.update(*/}
accessStore.update( {/* (access) =>*/}
(access) => {/* (access.azureUrl = e.currentTarget.value),*/}
(access.azureUrl = e.currentTarget.value), {/* )*/}
) {/* }*/}
} {/* ></input>*/}
></input> {/* </ListItem>*/}
</ListItem> {/* <ListItem*/}
<ListItem {/* title={Locale.Settings.Access.Azure.ApiKey.Title}*/}
title={Locale.Settings.Access.Azure.ApiKey.Title} {/* subTitle={Locale.Settings.Access.Azure.ApiKey.SubTitle}*/}
subTitle={Locale.Settings.Access.Azure.ApiKey.SubTitle} {/* >*/}
> {/* <PasswordInput*/}
<PasswordInput {/* value={accessStore.azureApiKey}*/}
value={accessStore.azureApiKey} {/* type="text"*/}
type="text" {/* placeholder={*/}
placeholder={ {/* Locale.Settings.Access.Azure.ApiKey.Placeholder*/}
Locale.Settings.Access.Azure.ApiKey.Placeholder {/* }*/}
} {/* onChange={(e) => {*/}
onChange={(e) => { {/* accessStore.update(*/}
accessStore.update( {/* (access) =>*/}
(access) => {/* (access.azureApiKey = e.currentTarget.value),*/}
(access.azureApiKey = e.currentTarget.value), {/* );*/}
); {/* }}*/}
}} {/* />*/}
/> {/* </ListItem>*/}
</ListItem> {/* <ListItem*/}
<ListItem {/* title={Locale.Settings.Access.Azure.ApiVerion.Title}*/}
title={Locale.Settings.Access.Azure.ApiVerion.Title} {/* subTitle={*/}
subTitle={ {/* Locale.Settings.Access.Azure.ApiVerion.SubTitle*/}
Locale.Settings.Access.Azure.ApiVerion.SubTitle {/* }*/}
} {/* >*/}
> {/* <input*/}
<input {/* type="text"*/}
type="text" {/* value={accessStore.azureApiVersion}*/}
value={accessStore.azureApiVersion} {/* placeholder="2023-08-01-preview"*/}
placeholder="2023-08-01-preview" {/* onChange={(e) =>*/}
onChange={(e) => {/* accessStore.update(*/}
accessStore.update( {/* (access) =>*/}
(access) => {/* (access.azureApiVersion =*/}
(access.azureApiVersion = {/* e.currentTarget.value),*/}
e.currentTarget.value), {/* )*/}
) {/* }*/}
} {/* ></input>*/}
></input> {/* </ListItem>*/}
</ListItem> {/* </>*/}
</> {/* ) : accessStore.provider === "Google" ? (*/}
)} {/* <>*/}
{accessStore.provider === ServiceProvider.Google && ( {/* <ListItem*/}
<> {/* title={Locale.Settings.Access.Google.Endpoint.Title}*/}
<ListItem {/* subTitle={*/}
title={Locale.Settings.Access.Google.Endpoint.Title} {/* Locale.Settings.Access.Google.Endpoint.SubTitle +*/}
subTitle={ {/* Google.ExampleEndpoint*/}
Locale.Settings.Access.Google.Endpoint.SubTitle + {/* }*/}
Google.ExampleEndpoint {/* >*/}
} {/* <input*/}
> {/* type="text"*/}
<input {/* value={accessStore.googleUrl}*/}
type="text" {/* placeholder={Google.ExampleEndpoint}*/}
value={accessStore.googleUrl} {/* onChange={(e) =>*/}
placeholder={Google.ExampleEndpoint} {/* accessStore.update(*/}
onChange={(e) => {/* (access) =>*/}
accessStore.update( {/* (access.googleUrl = e.currentTarget.value),*/}
(access) => {/* )*/}
(access.googleUrl = e.currentTarget.value), {/* }*/}
) {/* ></input>*/}
} {/* </ListItem>*/}
></input> {/* <ListItem*/}
</ListItem> {/* title={Locale.Settings.Access.Google.ApiKey.Title}*/}
<ListItem {/* subTitle={Locale.Settings.Access.Google.ApiKey.SubTitle}*/}
title={Locale.Settings.Access.Google.ApiKey.Title} {/* >*/}
subTitle={Locale.Settings.Access.Google.ApiKey.SubTitle} {/* <PasswordInput*/}
> {/* value={accessStore.googleApiKey}*/}
<PasswordInput {/* type="text"*/}
value={accessStore.googleApiKey} {/* placeholder={*/}
type="text" {/* Locale.Settings.Access.Google.ApiKey.Placeholder*/}
placeholder={ {/* }*/}
Locale.Settings.Access.Google.ApiKey.Placeholder {/* onChange={(e) => {*/}
} {/* accessStore.update(*/}
onChange={(e) => { {/* (access) =>*/}
accessStore.update( {/* (access.googleApiKey = e.currentTarget.value),*/}
(access) => {/* );*/}
(access.googleApiKey = e.currentTarget.value), {/* }}*/}
); {/* />*/}
}} {/* </ListItem>*/}
/> {/* <ListItem*/}
</ListItem> {/* title={Locale.Settings.Access.Google.ApiVersion.Title}*/}
<ListItem {/* subTitle={*/}
title={Locale.Settings.Access.Google.ApiVersion.Title} {/* Locale.Settings.Access.Google.ApiVersion.SubTitle*/}
subTitle={ {/* }*/}
Locale.Settings.Access.Google.ApiVersion.SubTitle {/* >*/}
} {/* <input*/}
> {/* type="text"*/}
<input {/* value={accessStore.googleApiVersion}*/}
type="text" {/* placeholder="2023-08-01-preview"*/}
value={accessStore.googleApiVersion} {/* onChange={(e) =>*/}
placeholder="2023-08-01-preview" {/* accessStore.update(*/}
onChange={(e) => {/* (access) =>*/}
accessStore.update( {/* (access.googleApiVersion =*/}
(access) => {/* e.currentTarget.value),*/}
(access.googleApiVersion = {/* )*/}
e.currentTarget.value), {/* }*/}
) {/* ></input>*/}
} {/* </ListItem>*/}
></input> {/* </>*/}
</ListItem> {/* ) : null}*/}
</> {/* </>*/}
)} {/* )}*/}
{accessStore.provider === ServiceProvider.Anthropic && ( {/* </>*/}
<> {/* )}*/}
<ListItem
title={Locale.Settings.Access.Anthropic.Endpoint.Title}
subTitle={
Locale.Settings.Access.Anthropic.Endpoint.SubTitle +
Anthropic.ExampleEndpoint
}
>
<input
type="text"
value={accessStore.anthropicUrl}
placeholder={Anthropic.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) =>
(access.anthropicUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Anthropic.ApiKey.Title}
subTitle={
Locale.Settings.Access.Anthropic.ApiKey.SubTitle
}
>
<PasswordInput
value={accessStore.anthropicApiKey}
type="text"
placeholder={
Locale.Settings.Access.Anthropic.ApiKey.Placeholder
}
onChange={(e) => {
accessStore.update(
(access) =>
(access.anthropicApiKey =
e.currentTarget.value),
);
}}
/>
</ListItem>
<ListItem
title={Locale.Settings.Access.Anthropic.ApiVerion.Title}
subTitle={
Locale.Settings.Access.Anthropic.ApiVerion.SubTitle
}
>
<input
type="text"
value={accessStore.anthropicApiVersion}
placeholder={Anthropic.Vision}
onChange={(e) =>
accessStore.update(
(access) =>
(access.anthropicApiVersion =
e.currentTarget.value),
)
}
></input>
</ListItem>
</>
)}
</>
)}
</>
)}
{!shouldHideBalanceQuery && !clientConfig?.isApp ? ( {/* {!shouldHideBalanceQuery && !clientConfig?.isApp ? (*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Usage.Title} {/* title={Locale.Settings.Usage.Title}*/}
subTitle={ {/* subTitle={*/}
showUsage {/* showUsage*/}
? loadingUsage {/* ? loadingUsage*/}
? Locale.Settings.Usage.IsChecking {/* ? Locale.Settings.Usage.IsChecking*/}
: Locale.Settings.Usage.SubTitle( {/* : Locale.Settings.Usage.SubTitle(*/}
usage?.used ?? "[?]", {/* usage?.used ?? "[?]",*/}
usage?.subscription ?? "[?]", {/* usage?.subscription ?? "[?]",*/}
) {/* )*/}
: Locale.Settings.Usage.NoAccess {/* : Locale.Settings.Usage.NoAccess*/}
} {/* }*/}
> {/* >*/}
{!showUsage || loadingUsage ? ( {/* {!showUsage || loadingUsage ? (*/}
<div /> {/* <div />*/}
) : ( {/* ) : (*/}
<IconButton {/* <IconButton*/}
icon={<ResetIcon></ResetIcon>} {/* icon={<ResetIcon></ResetIcon>}*/}
text={Locale.Settings.Usage.Check} {/* text={Locale.Settings.Usage.Check}*/}
onClick={() => checkUsage(true)} {/* onClick={() => checkUsage(true)}*/}
/> {/* />*/}
)} {/* )}*/}
</ListItem> {/* </ListItem>*/}
) : null} {/* ) : null}*/}
<ListItem {/* <ListItem*/}
title={Locale.Settings.Access.CustomModel.Title} {/* title={Locale.Settings.Access.CustomModel.Title}*/}
subTitle={Locale.Settings.Access.CustomModel.SubTitle} {/* subTitle={Locale.Settings.Access.CustomModel.SubTitle}*/}
> {/* >*/}
<input {/* <input*/}
type="text" {/* type="text"*/}
value={config.customModels} {/* value={config.customModels}*/}
placeholder="model1,model2,model3" {/* placeholder="model1,model2,model3"*/}
onChange={(e) => {/* onChange={(e) =>*/}
config.update( {/* config.update(*/}
(config) => (config.customModels = e.currentTarget.value), {/* (config) => (config.customModels = e.currentTarget.value),*/}
) {/* )*/}
} {/* }*/}
></input> {/* ></input>*/}
</ListItem> {/* </ListItem>*/}
</List> {/*</List>*/}
<List> {/*<List>*/}
<ModelConfigList {/* <ModelConfigList*/}
modelConfig={config.modelConfig} {/* modelConfig={config.modelConfig}*/}
updateConfig={(updater) => { {/* updateConfig={(updater) => {*/}
const modelConfig = { ...config.modelConfig }; {/* const modelConfig = { ...config.modelConfig };*/}
updater(modelConfig); {/* updater(modelConfig);*/}
config.update((config) => (config.modelConfig = modelConfig)); {/* config.update((config) => (config.modelConfig = modelConfig));*/}
}} {/* }}*/}
/> {/* />*/}
</List> {/*</List>*/}
{shouldShowPromptModal && ( {shouldShowPromptModal && (
<UserPromptModal onClose={() => setShowPromptModal(false)} /> <UserPromptModal onClose={() => setShowPromptModal(false)} />

View File

@ -6,6 +6,7 @@ import { IconButton } from "./button";
import SettingsIcon from "../icons/settings.svg"; import SettingsIcon from "../icons/settings.svg";
import GithubIcon from "../icons/github.svg"; import GithubIcon from "../icons/github.svg";
import ChatGptIcon from "../icons/chatgpt.svg"; import ChatGptIcon from "../icons/chatgpt.svg";
import DiitIcon from "../icons/diit.svg";
import AddIcon from "../icons/add.svg"; import AddIcon from "../icons/add.svg";
import CloseIcon from "../icons/close.svg"; import CloseIcon from "../icons/close.svg";
import DeleteIcon from "../icons/delete.svg"; import DeleteIcon from "../icons/delete.svg";
@ -155,38 +156,38 @@ export function SideBar(props: { className?: string }) {
> >
<div className={styles["sidebar-header"]} data-tauri-drag-region> <div className={styles["sidebar-header"]} data-tauri-drag-region>
<div className={styles["sidebar-title"]} data-tauri-drag-region> <div className={styles["sidebar-title"]} data-tauri-drag-region>
NextChat DiitChat
</div>
<div className={styles["sidebar-sub-title"]}>
Build your own AI assistant.
</div> </div>
{/*<div className={styles["sidebar-sub-title"]}>*/}
{/* Build your own AI assistant.*/}
{/*</div>*/}
<div className={styles["sidebar-logo"] + " no-dark"}> <div className={styles["sidebar-logo"] + " no-dark"}>
<ChatGptIcon /> <DiitIcon />
</div> </div>
</div> </div>
<div className={styles["sidebar-header-bar"]}> {/*<div className={styles["sidebar-header-bar"]}>*/}
<IconButton {/* <IconButton*/}
icon={<MaskIcon />} {/* icon={<MaskIcon />}*/}
text={shouldNarrow ? undefined : Locale.Mask.Name} {/* text={shouldNarrow ? undefined : Locale.Mask.Name}*/}
className={styles["sidebar-bar-button"]} {/* className={styles["sidebar-bar-button"]}*/}
onClick={() => { {/* onClick={() => {*/}
if (config.dontShowMaskSplashScreen !== true) { {/* if (config.dontShowMaskSplashScreen !== true) {*/}
navigate(Path.NewChat, { state: { fromHome: true } }); {/* navigate(Path.NewChat, { state: { fromHome: true } });*/}
} else { {/* } else {*/}
navigate(Path.Masks, { state: { fromHome: true } }); {/* navigate(Path.Masks, { state: { fromHome: true } });*/}
} {/* }*/}
}} {/* }}*/}
shadow {/* shadow*/}
/> {/* />*/}
<IconButton {/* <IconButton*/}
icon={<PluginIcon />} {/* icon={<PluginIcon />}*/}
text={shouldNarrow ? undefined : Locale.Plugin.Name} {/* text={shouldNarrow ? undefined : Locale.Plugin.Name}*/}
className={styles["sidebar-bar-button"]} {/* className={styles["sidebar-bar-button"]}*/}
onClick={() => showToast(Locale.WIP)} {/* onClick={() => showToast(Locale.WIP)}*/}
shadow {/* shadow*/}
/> {/* />*/}
</div> {/*</div>*/}
<div <div
className={styles["sidebar-body"]} className={styles["sidebar-body"]}
@ -216,11 +217,11 @@ export function SideBar(props: { className?: string }) {
<IconButton icon={<SettingsIcon />} shadow /> <IconButton icon={<SettingsIcon />} shadow />
</Link> </Link>
</div> </div>
<div className={styles["sidebar-action"]}> {/*<div className={styles["sidebar-action"]}>*/}
<a href={REPO_URL} target="_blank" rel="noopener noreferrer"> {/* <a href={REPO_URL} target="_blank" rel="noopener noreferrer">*/}
<IconButton icon={<GithubIcon />} shadow /> {/* <IconButton icon={<GithubIcon />} shadow />*/}
</a> {/* </a>*/}
</div> {/*</div>*/}
</div> </div>
<div> <div>
<IconButton <IconButton

View File

@ -10,7 +10,7 @@ import { GoogleTagManager } from "@next/third-parties/google";
const serverConfig = getServerSideConfig(); const serverConfig = getServerSideConfig();
export const metadata: Metadata = { export const metadata: Metadata = {
title: "NextChat", title: "DiitChat",
description: "Your personal ChatGPT Chat Bot.", description: "Your personal ChatGPT Chat Bot.",
viewport: { viewport: {
width: "device-width", width: "device-width",

View File

@ -8,7 +8,7 @@ const cn = {
Error: { Error: {
Unauthorized: isApp Unauthorized: isApp
? "检测到无效 API Key请前往[设置](/#/settings)页检查 API Key 是否配置正确。" ? "检测到无效 API Key请前往[设置](/#/settings)页检查 API Key 是否配置正确。"
: "访问密码不正确或为空,请前往[登录](/#/auth)页输入正确的访问密码,或者在[设置](/#/settings)页填入你自己的 OpenAI API Key。", : "访问密码不正确或为空,请前往[登录](/#/auth)页输入正确的访问密码。",
}, },
Auth: { Auth: {
Title: "需要密码", Title: "需要密码",

View File

@ -71,9 +71,9 @@ export const ALL_LANG_OPTIONS: Record<Lang, string> = {
}; };
const LANG_KEY = "lang"; const LANG_KEY = "lang";
const DEFAULT_LANG = "en"; const DEFAULT_LANG = "cn";
const fallbackLang = en; const fallbackLang = cn;
const targetLang = ALL_LANGS[getLang()] as LocaleType; const targetLang = ALL_LANGS[getLang()] as LocaleType;
// if target lang missing some fields, it will use fallback lang string // if target lang missing some fields, it will use fallback lang string
@ -104,19 +104,19 @@ function getLanguage() {
} }
export function getLang(): Lang { export function getLang(): Lang {
const savedLang = getItem(LANG_KEY); // const savedLang = getItem(LANG_KEY);
//
if (AllLangs.includes((savedLang ?? "") as Lang)) { // if (AllLangs.includes((savedLang ?? "") as Lang)) {
return savedLang as Lang; // return savedLang as Lang;
} // }
//
const lang = getLanguage(); // const lang = getLanguage();
//
for (const option of AllLangs) { // for (const option of AllLangs) {
if (lang.includes(option)) { // if (lang.includes(option)) {
return option; // return option;
} // }
} // }
return DEFAULT_LANG; return DEFAULT_LANG;
} }

View File

@ -33,13 +33,13 @@ export const DEFAULT_CONFIG = {
fontSize: 14, fontSize: 14,
theme: Theme.Auto as Theme, theme: Theme.Auto as Theme,
tightBorder: !!getClientConfig()?.isApp, tightBorder: !!getClientConfig()?.isApp,
sendPreviewBubble: true, sendPreviewBubble: false,
enableAutoGenerateTitle: true, enableAutoGenerateTitle: true,
sidebarWidth: DEFAULT_SIDEBAR_WIDTH, sidebarWidth: DEFAULT_SIDEBAR_WIDTH,
disablePromptHint: false, disablePromptHint: false,
dontShowMaskSplashScreen: false, // dont show splash screen when create chat dontShowMaskSplashScreen: true, // dont show splash screen when create chat
hideBuiltinMasks: false, // dont add builtin masks hideBuiltinMasks: false, // dont add builtin masks
customModels: "", customModels: "",