mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Update example
This commit is contained in:
parent
ae2936927d
commit
23412656de
2 changed files with 18 additions and 17 deletions
|
|
@ -6,10 +6,10 @@
|
|||
<link rel="stylesheet" href="/style.css">
|
||||
<script type="module" src="/wails/runtime.js"></script>
|
||||
<script type="module">
|
||||
import * as sqlite from './bindings/github.com/wailsapp/wails/v3/pkg/services/sqlite/service.js';
|
||||
import * as kvstore from './bindings/github.com/wailsapp/wails/v3/pkg/services/kvstore/keyvaluestore.js';
|
||||
import {Debug, Info, Warning, Error} from './bindings/github.com/wailsapp/wails/v3/pkg/services/log/loggerservice.js';
|
||||
import * as hash from './bindings/github.com/wailsapp/wails/v3/examples/services/hashes/service.js';
|
||||
import { Service as sqlite } from './bindings/github.com/wailsapp/wails/v3/pkg/services/sqlite/index.js';
|
||||
import { Service as kvstore } from './bindings/github.com/wailsapp/wails/v3/pkg/services/kvstore/index.js';
|
||||
import { Service as logger } from './bindings/github.com/wailsapp/wails/v3/pkg/services/log/index.js';
|
||||
import { Service as hash } from './bindings/github.com/wailsapp/wails/v3/examples/services/hashes/index.js';
|
||||
|
||||
function runHash() {
|
||||
let hashstring = document.getElementById("hashstring").value;
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
let method = sqlite.Execute;
|
||||
let isSelect = false;
|
||||
if (query.toLowerCase().startsWith("select ")) {
|
||||
method = sqlite.Select;
|
||||
method = sqlite.Query;
|
||||
isSelect = true;
|
||||
}
|
||||
method(query).then((result) => {
|
||||
|
|
@ -146,16 +146,16 @@
|
|||
// Call the appropriate logging function based on the log level
|
||||
switch(logLevel) {
|
||||
case 'Debug':
|
||||
Debug(message);
|
||||
logger.Debug(message);
|
||||
break;
|
||||
case 'Info':
|
||||
Info(message);
|
||||
logger.Info(message);
|
||||
break;
|
||||
case 'Warning':
|
||||
Warning(message);
|
||||
logger.Warning(message);
|
||||
break;
|
||||
case 'Error':
|
||||
Error(message);
|
||||
logger.Error(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@ package main
|
|||
|
||||
import (
|
||||
"embed"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v3/examples/services/hashes"
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"github.com/wailsapp/wails/v3/pkg/services/fileserver"
|
||||
"github.com/wailsapp/wails/v3/pkg/services/kvstore"
|
||||
"github.com/wailsapp/wails/v3/pkg/services/log"
|
||||
"github.com/wailsapp/wails/v3/pkg/services/sqlite"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
//go:embed assets/*
|
||||
|
|
@ -35,15 +36,15 @@ func main() {
|
|||
LogLevel: slog.LevelDebug,
|
||||
Services: []application.Service{
|
||||
application.NewService(hashes.New()),
|
||||
application.NewService(sqlite.New(&sqlite.Config{
|
||||
DBFile: "test.db",
|
||||
application.NewService(sqlite.NewWithConfig(&sqlite.Config{
|
||||
DBSource: "test.db",
|
||||
})),
|
||||
application.NewService(kvstore.New(&kvstore.Config{
|
||||
application.NewService(kvstore.NewWithConfig(&kvstore.Config{
|
||||
Filename: "store.json",
|
||||
AutoSave: true,
|
||||
})),
|
||||
application.NewService(log.New()),
|
||||
application.NewServiceWithOptions(fileserver.New(&fileserver.Config{
|
||||
application.NewServiceWithOptions(fileserver.NewWithConfig(&fileserver.Config{
|
||||
RootPath: rootPath,
|
||||
}), application.ServiceOptions{
|
||||
Route: "/files",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue