Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b4142308
authored
Jun 17, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: able to add chat page link now (close #70)
parent
2bba56a7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
17 deletions
+73
-17
common/constants.go
+1
-0
controller/misc.go
+1
-0
model/option.go
+3
-0
web/src/App.js
+14
-0
web/src/components/Header.js
+24
-16
web/src/components/SystemSetting.js
+15
-1
web/src/pages/Chat/index.js
+15
-0
No files found.
common/constants.go
View file @
b4142308
...
@@ -14,6 +14,7 @@ var ServerAddress = "http://localhost:3000"
...
@@ -14,6 +14,7 @@ var ServerAddress = "http://localhost:3000"
var
Footer
=
""
var
Footer
=
""
var
Logo
=
""
var
Logo
=
""
var
TopUpLink
=
""
var
TopUpLink
=
""
var
ChatLink
=
""
var
UsingSQLite
=
false
var
UsingSQLite
=
false
...
...
controller/misc.go
View file @
b4142308
...
@@ -28,6 +28,7 @@ func GetStatus(c *gin.Context) {
...
@@ -28,6 +28,7 @@ func GetStatus(c *gin.Context) {
"turnstile_check"
:
common
.
TurnstileCheckEnabled
,
"turnstile_check"
:
common
.
TurnstileCheckEnabled
,
"turnstile_site_key"
:
common
.
TurnstileSiteKey
,
"turnstile_site_key"
:
common
.
TurnstileSiteKey
,
"top_up_link"
:
common
.
TopUpLink
,
"top_up_link"
:
common
.
TopUpLink
,
"chat_link"
:
common
.
ChatLink
,
},
},
})
})
return
return
...
...
model/option.go
View file @
b4142308
...
@@ -63,6 +63,7 @@ func InitOptionMap() {
...
@@ -63,6 +63,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"ModelRatio"
]
=
common
.
ModelRatio2JSONString
()
common
.
OptionMap
[
"ModelRatio"
]
=
common
.
ModelRatio2JSONString
()
common
.
OptionMap
[
"GroupRatio"
]
=
common
.
GroupRatio2JSONString
()
common
.
OptionMap
[
"GroupRatio"
]
=
common
.
GroupRatio2JSONString
()
common
.
OptionMap
[
"TopUpLink"
]
=
common
.
TopUpLink
common
.
OptionMap
[
"TopUpLink"
]
=
common
.
TopUpLink
common
.
OptionMap
[
"ChatLink"
]
=
common
.
ChatLink
common
.
OptionMapRWMutex
.
Unlock
()
common
.
OptionMapRWMutex
.
Unlock
()
loadOptionsFromDatabase
()
loadOptionsFromDatabase
()
}
}
...
@@ -191,6 +192,8 @@ func updateOptionMap(key string, value string) (err error) {
...
@@ -191,6 +192,8 @@ func updateOptionMap(key string, value string) (err error) {
err
=
common
.
UpdateGroupRatioByJSONString
(
value
)
err
=
common
.
UpdateGroupRatioByJSONString
(
value
)
case
"TopUpLink"
:
case
"TopUpLink"
:
common
.
TopUpLink
=
value
common
.
TopUpLink
=
value
case
"ChatLink"
:
common
.
ChatLink
=
value
case
"ChannelDisableThreshold"
:
case
"ChannelDisableThreshold"
:
common
.
ChannelDisableThreshold
,
_
=
strconv
.
ParseFloat
(
value
,
64
)
common
.
ChannelDisableThreshold
,
_
=
strconv
.
ParseFloat
(
value
,
64
)
}
}
...
...
web/src/App.js
View file @
b4142308
...
@@ -23,6 +23,7 @@ import Redemption from './pages/Redemption';
...
@@ -23,6 +23,7 @@ import Redemption from './pages/Redemption';
import
EditRedemption
from
'./pages/Redemption/EditRedemption'
;
import
EditRedemption
from
'./pages/Redemption/EditRedemption'
;
import
TopUp
from
'./pages/TopUp'
;
import
TopUp
from
'./pages/TopUp'
;
import
Log
from
'./pages/Log'
;
import
Log
from
'./pages/Log'
;
import
Chat
from
'./pages/Chat'
;
const
Home
=
lazy
(()
=>
import
(
'./pages/Home'
));
const
Home
=
lazy
(()
=>
import
(
'./pages/Home'
));
const
About
=
lazy
(()
=>
import
(
'./pages/About'
));
const
About
=
lazy
(()
=>
import
(
'./pages/About'
));
...
@@ -47,6 +48,11 @@ function App() {
...
@@ -47,6 +48,11 @@ function App() {
localStorage
.
setItem
(
'system_name'
,
data
.
system_name
);
localStorage
.
setItem
(
'system_name'
,
data
.
system_name
);
localStorage
.
setItem
(
'logo'
,
data
.
logo
);
localStorage
.
setItem
(
'logo'
,
data
.
logo
);
localStorage
.
setItem
(
'footer_html'
,
data
.
footer_html
);
localStorage
.
setItem
(
'footer_html'
,
data
.
footer_html
);
if
(
data
.
chat_link
)
{
localStorage
.
setItem
(
'chat_link'
,
data
.
chat_link
);
}
else
{
localStorage
.
removeItem
(
'chat_link'
);
}
if
(
if
(
data
.
version
!==
process
.
env
.
REACT_APP_VERSION
&&
data
.
version
!==
process
.
env
.
REACT_APP_VERSION
&&
data
.
version
!==
'v0.0.0'
&&
data
.
version
!==
'v0.0.0'
&&
...
@@ -267,6 +273,14 @@ function App() {
...
@@ -267,6 +273,14 @@ function App() {
<
/Suspense
>
<
/Suspense
>
}
}
/
>
/
>
<
Route
path
=
'/chat'
element
=
{
<
Suspense
fallback
=
{
<
Loading
><
/Loading>}
>
<
Chat
/>
<
/Suspense
>
}
/
>
<
Route
path
=
'*'
element
=
{
NotFound
}
/
>
<
Route
path
=
'*'
element
=
{
NotFound
}
/
>
<
/Routes
>
<
/Routes
>
);
);
...
...
web/src/components/Header.js
View file @
b4142308
...
@@ -7,57 +7,65 @@ import { API, getLogo, getSystemName, isAdmin, isMobile, showSuccess } from '../
...
@@ -7,57 +7,65 @@ import { API, getLogo, getSystemName, isAdmin, isMobile, showSuccess } from '../
import
'../index.css'
;
import
'../index.css'
;
// Header Buttons
// Header Buttons
cons
t
headerButtons
=
[
le
t
headerButtons
=
[
{
{
name
:
'首页'
,
name
:
'首页'
,
to
:
'/'
,
to
:
'/'
,
icon
:
'home'
,
icon
:
'home'
},
},
{
{
name
:
'渠道'
,
name
:
'渠道'
,
to
:
'/channel'
,
to
:
'/channel'
,
icon
:
'sitemap'
,
icon
:
'sitemap'
,
admin
:
true
,
admin
:
true
},
},
{
{
name
:
'令牌'
,
name
:
'令牌'
,
to
:
'/token'
,
to
:
'/token'
,
icon
:
'key'
,
icon
:
'key'
},
},
{
{
name
:
'兑换'
,
name
:
'兑换'
,
to
:
'/redemption'
,
to
:
'/redemption'
,
icon
:
'dollar sign'
,
icon
:
'dollar sign'
,
admin
:
true
,
admin
:
true
},
},
{
{
name
:
'充值'
,
name
:
'充值'
,
to
:
'/topup'
,
to
:
'/topup'
,
icon
:
'cart'
,
icon
:
'cart'
},
},
{
{
name
:
'用户'
,
name
:
'用户'
,
to
:
'/user'
,
to
:
'/user'
,
icon
:
'user'
,
icon
:
'user'
,
admin
:
true
,
admin
:
true
},
},
{
{
name
:
'日志'
,
name
:
'日志'
,
to
:
'/log'
,
to
:
'/log'
,
icon
:
'book'
,
icon
:
'book'
},
},
{
{
name
:
'设置'
,
name
:
'设置'
,
to
:
'/setting'
,
to
:
'/setting'
,
icon
:
'setting'
,
icon
:
'setting'
},
},
{
{
name
:
'关于'
,
name
:
'关于'
,
to
:
'/about'
,
to
:
'/about'
,
icon
:
'info circle'
,
icon
:
'info circle'
}
,
}
];
];
if
(
localStorage
.
getItem
(
'chat_link'
))
{
headerButtons
.
splice
(
1
,
0
,
{
name
:
'聊天'
,
to
:
'/chat'
,
icon
:
'comments'
});
}
const
Header
=
()
=>
{
const
Header
=
()
=>
{
const
[
userState
,
userDispatch
]
=
useContext
(
UserContext
);
const
[
userState
,
userDispatch
]
=
useContext
(
UserContext
);
let
navigate
=
useNavigate
();
let
navigate
=
useNavigate
();
...
@@ -112,11 +120,11 @@ const Header = () => {
...
@@ -112,11 +120,11 @@ const Header = () => {
style
=
{
style
=
{
showSidebar
showSidebar
?
{
?
{
borderBottom
:
'none'
,
borderBottom
:
'none'
,
marginBottom
:
'0'
,
marginBottom
:
'0'
,
borderTop
:
'none'
,
borderTop
:
'none'
,
height
:
'51px'
,
height
:
'51px'
}
}
:
{
borderTop
:
'none'
,
height
:
'52px'
}
:
{
borderTop
:
'none'
,
height
:
'52px'
}
}
}
>
>
...
...
web/src/components/SystemSetting.js
View file @
b4142308
...
@@ -34,6 +34,7 @@ const SystemSetting = () => {
...
@@ -34,6 +34,7 @@ const SystemSetting = () => {
ModelRatio
:
''
,
ModelRatio
:
''
,
GroupRatio
:
''
,
GroupRatio
:
''
,
TopUpLink
:
''
,
TopUpLink
:
''
,
ChatLink
:
''
,
AutomaticDisableChannelEnabled
:
''
,
AutomaticDisableChannelEnabled
:
''
,
ChannelDisableThreshold
:
0
,
ChannelDisableThreshold
:
0
,
LogConsumeEnabled
:
''
LogConsumeEnabled
:
''
...
@@ -109,7 +110,8 @@ const SystemSetting = () => {
...
@@ -109,7 +110,8 @@ const SystemSetting = () => {
name
===
'PreConsumedQuota'
||
name
===
'PreConsumedQuota'
||
name
===
'ModelRatio'
||
name
===
'ModelRatio'
||
name
===
'GroupRatio'
||
name
===
'GroupRatio'
||
name
===
'TopUpLink'
name
===
'TopUpLink'
||
name
===
'ChatLink'
)
{
)
{
setInputs
((
inputs
)
=>
({
...
inputs
,
[
name
]:
value
}));
setInputs
((
inputs
)
=>
({
...
inputs
,
[
name
]:
value
}));
}
else
{
}
else
{
...
@@ -155,6 +157,9 @@ const SystemSetting = () => {
...
@@ -155,6 +157,9 @@ const SystemSetting = () => {
if
(
originInputs
[
'TopUpLink'
]
!==
inputs
.
TopUpLink
)
{
if
(
originInputs
[
'TopUpLink'
]
!==
inputs
.
TopUpLink
)
{
await
updateOption
(
'TopUpLink'
,
inputs
.
TopUpLink
);
await
updateOption
(
'TopUpLink'
,
inputs
.
TopUpLink
);
}
}
if
(
originInputs
[
'ChatLink'
]
!==
inputs
.
ChatLink
)
{
await
updateOption
(
'ChatLink'
,
inputs
.
ChatLink
);
}
};
};
const
submitSMTP
=
async
()
=>
{
const
submitSMTP
=
async
()
=>
{
...
@@ -360,6 +365,15 @@ const SystemSetting = () => {
...
@@ -360,6 +365,15 @@ const SystemSetting = () => {
min
=
'0'
min
=
'0'
placeholder
=
'例如:100'
placeholder
=
'例如:100'
/>
/>
<
Form
.
Input
label
=
'聊天页面链接'
name
=
'ChatLink'
onChange
=
{
handleInputChange
}
autoComplete
=
'new-password'
value
=
{
inputs
.
ChatLink
}
type
=
'link'
placeholder
=
'例如 ChatGPT Next Web 的部署地址'
/>
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Group
widths
=
'equal'
>
<
Form
.
Group
widths
=
'equal'
>
<
Form
.
TextArea
<
Form
.
TextArea
...
...
web/src/pages/Chat/index.js
0 → 100644
View file @
b4142308
import
React
from
'react'
;
const
Chat
=
()
=>
{
const
chatLink
=
localStorage
.
getItem
(
'chat_link'
);
return
(
<
iframe
src
=
{
chatLink
}
style
=
{{
width
:
'100%'
,
height
:
'85vh'
,
border
:
'none'
}}
/
>
);
};
export
default
Chat
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment