add: track webui error and log directly into error history (may not working)

This commit is contained in:
RainyXeon
2024-07-10 17:28:50 +07:00
committed by ThePedroo
parent 0818f0ade6
commit ffd0e36118
5 changed files with 21 additions and 2 deletions

View File

@@ -170,6 +170,7 @@ androidComponents.onVariants { variant ->
set.add(Pair(root.file("webroot/js/language.js").asFile, null))
set.add(Pair(root.file("webroot/js/light.icon.js").asFile, null))
set.add(Pair(root.file("webroot/js/restoreError.js").asFile, null))
set.add(Pair(root.file("webroot/js/webuiError.js").asFile, null))
set.add(Pair(root.file("webroot/js/list/module.js").asFile, null))
set.add(Pair(root.file("webroot/js/list/settings.js").asFile, null))

View File

@@ -121,6 +121,7 @@ extract "$ZIPFILE" 'webroot/js/theme.js' "$MODPATH/webroot/js" true
extract "$ZIPFILE" 'webroot/js/language.js' "$MODPATH/webroot/js" true
extract "$ZIPFILE" 'webroot/js/light.icon.js' "$MODPATH/webroot/js/list" true
extract "$ZIPFILE" 'webroot/js/restoreError.js' "$MODPATH/webroot/js/list" true
extract "$ZIPFILE" 'webroot/js/webuiError.js' "$MODPATH/webroot/js/list" true
extract "$ZIPFILE" 'webroot/js/list/module.js' "$MODPATH/webroot/js/list" true
extract "$ZIPFILE" 'webroot/js/list/settings.js' "$MODPATH/webroot/js/list" true

View File

@@ -6,6 +6,8 @@
<meta name="viewport" content="viewport-fit=cover" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="js/theme.js" type="module"></script>
<script src="js/restoreError.js" type="module"></script>
<script src="js/webuiError.js" type="module"></script>
<script src="js/list/module.js" type="module"></script>
<script src="js/list/settings.js" type="module"></script>
<script src="js/list/language.js" type="module"></script>
@@ -13,7 +15,6 @@
<script src="js/main.js" type="module"></script>
<script src="js/modal/language.js" type="module"></script>
<script src="js/modal/errorHistory.js" type="module"></script>
<script src="js/restoreError.js" type="module"></script>
<link rel="stylesheet" href="css/fonts.css">
<link rel="stylesheet" href="css/index.css">
</head>

View File

@@ -1,5 +1,6 @@
import { fullScreen, exec, toast } from './kernelsu.js'
import { setNewLanguage, getTranslations } from './language.js'
import { sendError } from './webuiError.js'
(async () => {
const EXPECTED = 1
@@ -156,7 +157,9 @@ import { setNewLanguage, getTranslations } from './language.js'
} else {
toast(`${translations.cmdErrors.find}: ${findModulesCmd.stderr}`)
}
})()
})().catch(err => {
sendError(err)
})
function setLangData(mode) {
localStorage.setItem('/system/language', mode)

13
webroot/js/webuiError.js Normal file
View File

@@ -0,0 +1,13 @@
window.addEventListener('error', (e) => {
console.log(e.stack)
const previousError = localStorage.getItem('/system/error')
localStorage.setItem('/system/error', previousError + `\n` + e.stack)
document.getElementById('errorh_panel').innerHTML += e.stack
})
export function sendError(e) {
console.log(e.stack)
const previousError = localStorage.getItem('/system/error')
localStorage.setItem('/system/error', previousError + `\n` + e.stack)
document.getElementById('errorh_panel').innerHTML += e.stack
}