Misc documentation updates

This commit is contained in:
Lea Anthony
2020-11-20 14:45:35 +11:00
parent 5ba03937c3
commit 0422921dc7
6 changed files with 50 additions and 41 deletions

View File

@@ -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

View File

@@ -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>

View File

@@ -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()
}

View File

@@ -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();
}

View File

@@ -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")
}

View File

@@ -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);