|
1 | 1 | import { exec, spawn, toast } from 'kernelsu-alt'; |
2 | | -import { modDir, persistDir, superkey, initInfo, MAX_CHUNK_SIZE } from '../index.js'; |
| 2 | +import { modDir, persistDir, superkey, initInfo, MAX_CHUNK_SIZE, linkRedirect } from '../index.js'; |
3 | 3 |
|
4 | 4 | let allKpms = []; |
5 | 5 | let searchQuery = ''; |
| 6 | +let clickCount = 0; |
| 7 | +let lastClickTime = 0; |
6 | 8 |
|
7 | 9 | async function getKpmInfo(path) { |
8 | 10 | const result = await exec(`kptools -l -M "${path}"`, { env: { PATH: `${modDir}/bin` } }); |
@@ -255,7 +257,20 @@ async function uploadFile(file, targetPath, onProgress, signal) { |
255 | 257 | } |
256 | 258 | } |
257 | 259 |
|
| 260 | +function checkFileUploadApi() { |
| 261 | + // If we reach here 3 times in 2 seconds, upload api is likely available |
| 262 | + const currentTime = Date.now(); |
| 263 | + clickCount = (currentTime - lastClickTime > 2000) ? 1 : clickCount + 1; |
| 264 | + lastClickTime = currentTime; |
| 265 | + |
| 266 | + if (clickCount === 3) { |
| 267 | + clickCount = 0; |
| 268 | + linkRedirect('https://github.com/KOWX712/KsuWebUIStandalone/releases/latest'); |
| 269 | + } |
| 270 | +} |
| 271 | + |
258 | 272 | async function handleFileUpload(accept, containerId, onSelected) { |
| 273 | + checkFileUploadApi(); |
259 | 274 | const input = document.createElement('input'); |
260 | 275 | input.type = 'file'; |
261 | 276 | input.accept = accept; |
@@ -404,6 +419,14 @@ export function initKPMPage() { |
404 | 419 | kpmItemMap.clear(); |
405 | 420 | refreshKpmList(); |
406 | 421 | }; |
| 422 | + |
| 423 | + const controlDialog = document.getElementById('control-dialog'); |
| 424 | + const controlTextField = controlDialog.querySelector('md-outlined-text-field'); |
| 425 | + controlTextField.addEventListener('input', () => { |
| 426 | + controlDialog.querySelector('.confirm').disabled = !controlTextField.value; |
| 427 | + }); |
| 428 | + |
| 429 | + document.getElementById('load').onclick = () => uploadAndLoadModule(); |
407 | 430 | } |
408 | 431 |
|
409 | | -export { loadModule, refreshKpmList, uploadAndLoadModule, handleFileUpload, uploadFile } |
| 432 | +export { loadModule, refreshKpmList, handleFileUpload, uploadFile } |
0 commit comments