mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
chore: dalle2
This commit is contained in:
parent
594260ce5d
commit
a361ce52b5
19
src-tauri/src/assets/dalle2.core.js
vendored
19
src-tauri/src/assets/dalle2.core.js
vendored
@ -28,22 +28,19 @@ async function init() {
|
||||
document.body.appendChild(selectionMenu);
|
||||
const { computePosition, flip, offset, shift } = window.FloatingUIDOM;
|
||||
|
||||
document.body.addEventListener("mouseup", async (e) => {
|
||||
const selection = window.getSelection();
|
||||
if (window.__DALLE2_STATE__ !== 1) {
|
||||
window.__DALLE2_CONTENT__ = selection.toString().trim();
|
||||
}
|
||||
|
||||
document.body.addEventListener('mousedown', async (e) => {
|
||||
if (e.target.id === 'chagpt-selection-menu') {
|
||||
await invoke('dalle2_window', { query: encodeURIComponent(window.__DALLE2_CONTENT__) });
|
||||
}
|
||||
|
||||
if (window.__DALLE2_STATE__ === 1) {
|
||||
delete window.__DALLE2_STATE__;
|
||||
} else {
|
||||
delete window.__DALLE2_CONTENT__;
|
||||
}
|
||||
});
|
||||
|
||||
document.body.addEventListener("mouseup", async (e) => {
|
||||
selectionMenu.style.display = 'none';
|
||||
const selection = window.getSelection();
|
||||
window.__DALLE2_CONTENT__ = selection.toString().trim();
|
||||
|
||||
if (!window.__DALLE2_CONTENT__) return;
|
||||
|
||||
if (selection.rangeCount > 0) {
|
||||
@ -56,8 +53,6 @@ async function init() {
|
||||
rootEl.style.left = `${rect.left}px`;
|
||||
document.body.appendChild(rootEl);
|
||||
|
||||
window.__DALLE2_STATE__ = 1;
|
||||
|
||||
selectionMenu.style.display = 'block';
|
||||
computePosition(rootEl, selectionMenu, {
|
||||
placement: 'top',
|
||||
|
Loading…
Reference in New Issue
Block a user