Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
ai-chat-ui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenghong_tao
ai-chat-ui
Commits
26e2a9fd
Commit
26e2a9fd
authored
Apr 29, 2025
by
chenghong_tao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add embed.js userId参数
parent
ec9da121
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
README.md
README.md
+2
-2
demo.html
iframePlugin/demo.html
+12
-0
embed.js
iframePlugin/embed.js
+5
-1
No files found.
README.md
View file @
26e2a9fd
...
...
@@ -23,9 +23,9 @@ npm run build
### 注意事项
1.
使用embed模式时,引入embed.js文件时需要带URL参数
```
html
<script
src=
"/embed.min.js?url=当前前端所在的IP或域名地址"
></script>
<script
src=
"/embed.min.js?url=当前前端所在的IP或域名地址
&userId=用户名
"
></script>
```
如:在本地运行前端时,引入embed.js文件时,参数则为url=http://127.0.0.1:3000
```
html
<script
src=
"/embed.min.js?url=http://127.0.0.1:3000"
></script>
<script
src=
"/embed.min.js?url=http://127.0.0.1:3000
&userId=admin
"
></script>
```
iframePlugin/demo.html
0 → 100644
View file @
26e2a9fd
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Chat iframe test
</title>
</head>
<body>
<script
src=
"http://10.82.13.89:8080/embed.min.js?url=http://10.82.13.89:8080&userId=张三"
></script>
</body>
</html>
\ No newline at end of file
iframePlugin/embed.js
View file @
26e2a9fd
...
...
@@ -7,10 +7,14 @@
return
;
}
let
baseUrl
=
''
;
let
userId
=
''
;
// 获取当前时间戳
const
timestamp
=
Date
.
now
();
try
{
// 处理相对路径(如 src="./embed.js")
const
scriptUrl
=
new
URL
(
currentScript
.
src
,
location
.
href
);
baseUrl
=
scriptUrl
.
searchParams
.
get
(
'url'
);
userId
=
scriptUrl
.
searchParams
.
get
(
'userId'
);
if
(
!
baseUrl
)
{
console
.
error
(
'未找到URL参数'
);
...
...
@@ -100,7 +104,7 @@
const
iframe
=
document
.
createElement
(
'iframe'
);
// 获取URL
iframe
.
src
=
baseUrl
;
// 替换为你的聊天窗口页面地址
iframe
.
src
=
baseUrl
+
'?userId='
+
userId
+
'×tamp='
+
timestamp
;
// 替换为你的聊天窗口页面地址
iframe
.
style
.
width
=
'100%'
;
iframe
.
style
.
height
=
'100%'
;
iframe
.
style
.
border
=
'none'
;
...
...
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