mirror of
https://github.com/klxf/eext-jiepei-helper.git
synced 2025-12-06 14:14:14 +08:00
modify check update target
This commit is contained in:
parent
ef521ec2b0
commit
c792a8c8fd
@ -2,6 +2,7 @@
|
||||
|
||||
1. 支持自动识别板子层数
|
||||
2. 更新依赖 pro-api-types
|
||||
3. 检查更新目标更改为 Github Releases
|
||||
|
||||
# 1.0.2
|
||||
|
||||
|
||||
@ -11,14 +11,14 @@
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/klxf/"
|
||||
"url": "https://github.com/klxf/eext-jiepei-helper"
|
||||
},
|
||||
"categories": "Other",
|
||||
"keywords": ["Helper"],
|
||||
"images": {
|
||||
"logo": "./images/logo.png"
|
||||
},
|
||||
"homepage": "https://extensions.oshwhub.com/item/fangs233/jiepei-helper",
|
||||
"homepage": "https://github.com/klxf/eext-jiepei-helper",
|
||||
"bugs": "https://github.com/klxf/eext-jiepei-helper/issues",
|
||||
"activationEvents": {},
|
||||
"entry": "./dist/index",
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>关于软件</title>
|
||||
<link rel="stylesheet" href="/iframe/css/index.css">
|
||||
<link rel="stylesheet" href="/iframe/css/index.css" />
|
||||
</head>
|
||||
<body class="bg-gray-100 flex items-center justify-center min-h-screen">
|
||||
<div class="min-h-screen bg-gray-100 flex items-center justify-center">
|
||||
@ -17,26 +17,18 @@
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center space-x-4 mt-auto">
|
||||
<a id="home" class="text-blue-600 hover:text-blue-800 text-sm transition duration-300 ease-in-out">
|
||||
🏠 扩展主页
|
||||
</a>
|
||||
<a id="bugs" class="text-blue-600 hover:text-blue-800 text-sm transition duration-300 ease-in-out">
|
||||
🐞 Bug反馈
|
||||
</a>
|
||||
<a id="check" class="text-blue-600 hover:text-blue-800 text-sm transition duration-300 ease-in-out">
|
||||
✨ 检查更新
|
||||
</a>
|
||||
<a id="home" class="text-blue-600 hover:text-blue-800 text-sm transition duration-300 ease-in-out"> 🏠 扩展主页 </a>
|
||||
<a id="bugs" class="text-blue-600 hover:text-blue-800 text-sm transition duration-300 ease-in-out"> 🐞 Bug反馈 </a>
|
||||
<a id="check" class="text-blue-600 hover:text-blue-800 text-sm transition duration-300 ease-in-out"> ✨ 检查更新 </a>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center text-[12px] text-gray-500 mt-2">
|
||||
本扩展使用 Apache-2.0 许可协议开源
|
||||
</div>
|
||||
<div class="flex justify-center text-[12px] text-gray-500 mt-2">本扩展使用 Apache-2.0 许可协议开源</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// 页面加载完成
|
||||
document.addEventListener('DOMContentLoaded', async function () {
|
||||
const file = await eda.sys_FileSystem.getExtensionFile("/extension.json");
|
||||
const file = await eda.sys_FileSystem.getExtensionFile('/extension.json');
|
||||
if (file) {
|
||||
const extensionData = JSON.parse(await file.text());
|
||||
document.getElementById('name').textContent = extensionData.displayName;
|
||||
@ -59,6 +51,40 @@
|
||||
|
||||
document.getElementById('check').addEventListener('click', function (event) {
|
||||
event.preventDefault();
|
||||
eda.sys_ClientUrl
|
||||
.request('https://api.github.com/repos/klxf/eext-jiepei-helper/releases/latest', 'GET')
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if (data && data.tag_name) {
|
||||
const latestVersion = data.tag_name.replace('v', '');
|
||||
const currentVersion = document.getElementById('version').textContent.replace('V', '');
|
||||
// 比较版本号,latestVersion 和 currentVersion
|
||||
const latestParts = latestVersion.split('.').map(Number);
|
||||
const currentParts = currentVersion.split('.').map(Number);
|
||||
let isNewVersionAvailable = false;
|
||||
for (let i = 0; i < Math.max(latestParts.length, currentParts.length); i++) {
|
||||
const latestPart = latestParts[i] || 0;
|
||||
const currentPart = currentParts[i] || 0;
|
||||
if (latestPart > currentPart) {
|
||||
isNewVersionAvailable = true;
|
||||
break;
|
||||
} else if (latestPart < currentPart) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isNewVersionAvailable) {
|
||||
eda.sys_Message.showToastMessage(`😋 有新版本可用: V${latestVersion}`, 'info');
|
||||
document.getElementById('tip').innerHTML =
|
||||
`<a href="${data.html_url}" target="_blank" class="text-blue-600 hover:text-blue-800">前往更新新版本</a>`;
|
||||
} else {
|
||||
eda.sys_Message.showToastMessage('👍 当前已是最新版本', 'success');
|
||||
}
|
||||
} else {
|
||||
eda.sys_Message.showToastMessage('🥺 获取版本信息失败', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
/* 已下架,弃用
|
||||
eda.sys_ClientUrl.request("https://extensions.oshwhub.com/api/v1/extensions/his_version_list?bizKey=188546598067642368", "GET")
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
@ -90,7 +116,8 @@
|
||||
eda.sys_Message.showToastMessage("🥺 获取版本信息失败", 'error');
|
||||
}
|
||||
});
|
||||
})
|
||||
*/
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user