Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c95bafd34f | ||
![]() |
a3791b599b | ||
![]() |
34e396271d | ||
![]() |
c3243503a7 | ||
![]() |
a16f898ed8 |
11 changed files with 70 additions and 9 deletions
|
@ -5,7 +5,7 @@ tmp_dir = "tmp"
|
|||
[build]
|
||||
args_bin = []
|
||||
bin = "tmp\\main.exe"
|
||||
cmd = "go build -o ./tmp/main.exe ./example"
|
||||
cmd = "go build -o ./tmp/main.exe ./examples/testbench"
|
||||
delay = 1000
|
||||
exclude_dir = ["assets", "tmp", "vendor", "testdata", "runtime/out", "node_modules", "dist"]
|
||||
exclude_file = []
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
tmp/
|
||||
out/
|
||||
*.exe
|
|
@ -9,7 +9,7 @@ Build modern, cross-platform desktop apps in HTML + Go from one codebase. It use
|
|||
- ⚡**Fast development**: Use *ANY* web framework for your UI. Tiramisu handles all the magic of making it work, for you.
|
||||
|
||||
## Installation
|
||||
`go install git.iwakura.rip/grng/tiramisu`
|
||||
`go get -u git.iwakura.rip/grng/tiramisu`
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
func main() {
|
||||
// create the webview instance
|
||||
app := tiramisu.New(tiramisu.Options{
|
||||
app := tiramisu.New(tiramisu.TiramisuOptions{
|
||||
Title: "Tiramisu Example",
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
|
|
|
@ -6,4 +6,4 @@ tasks:
|
|||
default:
|
||||
cmds:
|
||||
- bunx tsc -p ./runtime
|
||||
- go build -ldflags='-H windowsgui' ./example
|
||||
- go build -ldflags='-H windowsgui' ./examples/testbench
|
||||
|
|
6
examples/minimal/index.html
Normal file
6
examples/minimal/index.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>hello tiramisu!</h1>
|
||||
</body>
|
||||
</html>
|
24
examples/minimal/main.go
Normal file
24
examples/minimal/main.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
t "git.iwakura.rip/grng/tiramisu"
|
||||
webview "github.com/webview/webview_go"
|
||||
)
|
||||
|
||||
//go:embed index.html
|
||||
var html string
|
||||
|
||||
func main() {
|
||||
app := t.New(t.TiramisuOptions{
|
||||
Debug: true,
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
Title: "Tiramisu",
|
||||
Hints: webview.HintFixed,
|
||||
})
|
||||
|
||||
app.HTML(html)
|
||||
app.Run()
|
||||
}
|
11
runtime/out/preload.d.ts
vendored
Normal file
11
runtime/out/preload.d.ts
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
declare const tiramisu: {
|
||||
invoke: (name: string, ...args: any[]) => Promise<any>;
|
||||
fs: {
|
||||
readFile: (path: string) => Promise<string>;
|
||||
readDir: (path: string) => Promise<string[]>;
|
||||
exists: (path: string) => Promise<boolean>;
|
||||
};
|
||||
notifications: {
|
||||
notify: (message: string, ico?: string) => Promise<void>;
|
||||
};
|
||||
};
|
12
runtime/out/preload.js
Normal file
12
runtime/out/preload.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
const tiramisu = {
|
||||
invoke: window.__TIRAMISU_INTERNAL_invoke,
|
||||
fs: {
|
||||
readFile: window.__TIRAMISU_FILESYSTEM_readFile,
|
||||
readDir: window.__TIRAMISU_FILESYSTEM_readDir,
|
||||
exists: window.__TIRAMISU_INTERNAL_exists,
|
||||
},
|
||||
notifications: {
|
||||
notify: window.__TIRAMISU_NOTIFICATIONS_notify,
|
||||
},
|
||||
};
|
||||
window.tiramisu = tiramisu;
|
10
tiramisu.go
10
tiramisu.go
|
@ -40,15 +40,17 @@ func New(o TiramisuOptions) *Tiramisu {
|
|||
return t
|
||||
}
|
||||
|
||||
func (t *Tiramisu) Run(fn func()) {
|
||||
func (t *Tiramisu) Run(fns ...func()) {
|
||||
defer t.w.Destroy()
|
||||
t.w.Dispatch(func() {
|
||||
t.loadJSRuntime()
|
||||
t.loadGoRuntime()
|
||||
|
||||
for _, fn := range fns {
|
||||
if fn != nil {
|
||||
fn()
|
||||
}
|
||||
}
|
||||
})
|
||||
t.w.Run()
|
||||
}
|
||||
|
@ -95,6 +97,12 @@ func (t *Tiramisu) HTML(html string) {
|
|||
t.loadGoRuntime()
|
||||
}
|
||||
|
||||
func (t *Tiramisu) Navigate(url string) {
|
||||
t.w.Navigate(url)
|
||||
t.loadJSRuntime()
|
||||
t.loadGoRuntime()
|
||||
}
|
||||
|
||||
//go:embed runtime/out/*
|
||||
var runtimeFS embed.FS
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue