forked from XiaoMo/ChatGPT-Next-Web
feat: close #2908 allow to disable parse settings from link
This commit is contained in:
parent
638fdd8c3e
commit
c5ca278253
@ -191,6 +191,12 @@ If you do not want users to use GPT-4, set this value to 1.
|
|||||||
|
|
||||||
If you do want users to query balance, set this value to 1, or you should set it to 0.
|
If you do want users to query balance, set this value to 1, or you should set it to 0.
|
||||||
|
|
||||||
|
### `DISABLE_FAST_LINK` (optional)
|
||||||
|
|
||||||
|
> Default: Empty
|
||||||
|
|
||||||
|
If you want to disable parse settings from url, set this to 1.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
NodeJS >= 18, Docker >= 20
|
NodeJS >= 18, Docker >= 20
|
||||||
|
@ -102,6 +102,10 @@ OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填
|
|||||||
|
|
||||||
如果你想启用余额查询功能,将此环境变量设置为 1 即可。
|
如果你想启用余额查询功能,将此环境变量设置为 1 即可。
|
||||||
|
|
||||||
|
### `DISABLE_FAST_LINK` (可选)
|
||||||
|
|
||||||
|
如果你想禁用从链接解析预制设置,将此环境变量设置为 1 即可。
|
||||||
|
|
||||||
## 开发
|
## 开发
|
||||||
|
|
||||||
点击下方按钮,开始二次开发:
|
点击下方按钮,开始二次开发:
|
||||||
|
@ -11,6 +11,7 @@ const DANGER_CONFIG = {
|
|||||||
hideUserApiKey: serverConfig.hideUserApiKey,
|
hideUserApiKey: serverConfig.hideUserApiKey,
|
||||||
disableGPT4: serverConfig.disableGPT4,
|
disableGPT4: serverConfig.disableGPT4,
|
||||||
hideBalanceQuery: serverConfig.hideBalanceQuery,
|
hideBalanceQuery: serverConfig.hideBalanceQuery,
|
||||||
|
disableFastLink: serverConfig.disableFastLink,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -975,14 +975,17 @@ function _Chat() {
|
|||||||
doSubmit(text);
|
doSubmit(text);
|
||||||
},
|
},
|
||||||
code: (text) => {
|
code: (text) => {
|
||||||
|
if (accessStore.disableFastLink) return;
|
||||||
console.log("[Command] got code from url: ", text);
|
console.log("[Command] got code from url: ", text);
|
||||||
showConfirm(Locale.URLCommand.Code + `code = ${text}`).then((res) => {
|
showConfirm(Locale.URLCommand.Code + `code = ${text}`).then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
accessStore.updateCode(text);
|
accessStore.update((access) => (access.accessCode = text));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
settings: (text) => {
|
settings: (text) => {
|
||||||
|
if (accessStore.disableFastLink) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const payload = JSON.parse(text) as {
|
const payload = JSON.parse(text) as {
|
||||||
key?: string;
|
key?: string;
|
||||||
@ -998,10 +1001,10 @@ function _Chat() {
|
|||||||
).then((res) => {
|
).then((res) => {
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
if (payload.key) {
|
if (payload.key) {
|
||||||
accessStore.updateToken(payload.key);
|
accessStore.update((access) => (access.token = payload.key!));
|
||||||
}
|
}
|
||||||
if (payload.url) {
|
if (payload.url) {
|
||||||
accessStore.updateOpenAiUrl(payload.url);
|
accessStore.update((access) => (access.openaiUrl = payload.url!));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,9 @@ export function Settings() {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder={Locale.Settings.AccessCode.Placeholder}
|
placeholder={Locale.Settings.AccessCode.Placeholder}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
accessStore.updateCode(e.currentTarget.value);
|
accessStore.update(
|
||||||
|
(access) => (access.accessCode = e.currentTarget.value),
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
@ -907,7 +909,9 @@ export function Settings() {
|
|||||||
value={accessStore.openaiUrl}
|
value={accessStore.openaiUrl}
|
||||||
placeholder="https://api.openai.com/"
|
placeholder="https://api.openai.com/"
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
accessStore.updateOpenAiUrl(e.currentTarget.value)
|
accessStore.update(
|
||||||
|
(access) => (access.openaiUrl = e.currentTarget.value),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
></input>
|
></input>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
@ -920,7 +924,9 @@ export function Settings() {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder={Locale.Settings.Token.Placeholder}
|
placeholder={Locale.Settings.Token.Placeholder}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
accessStore.updateToken(e.currentTarget.value);
|
accessStore.update(
|
||||||
|
(access) => (access.token = e.currentTarget.value),
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
@ -13,6 +13,7 @@ declare global {
|
|||||||
BUILD_MODE?: "standalone" | "export";
|
BUILD_MODE?: "standalone" | "export";
|
||||||
BUILD_APP?: string; // is building desktop app
|
BUILD_APP?: string; // is building desktop app
|
||||||
ENABLE_BALANCE_QUERY?: string; // allow user to query balance or not
|
ENABLE_BALANCE_QUERY?: string; // allow user to query balance or not
|
||||||
|
DISABLE_FAST_LINK?: string; // disallow parse settings from url or not
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,5 +49,6 @@ export const getServerSideConfig = () => {
|
|||||||
hideUserApiKey: !!process.env.HIDE_USER_API_KEY,
|
hideUserApiKey: !!process.env.HIDE_USER_API_KEY,
|
||||||
disableGPT4: !!process.env.DISABLE_GPT4,
|
disableGPT4: !!process.env.DISABLE_GPT4,
|
||||||
hideBalanceQuery: !process.env.ENABLE_BALANCE_QUERY,
|
hideBalanceQuery: !process.env.ENABLE_BALANCE_QUERY,
|
||||||
|
disableFastLink: !!process.env.DISABLE_FAST_LINK,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,7 @@ const DEFAULT_ACCESS_STATE = {
|
|||||||
hideUserApiKey: false,
|
hideUserApiKey: false,
|
||||||
hideBalanceQuery: false,
|
hideBalanceQuery: false,
|
||||||
disableGPT4: false,
|
disableGPT4: false,
|
||||||
|
disableFastLink: false,
|
||||||
|
|
||||||
openaiUrl: DEFAULT_OPENAI_URL,
|
openaiUrl: DEFAULT_OPENAI_URL,
|
||||||
};
|
};
|
||||||
@ -29,15 +30,6 @@ export const useAccessStore = createPersistStore(
|
|||||||
|
|
||||||
return get().needCode;
|
return get().needCode;
|
||||||
},
|
},
|
||||||
updateCode(code: string) {
|
|
||||||
set(() => ({ accessCode: code?.trim() }));
|
|
||||||
},
|
|
||||||
updateToken(token: string) {
|
|
||||||
set(() => ({ token: token?.trim() }));
|
|
||||||
},
|
|
||||||
updateOpenAiUrl(url: string) {
|
|
||||||
set(() => ({ openaiUrl: url?.trim() }));
|
|
||||||
},
|
|
||||||
isAuthorized() {
|
isAuthorized() {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user