Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
b4415113
Commit
b4415113
authored
Jun 22, 2024
by
Timothy J. Baek
Browse files
enh: wake lock
parent
3af8c5b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
src/routes/+layout.svelte
src/routes/+layout.svelte
+27
-0
No files found.
src/routes/+layout.svelte
View file @
b4415113
...
@@ -36,6 +36,8 @@
...
@@ -36,6 +36,8 @@
let loaded = false;
let loaded = false;
const BREAKPOINT = 768;
const BREAKPOINT = 768;
let wakeLock = null;
onMount(async () => {
onMount(async () => {
theme.set(localStorage.theme);
theme.set(localStorage.theme);
...
@@ -50,6 +52,31 @@
...
@@ -50,6 +52,31 @@
window.addEventListener('resize', onResize);
window.addEventListener('resize', onResize);
const setWakeLock = async () => {
try {
wakeLock = await navigator.wakeLock.request('screen');
} catch (err) {
// The Wake Lock request has failed - usually system related, such as battery.
console.log(err);
}
wakeLock.addEventListener('release', () => {
// the wake lock has been released
console.log('Wake Lock released');
});
};
if ('wakeLock' in navigator) {
await setWakeLock();
document.addEventListener('visibilitychange', async () => {
// Re-request the wake lock if the document becomes visible
if (wakeLock !== null && document.visibilityState === 'visible') {
await setWakeLock();
}
});
}
let backendConfig = null;
let backendConfig = null;
try {
try {
backendConfig = await getBackendConfig();
backendConfig = await getBackendConfig();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment