mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-17 08:05:51 +01:00
Merge pull request #20 from wailsapp/Update-execution-order-in-Headless-mode
Numerous fixes for headless mode.
This commit is contained in:
commit
8a3aec6866
3 changed files with 12 additions and 14 deletions
File diff suppressed because one or more lines are too long
|
|
@ -101,6 +101,10 @@
|
|||
}
|
||||
s.textContent = script;
|
||||
document.head.appendChild(s)
|
||||
if (script.indexOf("window.wails._.") == 0) {
|
||||
var elem = document.querySelector('#' + id);
|
||||
elem.parentNode.removeChild(elem);
|
||||
}
|
||||
}
|
||||
|
||||
function handleConnect() {
|
||||
|
|
@ -139,8 +143,13 @@
|
|||
}, 300);
|
||||
}
|
||||
|
||||
let idcounter = 0
|
||||
function generateID() {
|
||||
return "wails-" + idcounter++;
|
||||
}
|
||||
|
||||
function handleMessage(e) {
|
||||
addScript(e.data);
|
||||
addScript(e.data, generateID());
|
||||
}
|
||||
|
||||
// Key listener
|
||||
|
|
@ -169,7 +178,6 @@
|
|||
|
||||
connect();
|
||||
|
||||
|
||||
}());
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -125,16 +125,6 @@ func (h *Headless) start(conn *websocket.Conn) {
|
|||
h.injectCSS(h.frameworkCSS)
|
||||
}
|
||||
|
||||
// If given an HMTL fragment, mount it on #app
|
||||
// Otherwise, replace the html tag
|
||||
var injectHTML string
|
||||
if h.appConfig.isHTMLFragment {
|
||||
injectHTML = fmt.Sprintf("$('#app').html('%s')", h.appConfig.HTML)
|
||||
} else {
|
||||
injectHTML = fmt.Sprintf("$('html').html('%s')", h.appConfig.HTML)
|
||||
}
|
||||
h.evalJS(injectHTML)
|
||||
|
||||
// Inject user CSS
|
||||
if h.appConfig.CSS != "" {
|
||||
outputCSS := fmt.Sprintf("%.45s", h.appConfig.CSS)
|
||||
|
|
@ -274,7 +264,7 @@ func (h *Headless) NotifyEvent(event *eventData) error {
|
|||
}
|
||||
}
|
||||
|
||||
message := fmt.Sprintf("wails._.notify('%s','%s')", event.Name, data)
|
||||
message := fmt.Sprintf("window.wails._.notify('%s','%s')", event.Name, data)
|
||||
return h.evalJS(message)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue