Skip to content

Commit

Permalink
feat: 令牌聊天新增ChatGPT Web & Midjourney支持
Browse files Browse the repository at this point in the history
  • Loading branch information
Calcium-Ion committed Jan 21, 2024
1 parent f73a180 commit c59a33e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions web/src/components/OperationSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const OperationSetting = () => {
placeholder='例如发卡网站的购买链接'
/>
<Form.Input
label='聊天页面链接'
label='默认聊天页面链接'
name='ChatLink'
onChange={handleInputChange}
autoComplete='new-password'
Expand All @@ -198,7 +198,7 @@ const OperationSetting = () => {
autoComplete='new-password'
value={inputs.ChatLink2}
type='link'
placeholder='例如 ChatGPT Next Web 的部署地址'
placeholder='例如 ChatGPT Web & Midjourney 的部署地址'
/>
<Form.Input
label='单位美元额度'
Expand Down
22 changes: 13 additions & 9 deletions web/src/components/TokensTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const TokensTable = () => {

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'},
];

Expand Down Expand Up @@ -154,8 +155,9 @@ const TokensTable = () => {
<Button theme="light" style={{ color: 'rgba(var(--semi-teal-7), 1)' }} onClick={()=>{onOpenLink('next', record.key)}}>聊天</Button>
<Dropdown trigger="click" position="bottomRight" menu={
[
{node: 'item', key: 'next', name: 'ChatGPT Next Web', onClick: () => {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)}},
]
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c59a33e

Please sign in to comment.