初始提交: 配置管理面板 (Vite 8 + Svelte 5 + Bulma)
This commit is contained in:
23
src/pages/DevicePage.svelte
Normal file
23
src/pages/DevicePage.svelte
Normal file
@@ -0,0 +1,23 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { getDevice, putDevice } from '../lib/api.js';
|
||||
|
||||
let config = $state({});
|
||||
let loading = $state(false);
|
||||
let error = $state(null);
|
||||
|
||||
onMount(async () => {
|
||||
loading = true;
|
||||
try {
|
||||
const data = await getDevice();
|
||||
config = { ...data };
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
});
|
||||
|
||||
function handleSave(event: Event) {
|
||||
event.preventDefault();
|
||||
putDevice(config).then(() => window.location.reload());
|
||||
}
|
||||
Reference in New Issue
Block a user