Skip to content

Commit 3935c72

Browse files
committed
feat: sd setting
1 parent 908ee00 commit 3935c72

6 files changed

Lines changed: 71 additions & 5 deletions

File tree

app/components/settings.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
ServiceProvider,
6666
SlotID,
6767
UPDATE_URL,
68+
Stability,
6869
} from "../constant";
6970
import { Prompt, SearchService, usePromptStore } from "../store/prompt";
7071
import { ErrorBoundary } from "./error";
@@ -1041,6 +1042,45 @@ export function Settings() {
10411042
</>
10421043
);
10431044

1045+
const stabilityConfigComponent = accessStore.provider ===
1046+
ServiceProvider.Stability && (
1047+
<>
1048+
<ListItem
1049+
title={Locale.Settings.Access.Stability.Endpoint.Title}
1050+
subTitle={
1051+
Locale.Settings.Access.Stability.Endpoint.SubTitle +
1052+
Stability.ExampleEndpoint
1053+
}
1054+
>
1055+
<input
1056+
type="text"
1057+
value={accessStore.stabilityUrl}
1058+
placeholder={Stability.ExampleEndpoint}
1059+
onChange={(e) =>
1060+
accessStore.update(
1061+
(access) => (access.stabilityUrl = e.currentTarget.value),
1062+
)
1063+
}
1064+
></input>
1065+
</ListItem>
1066+
<ListItem
1067+
title={Locale.Settings.Access.Stability.ApiKey.Title}
1068+
subTitle={Locale.Settings.Access.Stability.ApiKey.SubTitle}
1069+
>
1070+
<PasswordInput
1071+
value={accessStore.stabilityApiKey}
1072+
type="text"
1073+
placeholder={Locale.Settings.Access.Stability.ApiKey.Placeholder}
1074+
onChange={(e) => {
1075+
accessStore.update(
1076+
(access) => (access.stabilityApiKey = e.currentTarget.value),
1077+
);
1078+
}}
1079+
/>
1080+
</ListItem>
1081+
</>
1082+
);
1083+
10441084
return (
10451085
<ErrorBoundary>
10461086
<div className="window-header" data-tauri-drag-region>
@@ -1324,6 +1364,7 @@ export function Settings() {
13241364
{baiduConfigComponent}
13251365
{byteDanceConfigComponent}
13261366
{alibabaConfigComponent}
1367+
{stabilityConfigComponent}
13271368
</>
13281369
)}
13291370
</>

app/constant.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ export enum ModelProvider {
116116
Qwen = "Qwen",
117117
}
118118

119-
export const StabilityPath = {
119+
export const Stability = {
120120
GeneratePath: "v2beta/stable-image/generate",
121+
ExampleEndpoint: "https://api.stability.ai",
121122
};
122123

123124
export const Anthropic = {

app/locales/cn.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,17 @@ const cn = {
389389
SubTitle: "样例:",
390390
},
391391
},
392+
Stability: {
393+
ApiKey: {
394+
Title: "接口密钥",
395+
SubTitle: "使用自定义 Stability API Key",
396+
Placeholder: "Stability API Key",
397+
},
398+
Endpoint: {
399+
Title: "接口地址",
400+
SubTitle: "样例:",
401+
},
402+
},
392403
CustomModel: {
393404
Title: "自定义模型名",
394405
SubTitle: "增加自定义模型可选项,使用英文逗号隔开",

app/locales/en.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,17 @@ const en: LocaleType = {
372372
SubTitle: "Example: ",
373373
},
374374
},
375+
Stability: {
376+
ApiKey: {
377+
Title: "Stability API Key",
378+
SubTitle: "Use a custom Stability API Key",
379+
Placeholder: "Stability API Key",
380+
},
381+
Endpoint: {
382+
Title: "Endpoint Address",
383+
SubTitle: "Example: ",
384+
},
385+
},
375386
CustomModel: {
376387
Title: "Custom Models",
377388
SubTitle: "Custom model options, seperated by comma",

app/store/access.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ const DEFAULT_ALIBABA_URL = isApp
3939
? DEFAULT_API_HOST + "/api/proxy/alibaba"
4040
: ApiPath.Alibaba;
4141

42-
console.log("DEFAULT_ANTHROPIC_URL", DEFAULT_ANTHROPIC_URL);
43-
4442
const DEFAULT_ACCESS_STATE = {
4543
accessCode: "",
4644
useCustomConfig: false,
@@ -80,6 +78,10 @@ const DEFAULT_ACCESS_STATE = {
8078
alibabaUrl: DEFAULT_ALIBABA_URL,
8179
alibabaApiKey: "",
8280

81+
//stability
82+
stabilityUrl: "",
83+
stabilityApiKey: "",
84+
8385
// server config
8486
needCode: true,
8587
hideUserApiKey: false,

app/store/sd.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StabilityPath, StoreKey } from "@/app/constant";
1+
import { Stability, StoreKey } from "@/app/constant";
22
import { getHeaders } from "@/app/client/api";
33
import { createPersistStore } from "@/app/utils/store";
44
import { nanoid } from "nanoid";
@@ -63,7 +63,7 @@ export const useSdStore = createPersistStore<
6363
}
6464
const headers = getHeaders();
6565
delete headers["Content-Type"];
66-
fetch(`/api/stability/${StabilityPath.GeneratePath}/${data.model}`, {
66+
fetch(`/api/stability/${Stability.GeneratePath}/${data.model}`, {
6767
method: "POST",
6868
headers: {
6969
...headers,

0 commit comments

Comments
 (0)