Skip to content

Commit 80c34aa

Browse files
zouwangqiangjosStorer
authored andcommitted
- refactor(ConversationCard): add event listener to close the window on Escape key press
- refactor(ConversationCard): change style of header to allow for dragging - refactor(ConversationCard): change select width to auto - refactor(FloatingToolbar): change handle class from dragbar to draggable - refactor(styles.scss): add scrollbar and resizer styles to the conversation card and change select width to auto
1 parent 2ef9eb0 commit 80c34aa

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

src/components/ConversationCard/index.jsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ function ConversationCard(props) {
6868
)
6969
const config = useConfig()
7070

71+
document.addEventListener('keydown', function (event) {
72+
if (event.key === 'Escape' || event.keyCode === 27) {
73+
// 关闭窗口代码
74+
port.disconnect()
75+
if (props.onClose) props.onClose()
76+
}
77+
})
78+
7179
useEffect(() => {
7280
if (props.onUpdate) props.onUpdate(port, session, conversationItemData)
7381
}, [session, conversationItemData])
@@ -197,7 +205,10 @@ function ConversationCard(props) {
197205

198206
return (
199207
<div className="gpt-inner">
200-
<div className="gpt-header" style="margin: 15px;">
208+
<div
209+
className={props.draggable ? 'gpt-header draggable' : 'gpt-header'}
210+
style="padding: 15px;user-select:none;"
211+
>
201212
<span className="gpt-util-group">
202213
{props.closeable ? (
203214
<XLg
@@ -222,7 +233,7 @@ function ConversationCard(props) {
222233
<img src={logo} style="user-select:none;width:20px;height:20px;" />
223234
)}
224235
<select
225-
style={props.notClampSize ? {} : { width: windowSize[0] * 0.05 + 'px' }}
236+
style={props.notClampSize ? {} : { width: 'auto' }}
226237
className="normal-button"
227238
required
228239
onChange={(e) => {
@@ -255,9 +266,7 @@ function ConversationCard(props) {
255266
})}
256267
</select>
257268
</span>
258-
{props.draggable ? (
259-
<div className="dragbar" />
260-
) : (
269+
{!props.draggable && (
261270
<WindowDesktop
262271
className="gpt-util-icon"
263272
title={t('Float the Window')}

src/components/FloatingToolbar/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function FloatingToolbar(props) {
8080
return (
8181
<div data-theme={config.themeMode}>
8282
<Draggable
83-
handle=".dragbar"
83+
handle=".draggable"
8484
onDrag={dragEvent.onDrag}
8585
onStop={dragEvent.onStop}
8686
position={virtualPosition}

src/content-script/styles.scss

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,27 @@
8888
padding: 5px 15px 10px;
8989
background-color: var(--theme-color);
9090
color: var(--font-color);
91-
overflow-y: auto;
91+
::-webkit-scrollbar {
92+
background-color: var(--theme-color);
93+
}
94+
::-webkit-scrollbar-thumb {
95+
background-color: var(--dragbar-color);
96+
}
97+
&::-webkit-scrollbar {
98+
background-color: var(--theme-color);
99+
}
100+
&::-webkit-scrollbar-thumb {
101+
background-color: var(--dragbar-color);
102+
}
103+
::-webkit-resizer {
104+
background-color: var(--theme-color);
105+
}
106+
&::-webkit-resizer {
107+
background-color: var(--theme-color);
108+
}
92109

110+
overflow-y: auto;
111+
min-height: 300px;
93112
p {
94113
color: var(--font-color);
95114
}

0 commit comments

Comments
 (0)