mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
[v2] window.backend -> window.go
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
let greeting = "";
|
||||
|
||||
function greet() {
|
||||
window.backend.main.App.Greet(name).then((result) => {
|
||||
window.go.main.App.Greet(name).then((result) => {
|
||||
greeting = result;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import {ready} from '@wails/runtime';
|
||||
|
||||
ready( () => {
|
||||
@@ -13,7 +12,7 @@ ready( () => {
|
||||
let name = nameElement.value;
|
||||
|
||||
// Call App.Greet(name)
|
||||
window.backend.main.App.Greet(name).then((result) => {
|
||||
window.go.main.App.Greet(name).then((result) => {
|
||||
// Update result with data back from App.Greet()
|
||||
document.getElementById("result").innerText = result;
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ func (b *Bindings) GenerateBackendJS(targetfile string) error {
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
const backend = {`)
|
||||
const go = {`)
|
||||
output.WriteString("\n")
|
||||
|
||||
var sortedPackageNames slicer.StringSlicer
|
||||
@@ -82,7 +82,7 @@ const backend = {`)
|
||||
argsString := args.Join(", ")
|
||||
output.WriteString(fmt.Sprintf(" \"%s\": (%s) => {", methodName, argsString))
|
||||
output.WriteString("\n")
|
||||
output.WriteString(fmt.Sprintf(" return window.backend.%s.%s.%s(%s);", packageName, structName, methodName, argsString))
|
||||
output.WriteString(fmt.Sprintf(" return window.go.%s.%s.%s(%s);", packageName, structName, methodName, argsString))
|
||||
output.WriteString("\n")
|
||||
output.WriteString(fmt.Sprintf(" },"))
|
||||
output.WriteString("\n")
|
||||
@@ -98,7 +98,7 @@ const backend = {`)
|
||||
})
|
||||
|
||||
output.WriteString(`};
|
||||
export default backend;`)
|
||||
export default go;`)
|
||||
output.WriteString("\n")
|
||||
|
||||
dir := filepath.Dir(targetfile)
|
||||
|
||||
@@ -11,7 +11,7 @@ The electron alternative for Go
|
||||
|
||||
import {Call} from './calls';
|
||||
|
||||
window.backend = {};
|
||||
window.go = {};
|
||||
|
||||
export function SetBindings(bindingsMap) {
|
||||
try {
|
||||
@@ -20,24 +20,24 @@ export function SetBindings(bindingsMap) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
// Initialise the backend map
|
||||
window.backend = window.backend || {};
|
||||
// Initialise the bindings map
|
||||
window.go = window.go || {};
|
||||
|
||||
// Iterate package names
|
||||
Object.keys(bindingsMap).forEach((packageName) => {
|
||||
|
||||
// Create inner map if it doesn't exist
|
||||
window.backend[packageName] = window.backend[packageName] || {};
|
||||
window.go[packageName] = window.go[packageName] || {};
|
||||
|
||||
// Iterate struct names
|
||||
Object.keys(bindingsMap[packageName]).forEach((structName) => {
|
||||
|
||||
// Create inner map if it doesn't exist
|
||||
window.backend[packageName][structName] = window.backend[packageName][structName] || {};
|
||||
window.go[packageName][structName] = window.go[packageName][structName] || {};
|
||||
|
||||
Object.keys(bindingsMap[packageName][structName]).forEach((methodName) => {
|
||||
|
||||
window.backend[packageName][structName][methodName] = function () {
|
||||
window.go[packageName][structName][methodName] = function () {
|
||||
|
||||
// No timeout by default
|
||||
let timeout = 0;
|
||||
|
||||
@@ -414,7 +414,7 @@ func ParseProject(projectPath string) (BoundStructs, error) {
|
||||
inputNames = inputNames[:len(inputNames)-2]
|
||||
}
|
||||
println(" ", m.Name+": function("+inputNames+") {")
|
||||
println(" return window.backend." + s.Name + "." + m.Name + "(" + inputNames + ");")
|
||||
println(" return window.go." + s.Name + "." + m.Name + "(" + inputNames + ");")
|
||||
print(" }")
|
||||
if methodCount < noOfMethods-1 {
|
||||
print(",")
|
||||
|
||||
@@ -11,7 +11,7 @@ The electron alternative for Go
|
||||
|
||||
import {Call} from './calls';
|
||||
|
||||
window.backend = {};
|
||||
window.go = {};
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,23 +46,23 @@ export function SetBindings(bindingsMap) {
|
||||
}
|
||||
|
||||
// Initialise the backend map
|
||||
window.backend = window.backend || {};
|
||||
window.go = window.go || {};
|
||||
|
||||
// Iterate package names
|
||||
Object.keys(bindingsMap).forEach((packageName) => {
|
||||
|
||||
// Create inner map if it doesn't exist
|
||||
window.backend[packageName] = window.backend[packageName] || {};
|
||||
window.go[packageName] = window.go[packageName] || {};
|
||||
|
||||
// Iterate struct names
|
||||
Object.keys(bindingsMap[packageName]).forEach((structName) => {
|
||||
|
||||
// Create inner map if it doesn't exist
|
||||
window.backend[packageName][structName] = window.backend[packageName][structName] || {};
|
||||
window.go[packageName][structName] = window.go[packageName][structName] || {};
|
||||
|
||||
Object.keys(bindingsMap[packageName][structName]).forEach((methodName) => {
|
||||
|
||||
window.backend[packageName][structName][methodName] = function () {
|
||||
window.go[packageName][structName][methodName] = function () {
|
||||
|
||||
// No timeout by default
|
||||
let timeout = 0;
|
||||
|
||||
@@ -16,8 +16,8 @@ import {AddIPCListener, SendMessage} from 'ipc';
|
||||
import * as Platform from 'platform';
|
||||
|
||||
export function Init() {
|
||||
// Backend is where the Go struct wrappers get bound to
|
||||
window.backend = {};
|
||||
// Where the Go struct wrappers get bound to
|
||||
window.go = {};
|
||||
|
||||
// Initialise global if not already
|
||||
window.wails = {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
interface Window {
|
||||
|
||||
backend: {
|
||||
go: {
|
||||
|
||||
{{- range . }}{{$packageName:=.Name}}
|
||||
{{- if .HasBoundStructs }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"name": "go",
|
||||
"version": "1.0.0",
|
||||
"description": "Auto generated module wrapping your Wails backend",
|
||||
"main": "index.js",
|
||||
|
||||
Reference in New Issue
Block a user