mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
parent
9fa0fe8e6c
commit
71b37f690c
2
src-tauri/src/assets/core.js
vendored
2
src-tauri/src/assets/core.js
vendored
@ -71,7 +71,7 @@ async function init() {
|
||||
|
||||
document.addEventListener("click", (e) => {
|
||||
const origin = e.target.closest("a");
|
||||
if (!origin.target) return;
|
||||
if (!origin || !origin.target) return;
|
||||
if (origin && origin.href && origin.target !== '_self') {
|
||||
invoke('open_link', { url: origin.href });
|
||||
}
|
||||
|
2
src-tauri/src/assets/dalle2.js
vendored
2
src-tauri/src/assets/dalle2.js
vendored
@ -3,7 +3,7 @@
|
||||
async function init() {
|
||||
document.addEventListener("click", (e) => {
|
||||
const origin = e.target.closest("a");
|
||||
if (!origin.target) return;
|
||||
if (!origin || !origin.target) return;
|
||||
if (origin && origin.href && origin.target !== '_self') {
|
||||
if (/\/(login|signup)$/.test(window.location.href)) {
|
||||
origin.target = '_self';
|
||||
|
46
src-tauri/src/assets/export.js
vendored
46
src-tauri/src/assets/export.js
vendored
@ -24,7 +24,7 @@ async function init() {
|
||||
} else if (shouldRemoveButtons()) {
|
||||
removeButtons();
|
||||
}
|
||||
}, 200);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
const Format = {
|
||||
@ -47,9 +47,16 @@ function shouldRemoveButtons() {
|
||||
function shouldAddButtons(actionsArea) {
|
||||
// first, check if there's a "Try Again" button and no other buttons
|
||||
const buttons = actionsArea.querySelectorAll("button");
|
||||
|
||||
const hasTryAgainButton = Array.from(buttons).some((button) => {
|
||||
return !button.id?.includes("download");
|
||||
});
|
||||
|
||||
// fix: https://github.com/lencx/ChatGPT/issues/189
|
||||
if (buttons.length === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasTryAgainButton && buttons.length === 1) {
|
||||
return true;
|
||||
}
|
||||
@ -106,16 +113,18 @@ function addActionsButtons(actionsArea, TryAgainButton) {
|
||||
downloadThread({ as: Format.PDF });
|
||||
};
|
||||
actionsArea.appendChild(downloadPdfButton);
|
||||
const exportHtml = TryAgainButton.cloneNode(true);
|
||||
exportHtml.id = "download-html-button";
|
||||
downloadButton.setAttribute("share-ext", "true");
|
||||
// exportHtml.innerText = "Share Link";
|
||||
exportHtml.title = "Share Link";
|
||||
exportHtml.innerHTML = setIcon('link');
|
||||
exportHtml.onclick = () => {
|
||||
sendRequest();
|
||||
};
|
||||
actionsArea.appendChild(exportHtml);
|
||||
|
||||
// fix: https://github.com/lencx/ChatGPT/issues/126
|
||||
// const exportHtml = TryAgainButton.cloneNode(true);
|
||||
// exportHtml.id = "download-html-button";
|
||||
// downloadButton.setAttribute("share-ext", "true");
|
||||
// // exportHtml.innerText = "Share Link";
|
||||
// exportHtml.title = "Share Link";
|
||||
// exportHtml.innerHTML = setIcon('link');
|
||||
// exportHtml.onclick = () => {
|
||||
// sendRequest();
|
||||
// };
|
||||
// actionsArea.appendChild(exportHtml);
|
||||
}
|
||||
|
||||
function downloadThread({ as = Format.PNG } = {}) {
|
||||
@ -175,12 +184,27 @@ class Elements {
|
||||
this.thread = document.querySelector(
|
||||
"[class*='react-scroll-to-bottom']>[class*='react-scroll-to-bottom']>div"
|
||||
);
|
||||
|
||||
// fix: old chat https://github.com/lencx/ChatGPT/issues/185
|
||||
if (!this.thread) {
|
||||
this.thread = document.querySelector(
|
||||
"main .overflow-y-auto"
|
||||
);
|
||||
}
|
||||
|
||||
// h-full overflow-y-auto
|
||||
this.positionForm = document.querySelector("form").parentNode;
|
||||
// this.styledThread = document.querySelector("main");
|
||||
// this.threadContent = document.querySelector(".gAnhyd");
|
||||
this.scroller = Array.from(
|
||||
document.querySelectorAll('[class*="react-scroll-to"]')
|
||||
).filter((el) => el.classList.contains("h-full"))[0];
|
||||
|
||||
// fix: old chat
|
||||
if (!this.scroller) {
|
||||
this.scroller = document.querySelector('main .overflow-y-auto');
|
||||
}
|
||||
|
||||
this.hiddens = Array.from(document.querySelectorAll(".overflow-hidden"));
|
||||
this.images = Array.from(document.querySelectorAll("img[srcset]"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user