From e8db0a2c7204da8fa9249ebe7a008cddb98eb8f4 Mon Sep 17 00:00:00 2001
From: GuoRuqiang <61670021+guoruqiang@users.noreply.github.com>
Date: Tue, 16 Jan 2024 18:15:55 +0000
Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=80?=
=?UTF-8?q?=E4=B8=AA=E8=B6=85=E9=93=BE=E8=81=8A=E5=A4=A9=E8=B7=B3=E8=BD=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
在“运营设置里面”增加了“聊天页面2链接”,方便将项目(https://github.com/Dooy/chatgpt-web-midjourney-proxy) 替换掉原来的AMA问天。
Changes to be committed:
modified: common/constants.go
modified: controller/misc.go
modified: model/option.go
modified: web/src/App.js
modified: web/src/components/OperationSetting.js
modified: web/src/components/TokensTable.js
---
common/constants.go | 1 +
controller/misc.go | 1 +
model/option.go | 3 +++
web/src/App.js | 5 +++++
web/src/components/OperationSetting.js | 13 +++++++++++++
web/src/components/TokensTable.js | 13 +++++++------
6 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/common/constants.go b/common/constants.go
index 212649a..06986e5 100644
--- a/common/constants.go
+++ b/common/constants.go
@@ -21,6 +21,7 @@ var Footer = ""
var Logo = ""
var TopUpLink = ""
var ChatLink = ""
+var ChatLink2 = ""
var QuotaPerUnit = 500 * 1000.0 // $0.002 / 1K tokens
var DisplayInCurrencyEnabled = true
var DisplayTokenStatEnabled = true
diff --git a/controller/misc.go b/controller/misc.go
index e8dc843..1264f5d 100644
--- a/controller/misc.go
+++ b/controller/misc.go
@@ -31,6 +31,7 @@ func GetStatus(c *gin.Context) {
"turnstile_site_key": common.TurnstileSiteKey,
"top_up_link": common.TopUpLink,
"chat_link": common.ChatLink,
+ "chat_link2": common.ChatLink2,
"quota_per_unit": common.QuotaPerUnit,
"display_in_currency": common.DisplayInCurrencyEnabled,
"enable_batch_update": common.BatchUpdateEnabled,
diff --git a/model/option.go b/model/option.go
index 5a1b453..94b5bee 100644
--- a/model/option.go
+++ b/model/option.go
@@ -76,6 +76,7 @@ func InitOptionMap() {
common.OptionMap["GroupRatio"] = common.GroupRatio2JSONString()
common.OptionMap["TopUpLink"] = common.TopUpLink
common.OptionMap["ChatLink"] = common.ChatLink
+ common.OptionMap["ChatLink2"] = common.ChatLink2
common.OptionMap["QuotaPerUnit"] = strconv.FormatFloat(common.QuotaPerUnit, 'f', -1, 64)
common.OptionMap["RetryTimes"] = strconv.Itoa(common.RetryTimes)
common.OptionMap["DataExportInterval"] = strconv.Itoa(common.DataExportInterval)
@@ -241,6 +242,8 @@ func updateOptionMap(key string, value string) (err error) {
common.TopUpLink = value
case "ChatLink":
common.ChatLink = value
+ case "ChatLink2":
+ common.ChatLink2 = value
case "ChannelDisableThreshold":
common.ChannelDisableThreshold, _ = strconv.ParseFloat(value, 64)
case "QuotaPerUnit":
diff --git a/web/src/App.js b/web/src/App.js
index 02db609..e980397 100644
--- a/web/src/App.js
+++ b/web/src/App.js
@@ -57,6 +57,11 @@ function App() {
} else {
localStorage.removeItem('chat_link');
}
+ if (data.chat_link2) {
+ localStorage.setItem('chat_link2', data.chat_link2);
+ } else {
+ localStorage.removeItem('chat_link2');
+ }
// if (
// data.version !== process.env.REACT_APP_VERSION &&
// data.version !== 'v0.0.0' &&
diff --git a/web/src/components/OperationSetting.js b/web/src/components/OperationSetting.js
index 88f2d92..7ed7d47 100644
--- a/web/src/components/OperationSetting.js
+++ b/web/src/components/OperationSetting.js
@@ -15,6 +15,7 @@ const OperationSetting = () => {
GroupRatio: '',
TopUpLink: '',
ChatLink: '',
+ ChatLink2: '', // 添加的新状态变量
QuotaPerUnit: 0,
AutomaticDisableChannelEnabled: '',
ChannelDisableThreshold: 0,
@@ -141,6 +142,9 @@ const OperationSetting = () => {
if (originInputs['ChatLink'] !== inputs.ChatLink) {
await updateOption('ChatLink', inputs.ChatLink);
}
+ if (originInputs['ChatLink2'] !== inputs.ChatLink2) {
+ await updateOption('ChatLink2', inputs.ChatLink2);
+ }
if (originInputs['QuotaPerUnit'] !== inputs.QuotaPerUnit) {
await updateOption('QuotaPerUnit', inputs.QuotaPerUnit);
}
@@ -187,6 +191,15 @@ const OperationSetting = () => {
type='link'
placeholder='例如 ChatGPT Next Web 的部署地址'
/>
+
{
const link_menu = [
{node: 'item', key: 'next', name: 'ChatGPT Next Web', onClick: () => {onOpenLink('next')}},
- {node: 'item', key: 'ama', name: 'AMA 问天', value: 'ama'},
+ {node: 'item', key: 'ama', name: 'ChatGPT Web & Midjourney', value: 'ama'},
{node: 'item', key: 'opencat', name: 'OpenCat', value: 'opencat'},
];
@@ -155,7 +155,7 @@ const TokensTable = () => {
{onOpenLink('next', record.key)}},
- {node: 'item', key: 'ama', name: 'AMA 问天(BotGrem)', onClick: () => {onOpenLink('ama', record.key)}},
+ {node: 'item', key: 'ama', name: 'ChatGPT Web & Midjourney', onClick: () => {onOpenLink('ama', record.key)}},
{node: 'item', key: 'opencat', name: 'OpenCat', onClick: () => {onOpenLink('opencat', record.key)}},
]
}
@@ -289,6 +289,7 @@ const TokensTable = () => {
}
let encodedServerAddress = encodeURIComponent(serverAddress);
const nextLink = localStorage.getItem('chat_link');
+ const mjLink = localStorage.getItem('chat_link2');
let nextUrl;
if (nextLink) {
@@ -300,7 +301,7 @@ const TokensTable = () => {
let url;
switch (type) {
case 'ama':
- url = `ama://set-api-key?server=${encodedServerAddress}&key=sk-${key}`;
+ url = mjLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
break;
case 'opencat':
url = `opencat://team/join?domain=${encodedServerAddress}&token=sk-${key}`;
@@ -351,7 +352,7 @@ const TokensTable = () => {
let url;
switch (type) {
case 'ama':
- url = `ama://set-api-key?server=${encodedServerAddress}&key=sk-${key}`;
+ url = `https://mjgpt.grqnas.cn/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
break;
case 'opencat':
From f73a180fc328d1bd4d23ac6a2fadf8ffc704c9d8 Mon Sep 17 00:00:00 2001
From: GuoRuqiang <61670021+guoruqiang@users.noreply.github.com>
Date: Tue, 16 Jan 2024 18:50:01 +0000
Subject: [PATCH 2/3] Changes to be committed: modified:
web/src/components/TokensTable.js
---
web/src/components/TokensTable.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/web/src/components/TokensTable.js b/web/src/components/TokensTable.js
index 7402821..37f9231 100644
--- a/web/src/components/TokensTable.js
+++ b/web/src/components/TokensTable.js
@@ -341,6 +341,7 @@ const TokensTable = () => {
}
let encodedServerAddress = encodeURIComponent(serverAddress);
const chatLink = localStorage.getItem('chat_link');
+ const mjLink = localStorage.getItem('chat_link2');
let defaultUrl;
if (chatLink) {
@@ -352,7 +353,7 @@ const TokensTable = () => {
let url;
switch (type) {
case 'ama':
- url = `https://mjgpt.grqnas.cn/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
+ url = mjLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
break;
case 'opencat':
From c59a33e8e9dd9330e76d119bcbb81847b0b9344b Mon Sep 17 00:00:00 2001
From: CaIon <1808837298@qq.com>
Date: Sun, 21 Jan 2024 17:43:40 +0800
Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E4=BB=A4=E7=89=8C=E8=81=8A?=
=?UTF-8?q?=E5=A4=A9=E6=96=B0=E5=A2=9EChatGPT=20Web=20&=20Midjourney?=
=?UTF-8?q?=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/components/OperationSetting.js | 4 ++--
web/src/components/TokensTable.js | 22 +++++++++++++---------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/web/src/components/OperationSetting.js b/web/src/components/OperationSetting.js
index 7ed7d47..efa4914 100644
--- a/web/src/components/OperationSetting.js
+++ b/web/src/components/OperationSetting.js
@@ -183,7 +183,7 @@ const OperationSetting = () => {
placeholder='例如发卡网站的购买链接'
/>
{
autoComplete='new-password'
value={inputs.ChatLink2}
type='link'
- placeholder='例如 ChatGPT Next Web 的部署地址'
+ placeholder='例如 ChatGPT Web & Midjourney 的部署地址'
/>
{
const link_menu = [
{node: 'item', key: 'next', name: 'ChatGPT Next Web', onClick: () => {onOpenLink('next')}},
- {node: 'item', key: 'ama', name: 'ChatGPT Web & Midjourney', value: 'ama'},
+ {node: 'item', key: 'ama', name: 'AMA 问天', value: 'ama'},
+ {node: 'item', key: 'next-mj', name: 'ChatGPT Web & Midjourney', value: 'next-mj', onClick: () => {onOpenLink('next-mj')}},
{node: 'item', key: 'opencat', name: 'OpenCat', value: 'opencat'},
];
@@ -154,8 +155,9 @@ const TokensTable = () => {
{onOpenLink('next', record.key)}},
- {node: 'item', key: 'ama', name: 'ChatGPT Web & Midjourney', onClick: () => {onOpenLink('ama', record.key)}},
+ {node: 'item', key: 'next', disabled: !localStorage.getItem('chat_link'), name: 'ChatGPT Next Web', onClick: () => {onOpenLink('next', record.key)}},
+ {node: 'item', key: 'next-mj', disabled: !localStorage.getItem('chat_link2'), name: 'ChatGPT Web & Midjourney', onClick: () => {onOpenLink('next-mj', record.key)}},
+ {node: 'item', key: 'ama', name: 'AMA 问天(BotGrem)', onClick: () => {onOpenLink('ama', record.key)}},
{node: 'item', key: 'opencat', name: 'OpenCat', onClick: () => {onOpenLink('opencat', record.key)}},
]
}
@@ -346,21 +348,23 @@ const TokensTable = () => {
if (chatLink) {
defaultUrl = chatLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
- } else {
- showError('管理员未设置聊天链接')
- return
}
let url;
switch (type) {
case 'ama':
- url = mjLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
+ url = `ama://set-api-key?server=${encodedServerAddress}&key=sk-${key}`;
break;
-
case 'opencat':
url = `opencat://team/join?domain=${encodedServerAddress}&token=sk-${key}`;
break;
-
+ case 'next-mj':
+ url = mjLink + `/#/?settings={"key":"sk-${key}","url":"${serverAddress}"}`;
+ break;
default:
+ if (!chatLink) {
+ showError('管理员未设置聊天链接')
+ return;
+ }
url = defaultUrl;
}