add zqdgr
This commit is contained in:
26
main.go
26
main.go
@@ -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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user