feat: new menu item / shortcut to close all chats

This commit is contained in:
josc146
2023-05-12 23:12:24 +08:00
parent 7355f39286
commit 8b05fb4c5c
16 changed files with 54 additions and 23 deletions
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "Tastenkombinationen",
"Open Conversation Page": "Konversationsseite öffnen",
"Open Conversation Window": "Konversationsfenster öffnen",
"Store to Independent Conversation Page": "Auf unabhängiger Konversationsseite speichern"
"Store to Independent Conversation Page": "Auf unabhängiger Konversationsseite speichern",
"Close All Chats In This Page": "Schließe alle Chats auf dieser Seite"
}
+2 -1
View File
@@ -114,5 +114,6 @@
"Others": "Others",
"API Modes": "API Modes",
"Disable web mode history for better privacy protection, but it will result in unavailable conversations after a period of time": "Disable web mode history for better privacy protection, but it will result in unavailable conversations after a period of time",
"Display selection tools next to input box to avoid blocking": "Display selection tools next to input box to avoid blocking"
"Display selection tools next to input box to avoid blocking": "Display selection tools next to input box to avoid blocking",
"Close All Chats In This Page": "Close All Chats In This Page"
}
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "Atajos de teclado",
"Open Conversation Page": "Abrir página de conversación independiente",
"Open Conversation Window": "Abrir la ventana de conversación independiente",
"Store to Independent Conversation Page": "Guardar en página de conversación independiente"
"Store to Independent Conversation Page": "Guardar en página de conversación independiente",
"Close All Chats In This Page": "Cerrar todos los chats en esta página"
}
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "Raccourcis clavier",
"Open Conversation Page": "Ouvrir la page de conversation",
"Open Conversation Window": "Ouvrir la fenêtre de conversation",
"Store to Independent Conversation Page": "Enregistrer sur une page de conversation indépendante"
"Store to Independent Conversation Page": "Enregistrer sur une page de conversation indépendante",
"Close All Chats In This Page": "Fermez tous les chats sur cette page"
}
+2 -1
View File
@@ -111,5 +111,6 @@
"API Params": "Parameter API",
"API Url": "URL API",
"Others": "Lain-lain",
"API Modes": "Mode API"
"API Modes": "Mode API",
"Close All Chats In This Page": "Tutup Semua Obrolan di Halaman Ini"
}
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "Scorciatoie da tastiera",
"Open Conversation Page": "Apri la pagina della conversazione",
"Open Conversation Window": "Apri la finestra di conversazione",
"Store to Independent Conversation Page": "Salva alla pagina della conversazione indipendente"
"Store to Independent Conversation Page": "Salva alla pagina della conversazione indipendente",
"Close All Chats In This Page": "Chiudi tutte le chat in questa pagina."
}
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "キーボードショートカット",
"Open Conversation Page": "会話ページを開く",
"Open Conversation Window": "会話ウィンドウを開く",
"Store to Independent Conversation Page": "独立した会話ページに保存"
"Store to Independent Conversation Page": "独立した会話ページに保存",
"Close All Chats In This Page": "このページのすべてのチャットを閉じる"
}
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "키보드 단축키 설정",
"Open Conversation Page": "대화 페이지 열기",
"Open Conversation Window": "대화 창 열기",
"Store to Independent Conversation Page": "독립적인 대화 페이지에 저장"
"Store to Independent Conversation Page": "독립적인 대화 페이지에 저장",
"Close All Chats In This Page": "이 페이지의 모든 채팅 종료하기"
}
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "Atalhos de Teclado",
"Open Conversation Page": "Abrir Página de Conversa",
"Open Conversation Window": "Abrir Janela de Conversa",
"Store to Independent Conversation Page": "Armazenar em Página de Conversa Independente"
"Store to Independent Conversation Page": "Armazenar em Página de Conversa Independente",
"Close All Chats In This Page": "Закрыть все чаты на этой странице"
}
+2 -1
View File
@@ -97,5 +97,6 @@
"Keyboard Shortcuts": "Горячие клавиши",
"Open Conversation Page": "Открыть страницу бесед",
"Open Conversation Window": "Открыть окно бесед",
"Store to Independent Conversation Page": "Хранить на странице независимых разговоров"
"Store to Independent Conversation Page": "Хранить на странице независимых разговоров",
"Close All Chats In This Page": "Close All Chats In This Page"
}
+2 -1
View File
@@ -114,5 +114,6 @@
"Others": "其他",
"API Modes": "API模式",
"Disable web mode history for better privacy protection, but it will result in unavailable conversations after a period of time": "禁用网页版模式历史记录以获得更好的隐私保护, 但会导致对话在一段时间后不可用",
"Display selection tools next to input box to avoid blocking": "将选择浮动工具显示在输入框旁边以避免遮挡"
"Display selection tools next to input box to avoid blocking": "将选择浮动工具显示在输入框旁边以避免遮挡",
"Close All Chats In This Page": "关闭本页所有聊天"
}
+2 -1
View File
@@ -114,5 +114,6 @@
"Others": "其他",
"API Modes": "API 模式",
"Disable web mode history for better privacy protection, but it will result in unavailable conversations after a period of time": "停用網頁版模式歷史記錄以提升隱私保護,但會導致對話記錄在一段時間後無法使用",
"Display selection tools next to input box to avoid blocking": "將選擇浮動工具顯示在輸入框旁邊以避免遮擋"
"Display selection tools next to input box to avoid blocking": "將選擇浮動工具顯示在輸入框旁邊以避免遮擋",
"Close All Chats In This Page": "關閉本頁所有對話"
}
+13 -11
View File
@@ -68,14 +68,6 @@ function ConversationCard(props) {
)
const config = useConfig()
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape' || event.keyCode === 27) {
// 关闭窗口代码
port.disconnect()
if (props.onClose) props.onClose()
}
})
useEffect(() => {
if (props.onUpdate) props.onUpdate(port, session, conversationItemData)
}, [session, conversationItemData])
@@ -118,13 +110,23 @@ function ConversationCard(props) {
}
useEffect(() => {
const listener = () => {
const portListener = () => {
setPort(Browser.runtime.connect())
setIsReady(true)
}
port.onDisconnect.addListener(listener)
const closeChatsListener = (message) => {
if (message.type === 'CLOSE_CHATS') {
port.disconnect()
if (props.onClose) props.onClose()
}
}
if (props.closeable) Browser.runtime.onMessage.addListener(closeChatsListener)
port.onDisconnect.addListener(portListener)
return () => {
port.onDisconnect.removeListener(listener)
if (props.closeable) Browser.runtime.onMessage.removeListener(closeChatsListener)
port.onDisconnect.removeListener(portListener)
}
}, [port])
useEffect(() => {
+11
View File
@@ -39,4 +39,15 @@ export const config = {
})
},
},
closeAllChats: {
label: 'Close All Chats In This Page',
action: async () => {
Browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
Browser.tabs.sendMessage(tabs[0].id, {
type: 'CLOSE_CHATS',
data: {},
})
})
},
},
}
+3
View File
@@ -85,6 +85,9 @@
},
"openConversationWindow": {
"description": "Open the independent conversation window"
},
"closeAllChats": {
"description": "Close all chats in this page"
}
}
}
+3
View File
@@ -79,6 +79,9 @@
},
"openConversationWindow": {
"description": "Open the independent conversation window"
},
"closeAllChats": {
"description": "Close all chats in this page"
}
}
}