mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2024-11-11 02:10:11 +01:00
Merge branch 'main' into main
This commit is contained in:
commit
f5628f16d9
@ -20,10 +20,35 @@ async function getLatestReleaseVersion() {
|
|||||||
const url = "https://api.github.com/repos/Stirling-Tools/Stirling-PDF/releases/latest";
|
const url = "https://api.github.com/repos/Stirling-Tools/Stirling-PDF/releases/latest";
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
const data = await response.json();
|
if (response.status === 200) {
|
||||||
return data.tag_name ? data.tag_name.substring(1) : "";
|
const data = await response.json();
|
||||||
|
return data.tag_name ? data.tag_name.substring(1) : "";
|
||||||
|
} else {
|
||||||
|
// If the status is not 200, try to get the version from build.gradle
|
||||||
|
return await getCurrentVersionFromBypass();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch latest version:", error);
|
console.error("Failed to fetch latest version from GitHub:", error);
|
||||||
|
// If an error occurs, try to get the version from build.gradle
|
||||||
|
return await getCurrentVersionFromBypass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getCurrentVersionFromBypass() {
|
||||||
|
const url = "https://raw.githubusercontent.com/Stirling-Tools/Stirling-PDF/main/build.gradle";
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (response.status === 200) {
|
||||||
|
const text = await response.text();
|
||||||
|
const versionRegex = /version\s*=\s*['"](\d+\.\d+\.\d+)['"]/;
|
||||||
|
const match = versionRegex.exec(text);
|
||||||
|
if (match) {
|
||||||
|
return match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("Version number not found");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch latest version from build.gradle:", error);
|
||||||
return ""; // Return an empty string if the fetch fails
|
return ""; // Return an empty string if the fetch fails
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@
|
|||||||
|
|
||||||
<a href="swagger-ui/index.html" class="btn btn-sm btn-outline-primary mx-1" role="button"
|
<a href="swagger-ui/index.html" class="btn btn-sm btn-outline-primary mx-1" role="button"
|
||||||
target="_blank">API</a>
|
target="_blank">API</a>
|
||||||
<a th:if="${@shouldShow}" href="https://github.com/Stirling-Tools/Stirling-PDF/releases"
|
<a href="https://github.com/Stirling-Tools/Stirling-PDF/releases"
|
||||||
class="btn btn-sm btn-outline-primary mx-1" id="update-btn" th:utext="#{settings.update}" role="button"
|
class="btn btn-sm btn-outline-primary mx-1" id="update-btn" th:utext="#{settings.update}" role="button"
|
||||||
target="_blank"></a>
|
target="_blank"></a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user