Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Bistutu committed Apr 27, 2024
1 parent 333291c commit 5bc6131
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
26 changes: 14 additions & 12 deletions entrypoints/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,28 @@ export default defineContentScript({
let startPos = {x: 0, y: 0}; // startPos 记录鼠标按下时的位置
document.body.addEventListener('mouseup', () => clearTimeout(timer));
document.body.addEventListener('mousedown', event => {
clearTimeout(timer); // 清除之前的计时器
startPos.x = event.clientX; // 记录鼠标按下时的初始位置
startPos.y = event.clientY;
timer = setTimeout(() => {
let mouseX = event.clientX;
let mouseY = event.clientY;
handler(config, mouseX, mouseY);
}, 500) as unknown as number;
if (config.hotkey === constants.LongPress) {
clearTimeout(timer); // 清除之前的计时器
startPos.x = event.clientX; // 记录鼠标按下时的初始位置
startPos.y = event.clientY;
timer = setTimeout(() => {
let mouseX = event.clientX;
let mouseY = event.clientY;
handler(config, mouseX, mouseY);
}, 500) as unknown as number;
}
});
document.body.addEventListener('mousemove', event => {
// 如果鼠标移动超过10像素,取消长按事件
if (Math.abs(event.clientX - startPos.x) > 10 || Math.abs(event.clientY - startPos.y) > 10) {
clearTimeout(timer);
}
});

document.body.addEventListener('mousemove', event => {
// 检测鼠标是否移动
if (Math.abs(event.clientX - startPos.x) > 10 || Math.abs(event.clientY - startPos.y) > 10) {
clearTimeout(timer); // 如果鼠标移动超过10像素,取消长按事件
// 检测鼠标是否移动,如果鼠标移动超过10像素,取消长按事件
if (config.hotkey === constants.LongPress
&& Math.abs(event.clientX - startPos.x) > 10 || Math.abs(event.clientY - startPos.y) > 10) {
clearTimeout(timer);
}
});

Expand Down
8 changes: 4 additions & 4 deletions entrypoints/popup/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue'


const app = createApp(App);
app.use(ElementPlus) // 导入 element-plus ui
for (const [key, component] of Object.entries(ElementPlusIconsVue)) { // 注册所有 element-plus 的图标
app.component(key, component)
}

// 导入 element-plus ui,注册所有 element-plus 的图标
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) app.component(key, component)

app.mount('#app');
6 changes: 1 addition & 5 deletions entrypoints/popup/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@
-webkit-text-size-adjust: 100%;
}

.lightblue {
/*background-color: #f0f2f5;*/
}

.rounded-corner {
border-radius: 5px; /* 或者您期望的圆角大小 */
}

/*popup选项框文字*/
.popup-text {
font-size: 15px;
color: #000000;
/*color: #000000;*/
}

.popup-vertical-left {
Expand Down
10 changes: 5 additions & 5 deletions entrypoints/utils/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ export const options = {
label: 'OpenAI',
model: "gpt-3.5-turbo",
},
{
value: services.moonshot,
label: 'Kimi(月之暗面)',
model: "moonshot-v1-8k",
},
{
value: services.claude,
label: 'Claude',
Expand All @@ -169,11 +174,6 @@ export const options = {
label: 'Gemini',
model: "gemini-pro",
},
{
value: services.moonshot,
label: 'Moonshot',
model: "moonshot-v1-8k",
},
{
value: services.zhipu,
label: '智谱清言',
Expand Down

0 comments on commit 5bc6131

Please sign in to comment.