add zqdgr

This commit is contained in:
Zoe
2024-11-16 04:30:29 -06:00
parent a458d9ae8c
commit dc6c6d85bf
6 changed files with 56 additions and 2 deletions

26
main.go
View File

@@ -40,6 +40,28 @@ var viewsFS embed.FS
//go:embed assets/**
var assetsFS embed.FS
var devContent string = `<script>
let host = window.location.hostname;
const socket = new WebSocket('ws://' + host + ':2067/ws');
socket.addEventListener('message', (event) => {
if (event.data === 'refresh') {
async function testPage() {
try {
let res = await fetch(window.location.href)
} catch (error) {
console.error(error);
setTimeout(testPage, 300);
return;
}
window.location.reload();
}
testPage();
}
});
</script>`
type Category struct {
ID int64 `json:"id"`
Name string `json:"name"`
@@ -483,6 +505,10 @@ func main() {
return string(css)
})
engine.AddFunc("devContent", func() string {
return devContent
})
router := fiber.New(fiber.Config{
Views: engine,
})