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
1e413c8d
Commit
1e413c8d
authored
Apr 28, 2025
by
chenghong_tao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化嵌入文件
parent
2b895f7e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
15 deletions
+45
-15
embed.js
iframePlugin/embed.js
+45
-15
ai_icon.png
public/ai_icon.png
+0
-0
No files found.
iframePlugin/embed.js
View file @
1e413c8d
(
function
()
{
// 获取URL
const
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
const
baseUrl
=
urlParams
.
get
(
'url'
)
||
'https://tk-test.infi-inside.com:2443'
;
// 优先用 document.currentScript(现代浏览器支持),不支持则回退方案使用遍历匹配(兼容旧浏览器)
const
currentScript
=
document
.
currentScript
||
Array
.
from
(
document
.
scripts
).
find
(
script
=>
script
.
src
.
endsWith
(
'embed.min.js'
));
if
(
!
currentScript
)
{
console
.
error
(
'无法获取当前脚本标签'
);
return
;
}
let
baseUrl
=
''
;
try
{
// 处理相对路径(如 src="./embed.js")
const
scriptUrl
=
new
URL
(
currentScript
.
src
,
location
.
href
);
baseUrl
=
scriptUrl
.
searchParams
.
get
(
'url'
);
if
(
!
baseUrl
)
{
console
.
error
(
'未找到URL参数'
);
return
;
}
// 在这里使用 baseUrl...
}
catch
(
error
)
{
console
.
error
(
'解析URL失败:'
,
error
);
}
// 创建悬浮按钮
const
button
=
document
.
createElement
(
'button'
);
button
.
id
=
'chatbot-bubble-button'
;
button
.
style
.
position
=
'fixed'
;
button
.
style
.
bottom
=
'
2
0px'
;
button
.
style
.
bottom
=
'
1
0px'
;
button
.
style
.
right
=
'20px'
;
button
.
style
.
width
=
'50px'
;
button
.
style
.
height
=
'50px'
;
...
...
@@ -22,8 +39,8 @@
// Create an img element
const
img
=
document
.
createElement
(
'img'
);
img
.
src
=
baseUrl
+
'/
deepseek
.png'
;
// Replace with the path to your image
img
.
style
.
width
=
'
6
0px'
;
img
.
src
=
baseUrl
+
'/
ai_icon
.png'
;
// Replace with the path to your image
img
.
style
.
width
=
'
5
0px'
;
// img.style.height = '100%';
img
.
style
.
objectFit
=
'cover'
;
...
...
@@ -36,7 +53,7 @@
const
iframeContainer
=
document
.
createElement
(
'div'
);
iframeContainer
.
id
=
'chatbot-bubble-window'
;
iframeContainer
.
style
.
position
=
'fixed'
;
iframeContainer
.
style
.
bottom
=
'
8
0px'
;
iframeContainer
.
style
.
bottom
=
'
6
0px'
;
iframeContainer
.
style
.
right
=
'20px'
;
iframeContainer
.
style
.
width
=
'650px'
;
// 24rem
iframeContainer
.
style
.
height
=
'85%'
;
// 40rem
...
...
@@ -49,26 +66,29 @@
// 创建关闭按钮并插入SVG
const
closeButton
=
document
.
createElement
(
'button'
);
closeButton
.
style
.
position
=
'absolute'
;
closeButton
.
style
.
top
=
'
15px
'
;
closeButton
.
style
.
right
=
'
5
px'
;
closeButton
.
style
.
width
=
'
20
px'
;
closeButton
.
style
.
height
=
'
20
px'
;
closeButton
.
style
.
top
=
'
calc(22px - 5px)
'
;
closeButton
.
style
.
right
=
'
7
px'
;
closeButton
.
style
.
width
=
'
14
px'
;
closeButton
.
style
.
height
=
'
14
px'
;
closeButton
.
style
.
border
=
'none'
;
closeButton
.
style
.
backgroundColor
=
'transparent'
;
closeButton
.
style
.
cursor
=
'pointer'
;
closeButton
.
style
.
outline
=
'none'
;
closeButton
.
style
.
padding
=
'0'
;
closeButton
.
style
.
margin
=
'0'
;
const
svg
=
document
.
createElementNS
(
"http://www.w3.org/2000/svg"
,
"svg"
);
svg
.
setAttribute
(
"t"
,
"1745391895314"
);
svg
.
setAttribute
(
"class"
,
"icon"
);
//
svg.setAttribute("class", "icon");
svg
.
setAttribute
(
"viewBox"
,
"0 0 1024 1024"
);
svg
.
setAttribute
(
"version"
,
"1.1"
);
svg
.
setAttribute
(
"xmlns"
,
"http://www.w3.org/2000/svg"
);
svg
.
setAttribute
(
"width"
,
"1
6
"
);
svg
.
setAttribute
(
"height"
,
"1
6
"
);
svg
.
setAttribute
(
"width"
,
"1
4
"
);
svg
.
setAttribute
(
"height"
,
"1
4
"
);
const
path
=
document
.
createElementNS
(
"http://www.w3.org/2000/svg"
,
"path"
);
path
.
setAttribute
(
"d"
,
"M512 0C229.273 0 0 229.273 0 512s229.273 512 512 512 512-229.273 512-512S794.727 0 512 0z m241.36 701.668a36.571 36.571 0 1 1-51.715 51.715L512 563.715 322.355 753.36a36.571 36.571 0 1 1-51.715-51.715L460.285 512 270.64 322.355a36.571 36.571 0 0 1 51.715-51.715L512 460.285 701.645 270.64a36.571 36.571 0 0 1 51.715 51.715L563.715 512z"
);
path
.
setAttribute
(
"fill"
,
"#
D81E06
"
);
path
.
setAttribute
(
"fill"
,
"#
d55444
"
);
svg
.
appendChild
(
path
);
closeButton
.
appendChild
(
svg
);
...
...
@@ -99,4 +119,13 @@
closeButton
.
addEventListener
(
'click'
,
()
=>
{
iframeContainer
.
style
.
display
=
'none'
;
});
// 关闭按钮鼠标移入效果
closeButton
.
addEventListener
(
'mouseenter'
,
()
=>
{
// 设置svg颜色
path
.
setAttribute
(
"fill"
,
"#D81E06"
);
});
// 关闭按钮鼠标移出效果
closeButton
.
addEventListener
(
'mouseleave'
,
()
=>
{
path
.
setAttribute
(
"fill"
,
"#d55444"
);
});
})();
\ No newline at end of file
public/ai_icon.png
0 → 100644
View file @
1e413c8d
3.67 KB
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