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
316ba157
authored
Nov 06, 2025
by
Seefs
Committed by
GitHub
Nov 06, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix playground (#2153)
parent
c1af01c3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
3 deletions
+67
-3
web/src/helpers/base64.js
+56
-0
web/src/helpers/index.js
+1
-0
web/src/hooks/tokens/useTokensData.jsx
+8
-2
web/src/pages/Playground/index.jsx
+2
-1
No files found.
web/src/helpers/base64.js
0 → 100644
View file @
316ba157
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
const
toBinaryString
=
(
text
)
=>
{
if
(
typeof
TextEncoder
!==
'undefined'
)
{
const
bytes
=
new
TextEncoder
().
encode
(
text
);
let
binary
=
''
;
bytes
.
forEach
((
byte
)
=>
{
binary
+=
String
.
fromCharCode
(
byte
);
});
return
binary
;
}
return
encodeURIComponent
(
text
).
replace
(
/%
([
0-9A-F
]{2})
/g
,
(
_
,
hex
)
=>
String
.
fromCharCode
(
parseInt
(
hex
,
16
)),
);
};
export
const
encodeToBase64
=
(
value
)
=>
{
const
input
=
value
==
null
?
''
:
String
(
value
);
if
(
typeof
window
===
'undefined'
)
{
if
(
typeof
Buffer
!==
'undefined'
)
{
return
Buffer
.
from
(
input
,
'utf-8'
).
toString
(
'base64'
);
}
if
(
typeof
globalThis
!==
'undefined'
&&
typeof
globalThis
.
btoa
===
'function'
)
{
return
globalThis
.
btoa
(
toBinaryString
(
input
));
}
throw
new
Error
(
'Base64 encoding is unavailable in the current environment'
,
);
}
return
window
.
btoa
(
toBinaryString
(
input
));
};
web/src/helpers/index.js
View file @
316ba157
...
@@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
...
@@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
export
*
from
'./history'
;
export
*
from
'./history'
;
export
*
from
'./auth'
;
export
*
from
'./auth'
;
export
*
from
'./utils'
;
export
*
from
'./utils'
;
export
*
from
'./base64'
;
export
*
from
'./api'
;
export
*
from
'./api'
;
export
*
from
'./render'
;
export
*
from
'./render'
;
export
*
from
'./log'
;
export
*
from
'./log'
;
...
...
web/src/hooks/tokens/useTokensData.jsx
View file @
316ba157
...
@@ -20,7 +20,13 @@ For commercial licensing, please contact support@quantumnous.com
...
@@ -20,7 +20,13 @@ For commercial licensing, please contact support@quantumnous.com
import
{
useState
,
useEffect
}
from
'react'
;
import
{
useState
,
useEffect
}
from
'react'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
Modal
}
from
'@douyinfe/semi-ui'
;
import
{
Modal
}
from
'@douyinfe/semi-ui'
;
import
{
API
,
copy
,
showError
,
showSuccess
}
from
'../../helpers'
;
import
{
API
,
copy
,
showError
,
showSuccess
,
encodeToBase64
,
}
from
'../../helpers'
;
import
{
ITEMS_PER_PAGE
}
from
'../../constants'
;
import
{
ITEMS_PER_PAGE
}
from
'../../constants'
;
import
{
useTableCompactMode
}
from
'../common/useTableCompactMode'
;
import
{
useTableCompactMode
}
from
'../common/useTableCompactMode'
;
...
@@ -136,7 +142,7 @@ export const useTokensData = (openFluentNotification) => {
...
@@ -136,7 +142,7 @@ export const useTokensData = (openFluentNotification) => {
apiKey
:
'sk-'
+
record
.
key
,
apiKey
:
'sk-'
+
record
.
key
,
};
};
let
encodedConfig
=
encodeURIComponent
(
let
encodedConfig
=
encodeURIComponent
(
btoa
(
JSON
.
stringify
(
cherryConfig
)),
encodeToBase64
(
JSON
.
stringify
(
cherryConfig
)),
);
);
url
=
url
.
replaceAll
(
'{cherryConfig}'
,
encodedConfig
);
url
=
url
.
replaceAll
(
'{cherryConfig}'
,
encodedConfig
);
}
else
{
}
else
{
...
...
web/src/pages/Playground/index.jsx
View file @
316ba157
...
@@ -47,6 +47,7 @@ import {
...
@@ -47,6 +47,7 @@ import {
createLoadingAssistantMessage
,
createLoadingAssistantMessage
,
getTextContent
,
getTextContent
,
buildApiPayload
,
buildApiPayload
,
encodeToBase64
,
}
from
'../../helpers'
;
}
from
'../../helpers'
;
// Components
// Components
...
@@ -72,7 +73,7 @@ const generateAvatarDataUrl = (username) => {
...
@@ -72,7 +73,7 @@ const generateAvatarDataUrl = (username) => {
<text x="50%" y="50%" dominant-baseline="central" text-anchor="middle" font-size="16" fill="#ffffff" font-family="sans-serif">
${
firstLetter
}
</text>
<text x="50%" y="50%" dominant-baseline="central" text-anchor="middle" font-size="16" fill="#ffffff" font-family="sans-serif">
${
firstLetter
}
</text>
</svg>
</svg>
`
;
`
;
return
`data:image/svg+xml;base64,
${
btoa
(
svg
)}
`
;
return
`data:image/svg+xml;base64,
${
encodeToBase64
(
svg
)}
`
;
};
};
const
Playground
=
()
=>
{
const
Playground
=
()
=>
{
...
...
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