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
e6525eea
authored
Sep 27, 2025
by
Seefs
Committed by
GitHub
Sep 27, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1853 from ZKunZhang/fix/playground-copy-newlines
fix: 修复多行代码复制换行丢失问题 & 优化API参数处理#1828
parents
5f34c4a9
6f5dd348
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
16 deletions
+21
-16
web/src/components/common/markdown/MarkdownRenderer.jsx
+2
-2
web/src/helpers/api.js
+8
-7
web/src/helpers/utils.jsx
+11
-7
No files found.
web/src/components/common/markdown/MarkdownRenderer.jsx
View file @
e6525eea
...
...
@@ -181,8 +181,8 @@ export function PreCode(props) {
e
.
preventDefault
();
e
.
stopPropagation
();
if
(
ref
.
current
)
{
const
code
=
ref
.
current
.
querySelector
(
'code'
)?.
innerTex
t
??
''
;
const
code
Element
=
ref
.
current
.
querySelector
(
'code'
);
const
code
=
codeElement
?.
textConten
t
??
''
;
copy
(
code
).
then
((
success
)
=>
{
if
(
success
)
{
Toast
.
success
(
t
(
'代码已复制到剪贴板'
));
...
...
web/src/helpers/api.js
View file @
e6525eea
...
...
@@ -118,7 +118,6 @@ export const buildApiPayload = (
model
:
inputs
.
model
,
group
:
inputs
.
group
,
messages
:
processedMessages
,
group
:
inputs
.
group
,
stream
:
inputs
.
stream
,
};
...
...
@@ -132,13 +131,15 @@ export const buildApiPayload = (
seed
:
'seed'
,
};
Object
.
entries
(
parameterMappings
).
forEach
(([
key
,
param
])
=>
{
if
(
parameterEnabled
[
key
]
&&
inputs
[
param
]
!==
undefined
&&
inputs
[
param
]
!==
null
)
{
payload
[
param
]
=
inputs
[
param
];
const
enabled
=
parameterEnabled
[
key
];
const
value
=
inputs
[
param
];
const
hasValue
=
value
!==
undefined
&&
value
!==
null
;
if
(
enabled
&&
hasValue
)
{
payload
[
param
]
=
value
;
}
});
...
...
web/src/helpers/utils.jsx
View file @
e6525eea
...
...
@@ -75,13 +75,17 @@ export async function copy(text) {
await
navigator
.
clipboard
.
writeText
(
text
);
}
catch
(
e
)
{
try
{
// 构建input 执行 复制命令
var
_input
=
window
.
document
.
createElement
(
'input'
);
_input
.
value
=
text
;
window
.
document
.
body
.
appendChild
(
_input
);
_input
.
select
();
window
.
document
.
execCommand
(
'Copy'
);
window
.
document
.
body
.
removeChild
(
_input
);
// 构建 textarea 执行复制命令,保留多行文本格式
const
textarea
=
window
.
document
.
createElement
(
'textarea'
);
textarea
.
value
=
text
;
textarea
.
setAttribute
(
'readonly'
,
''
);
textarea
.
style
.
position
=
'fixed'
;
textarea
.
style
.
left
=
'-9999px'
;
textarea
.
style
.
top
=
'-9999px'
;
window
.
document
.
body
.
appendChild
(
textarea
);
textarea
.
select
();
window
.
document
.
execCommand
(
'copy'
);
window
.
document
.
body
.
removeChild
(
textarea
);
}
catch
(
e
)
{
okay
=
false
;
console
.
error
(
e
);
...
...
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