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);
|
document.body.appendChild(selectionMenu);
|
||||||
const { computePosition, flip, offset, shift } = window.FloatingUIDOM;
|
const { computePosition, flip, offset, shift } = window.FloatingUIDOM;
|
||||||
|
|
||||||
document.body.addEventListener("mouseup", async (e) => {
|
document.body.addEventListener('mousedown', async (e) => {
|
||||||
const selection = window.getSelection();
|
|
||||||
if (window.__DALLE2_STATE__ !== 1) {
|
|
||||||
window.__DALLE2_CONTENT__ = selection.toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.target.id === 'chagpt-selection-menu') {
|
if (e.target.id === 'chagpt-selection-menu') {
|
||||||
await invoke('dalle2_window', { query: encodeURIComponent(window.__DALLE2_CONTENT__) });
|
await invoke('dalle2_window', { query: encodeURIComponent(window.__DALLE2_CONTENT__) });
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (window.__DALLE2_STATE__ === 1) {
|
|
||||||
delete window.__DALLE2_STATE__;
|
|
||||||
delete window.__DALLE2_CONTENT__;
|
delete window.__DALLE2_CONTENT__;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.body.addEventListener("mouseup", async (e) => {
|
||||||
selectionMenu.style.display = 'none';
|
selectionMenu.style.display = 'none';
|
||||||
|
const selection = window.getSelection();
|
||||||
|
window.__DALLE2_CONTENT__ = selection.toString().trim();
|
||||||
|
|
||||||
if (!window.__DALLE2_CONTENT__) return;
|
if (!window.__DALLE2_CONTENT__) return;
|
||||||
|
|
||||||
if (selection.rangeCount > 0) {
|
if (selection.rangeCount > 0) {
|
||||||
@ -56,8 +53,6 @@ async function init() {
|
|||||||
rootEl.style.left = `${rect.left}px`;
|
rootEl.style.left = `${rect.left}px`;
|
||||||
document.body.appendChild(rootEl);
|
document.body.appendChild(rootEl);
|
||||||
|
|
||||||
window.__DALLE2_STATE__ = 1;
|
|
||||||
|
|
||||||
selectionMenu.style.display = 'block';
|
selectionMenu.style.display = 'block';
|
||||||
computePosition(rootEl, selectionMenu, {
|
computePosition(rootEl, selectionMenu, {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
|
Loading…
Reference in New Issue
Block a user