mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Misc documentation updates
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="example">
|
||||
<div class="example allow-select">
|
||||
<div class="{showCode ? 'code-title-open' : 'code-title-closed'}" on:click="{toggleExample}" >
|
||||
<span class="arrow">{showCode?'▼':'▶'}</span>
|
||||
Example Code
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: testcodeJs = "import { runtime } from '@wails/runtime';\nruntime.Log.Info('Platform from JS runtime: ' + runtime.System.Platform);";
|
||||
$: testcodeGo = '// runtime is given through WailsInit()\nruntime.Log.Info("Platform from Go runtime: " + runtime.System.Platform)';
|
||||
$: testcodeJs = "import { runtime } from '@wails/runtime';\nruntime.Log.Info('Platform from JS runtime: ' + runtime.System.Platform());";
|
||||
$: testcodeGo = '// runtime is given through WailsInit()\nruntime.Log.Info("Platform from Go runtime: " + runtime.System.Platform())';
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,11 +1,44 @@
|
||||
package main
|
||||
|
||||
import wails "github.com/wailsapp/wails/v2"
|
||||
import (
|
||||
"image"
|
||||
"os"
|
||||
|
||||
wails "github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/internal/runtime"
|
||||
)
|
||||
|
||||
type MyStruct struct {
|
||||
runtime *wails.Runtime
|
||||
image *runtime.Store
|
||||
}
|
||||
|
||||
func (l *MyStruct) ShowHelp() {
|
||||
l.runtime.Browser.Open("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
||||
func (n *Notepad) WailsInit(runtime *wails.Runtime) error {
|
||||
n.runtime = runtime
|
||||
n.image = runtime.Store.New("mainimage")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *MyStruct) LoadImage(filename string) error {
|
||||
|
||||
// Load filedata
|
||||
f, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
img, fmtName, err := image.DecodeConfig(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Sync the image data with the frontend
|
||||
n.image.Set(img)
|
||||
|
||||
// Get the size of the image
|
||||
n.runtime.Window.SetSize(img.Width, img.Height)
|
||||
|
||||
// Place window in center
|
||||
n.runtime.Window.Center()
|
||||
}
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
import { Log } from '@wails/runtime';
|
||||
import { Window } from '@wails/runtime';
|
||||
|
||||
function doSomeOperation() {
|
||||
// Do things
|
||||
let value = doSomething();
|
||||
Log.Print("A raw message");
|
||||
Log.Trace("I got: " + value);
|
||||
Log.Debug("A debug message");
|
||||
Log.Info("An Info message");
|
||||
Log.Warning("A Warning message");
|
||||
Log.Error("An Error message");
|
||||
}
|
||||
|
||||
function abort() {
|
||||
// Do some things
|
||||
Log.Fatal("I accidentally the whole application!");
|
||||
function resize(imageWidth, imageHeight) {
|
||||
Window.SetSize(imageWidth, imageHeight);
|
||||
Window.Center();
|
||||
}
|
||||
@@ -1,17 +1,6 @@
|
||||
import { Log } from '@wails/runtime';
|
||||
import { Browser } from '@wails/runtime';
|
||||
|
||||
function doSomeOperation() {
|
||||
// Do things
|
||||
let value = doSomething();
|
||||
Log.Print("A raw message");
|
||||
Log.Trace("I got: " + value);
|
||||
Log.Debug("A debug message");
|
||||
Log.Info("An Info message");
|
||||
Log.Warning("A Warning message");
|
||||
Log.Error("An Error message");
|
||||
}
|
||||
|
||||
function abort() {
|
||||
function showHelp() {
|
||||
// Do some things
|
||||
Log.Fatal("I accidentally the whole application!");
|
||||
Browser.Open("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Events } from '@wails/runtime';
|
||||
|
||||
let notes = [];
|
||||
|
||||
// Do some things
|
||||
Events.On("notes loaded", (newNotes) => {
|
||||
notes = newNotes;
|
||||
});
|
||||
// Respond to the unlock event 3 times
|
||||
Events.OnMultiple("unlock", (password) => {
|
||||
// Check password
|
||||
}, 3);
|
||||
|
||||
Reference in New Issue
Block a user