Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
4336d60
1
Parent(s):
d65b955
feat: 调整更新中样式
Browse files- assets/custom.css +9 -0
- assets/custom.js +27 -11
- assets/html/update.html +3 -0
assets/custom.css
CHANGED
|
@@ -115,6 +115,15 @@ footer {
|
|
| 115 |
span.hideK {
|
| 116 |
display: none;
|
| 117 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
/* user_info */
|
| 119 |
#user_info.block {
|
| 120 |
white-space: nowrap;
|
|
|
|
| 115 |
span.hideK {
|
| 116 |
display: none;
|
| 117 |
}
|
| 118 |
+
#updating-info.hideK {
|
| 119 |
+
display: none;
|
| 120 |
+
}
|
| 121 |
+
#updating-info {
|
| 122 |
+
margin: 12px 0px 20px;
|
| 123 |
+
text-align: start;
|
| 124 |
+
width: 100%;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
/* user_info */
|
| 128 |
#user_info.block {
|
| 129 |
white-space: nowrap;
|
assets/custom.js
CHANGED
|
@@ -73,6 +73,13 @@ const usingLatest_i18n = {
|
|
| 73 |
'sv': "Du använder den senaste versionen!"
|
| 74 |
};
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
const updateSuccess_i18n = {
|
| 77 |
'zh': "更新成功,请重启本程序。",
|
| 78 |
'en': "Updated successfully, please restart this program.",
|
|
@@ -532,15 +539,16 @@ var statusObserver = new MutationObserver(function (mutationsList) {
|
|
| 532 |
if (mutation.type === 'attributes' || mutation.type === 'childList') {
|
| 533 |
if (statusDisplay.innerHTML.includes('<span id="update-status"')) {
|
| 534 |
if (getUpdateStatus() === "success") {
|
| 535 |
-
|
| 536 |
noUpdateHtml();
|
| 537 |
localStorage.setItem('isLatestVersion', 'true');
|
| 538 |
isLatestVersion = true;
|
| 539 |
} else if (getUpdateStatus() === "failure") {
|
| 540 |
-
|
| 541 |
-
} else {
|
| 542 |
-
|
| 543 |
}
|
|
|
|
| 544 |
}
|
| 545 |
}
|
| 546 |
}
|
|
@@ -621,10 +629,12 @@ async function getLatestRelease() {
|
|
| 621 |
}
|
| 622 |
|
| 623 |
var releaseNoteElement = document.getElementById('release-note-content');
|
|
|
|
| 624 |
async function updateLatestVersion() {
|
| 625 |
const currentVersionElement = document.getElementById('current-version');
|
| 626 |
const latestVersionElement = document.getElementById('latest-version-title');
|
| 627 |
releaseNoteElement = document.getElementById('release-note-content');
|
|
|
|
| 628 |
const currentVersion = currentVersionElement.textContent;
|
| 629 |
const versionTime = document.getElementById('version-time').innerText;
|
| 630 |
const localVersionTime = versionTime !== "unknown" ? (new Date(versionTime)).getTime() : 0;
|
|
@@ -658,8 +668,10 @@ function getUpdateInfo() {
|
|
| 658 |
}
|
| 659 |
function bgUpdateChuanhu() {
|
| 660 |
updateChuanhuBtn.click();
|
| 661 |
-
|
| 662 |
-
|
|
|
|
|
|
|
| 663 |
statusObserver.observe(statusDisplay, { childList: true, subtree: true, characterData: true});
|
| 664 |
}
|
| 665 |
function cancelUpdate() {
|
|
@@ -672,6 +684,9 @@ function openUpdateToast() {
|
|
| 672 |
function closeUpdateToast() {
|
| 673 |
updateToast.style.setProperty('top', '-500px');
|
| 674 |
showingUpdateInfo = false;
|
|
|
|
|
|
|
|
|
|
| 675 |
}
|
| 676 |
function manualCheckUpdate() {
|
| 677 |
openUpdateToast();
|
|
@@ -682,24 +697,25 @@ function manualCheckUpdate() {
|
|
| 682 |
function noUpdate() {
|
| 683 |
localStorage.setItem('isLatestVersion', 'true');
|
| 684 |
isLatestVersion = true;
|
| 685 |
-
const releaseNoteWrap = document.getElementById('release-note-wrap');
|
| 686 |
-
releaseNoteWrap.style.setProperty('display', 'none');
|
| 687 |
noUpdateHtml();
|
| 688 |
}
|
| 689 |
function noUpdateHtml() {
|
| 690 |
const versionInfoElement = document.getElementById('version-info-title');
|
| 691 |
const gotoUpdateBtn = document.getElementById('goto-update-btn');
|
| 692 |
const closeUpdateBtn = document.getElementById('close-update-btn');
|
|
|
|
|
|
|
| 693 |
versionInfoElement.textContent = usingLatest_i18n.hasOwnProperty(language) ? usingLatest_i18n[language] : usingLatest_i18n['en'];
|
| 694 |
gotoUpdateBtn.classList.add('hideK');
|
| 695 |
closeUpdateBtn.classList.remove('hideK');
|
| 696 |
}
|
|
|
|
| 697 |
function getUpdateStatus() {
|
| 698 |
-
|
| 699 |
if (updateStatus) {
|
| 700 |
-
return updateStatus.innerText
|
| 701 |
} else {
|
| 702 |
-
return "unknown"
|
| 703 |
}
|
| 704 |
}
|
| 705 |
|
|
|
|
| 73 |
'sv': "Du använder den senaste versionen!"
|
| 74 |
};
|
| 75 |
|
| 76 |
+
const updatingMsg_i18n = {
|
| 77 |
+
'zh': "正在尝试更新...",
|
| 78 |
+
'en': "Trying to update...",
|
| 79 |
+
'ja': "更新を試みています...",
|
| 80 |
+
'ko': "업데이트를 시도 중...",
|
| 81 |
+
'sv': "Försöker uppdatera..."
|
| 82 |
+
}
|
| 83 |
const updateSuccess_i18n = {
|
| 84 |
'zh': "更新成功,请重启本程序。",
|
| 85 |
'en': "Updated successfully, please restart this program.",
|
|
|
|
| 539 |
if (mutation.type === 'attributes' || mutation.type === 'childList') {
|
| 540 |
if (statusDisplay.innerHTML.includes('<span id="update-status"')) {
|
| 541 |
if (getUpdateStatus() === "success") {
|
| 542 |
+
updatingInfoElement.innerText = updateSuccess_i18n.hasOwnProperty(language) ? updateSuccess_i18n[language] : updateSuccess_i18n['en'];
|
| 543 |
noUpdateHtml();
|
| 544 |
localStorage.setItem('isLatestVersion', 'true');
|
| 545 |
isLatestVersion = true;
|
| 546 |
} else if (getUpdateStatus() === "failure") {
|
| 547 |
+
updatingInfoElement.innerText = updateFailure_i18n.hasOwnProperty(language) ? updateFailure_i18n[language] : updateFailure_i18n['en'];
|
| 548 |
+
} else if (getUpdateStatus() != "") {
|
| 549 |
+
updatingInfoElement.innerText = getUpdateStatus();
|
| 550 |
}
|
| 551 |
+
updateStatus.parentNode.removeChild(updateStatus);
|
| 552 |
}
|
| 553 |
}
|
| 554 |
}
|
|
|
|
| 629 |
}
|
| 630 |
|
| 631 |
var releaseNoteElement = document.getElementById('release-note-content');
|
| 632 |
+
var updatingInfoElement = document.getElementById('updating-info');
|
| 633 |
async function updateLatestVersion() {
|
| 634 |
const currentVersionElement = document.getElementById('current-version');
|
| 635 |
const latestVersionElement = document.getElementById('latest-version-title');
|
| 636 |
releaseNoteElement = document.getElementById('release-note-content');
|
| 637 |
+
updatingInfoElement = document.getElementById('updating-info');
|
| 638 |
const currentVersion = currentVersionElement.textContent;
|
| 639 |
const versionTime = document.getElementById('version-time').innerText;
|
| 640 |
const localVersionTime = versionTime !== "unknown" ? (new Date(versionTime)).getTime() : 0;
|
|
|
|
| 668 |
}
|
| 669 |
function bgUpdateChuanhu() {
|
| 670 |
updateChuanhuBtn.click();
|
| 671 |
+
updatingInfoElement.innerText = updatingMsg_i18n.hasOwnProperty(language) ? updatingMsg_i18n[language] : updatingMsg_i18n['en'];
|
| 672 |
+
updatingInfoElement.classList.remove('hideK');
|
| 673 |
+
const releaseNoteWrap = document.getElementById('release-note-wrap');
|
| 674 |
+
releaseNoteWrap.style.setProperty('display', 'none');
|
| 675 |
statusObserver.observe(statusDisplay, { childList: true, subtree: true, characterData: true});
|
| 676 |
}
|
| 677 |
function cancelUpdate() {
|
|
|
|
| 684 |
function closeUpdateToast() {
|
| 685 |
updateToast.style.setProperty('top', '-500px');
|
| 686 |
showingUpdateInfo = false;
|
| 687 |
+
if (updatingInfoElement.classList.contains('hideK') === false) {
|
| 688 |
+
updatingInfoElement.classList.add('hideK');
|
| 689 |
+
}
|
| 690 |
}
|
| 691 |
function manualCheckUpdate() {
|
| 692 |
openUpdateToast();
|
|
|
|
| 697 |
function noUpdate() {
|
| 698 |
localStorage.setItem('isLatestVersion', 'true');
|
| 699 |
isLatestVersion = true;
|
|
|
|
|
|
|
| 700 |
noUpdateHtml();
|
| 701 |
}
|
| 702 |
function noUpdateHtml() {
|
| 703 |
const versionInfoElement = document.getElementById('version-info-title');
|
| 704 |
const gotoUpdateBtn = document.getElementById('goto-update-btn');
|
| 705 |
const closeUpdateBtn = document.getElementById('close-update-btn');
|
| 706 |
+
const releaseNoteWrap = document.getElementById('release-note-wrap');
|
| 707 |
+
releaseNoteWrap.style.setProperty('display', 'none');
|
| 708 |
versionInfoElement.textContent = usingLatest_i18n.hasOwnProperty(language) ? usingLatest_i18n[language] : usingLatest_i18n['en'];
|
| 709 |
gotoUpdateBtn.classList.add('hideK');
|
| 710 |
closeUpdateBtn.classList.remove('hideK');
|
| 711 |
}
|
| 712 |
+
var updateStatus = null;
|
| 713 |
function getUpdateStatus() {
|
| 714 |
+
updateStatus = statusDisplay.querySelector("#update-status");
|
| 715 |
if (updateStatus) {
|
| 716 |
+
return updateStatus.innerText;
|
| 717 |
} else {
|
| 718 |
+
return "unknown";
|
| 719 |
}
|
| 720 |
}
|
| 721 |
|
assets/html/update.html
CHANGED
|
@@ -8,6 +8,9 @@
|
|
| 8 |
Latest Version: <a href="https://github.com/gaizhenbiao/chuanhuchatgpt/releases/latest" target="_blank"
|
| 9 |
id="latest-version-title" style="text-decoration: none;">getting latest version...</a>
|
| 10 |
</p>
|
|
|
|
|
|
|
|
|
|
| 11 |
<div id="release-note-wrap">
|
| 12 |
<div class="release-note-content" id="release-note-content">
|
| 13 |
Getting Release Note...
|
|
|
|
| 8 |
Latest Version: <a href="https://github.com/gaizhenbiao/chuanhuchatgpt/releases/latest" target="_blank"
|
| 9 |
id="latest-version-title" style="text-decoration: none;">getting latest version...</a>
|
| 10 |
</p>
|
| 11 |
+
<p id="updating-info" class="hideK">
|
| 12 |
+
Getting update...
|
| 13 |
+
</p>
|
| 14 |
<div id="release-note-wrap">
|
| 15 |
<div class="release-note-content" id="release-note-content">
|
| 16 |
Getting Release Note...
|