5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 07:40:17 +08:00

Merge pull request #29 from wailsapp/Move-headless-capability-into-own-library

Move headless capability into own library
This commit is contained in:
Lea Anthony 2019-01-29 08:37:33 +11:00 committed by GitHub
commit cd8b4f088f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -127,34 +127,7 @@ func (h *Headless) sendMessage(conn *websocket.Conn, msg string) {
} }
} }
func (h *Headless) start(conn *websocket.Conn) { func (h *Headless) injectAllFiles() {
// set external.invoke
h.log.Infof("Connected to frontend.")
h.log.Infof("Mode = %s", h.connectionType)
wailsRuntime := BoxString(&defaultAssets, "wails.js")
h.evalJS(wailsRuntime, wailsRuntimeMessage)
if !h.bridgeMode {
// Inject jquery
jquery := BoxString(&defaultAssets, "jquery.3.3.1.min.js")
h.evalJS(jquery, jsMessage)
}
// Inject the initial JS
for _, js := range h.initialisationJS {
h.sendMessage(h.theConnection, js)
}
// Inject bindings
for _, binding := range h.bindingCache {
h.evalJS(binding, bindingMessage)
}
// In Bridge mode, we only send the wails runtime and bindings
// so ignore this whole section
if !h.bridgeMode {
// Inject Framework // Inject Framework
if h.frameworkJS != "" { if h.frameworkJS != "" {
h.evalJS(h.frameworkJS, jsMessage) h.evalJS(h.frameworkJS, jsMessage)
@ -204,6 +177,36 @@ func (h *Headless) start(conn *websocket.Conn) {
injectHTML = fmt.Sprintf("$('#app').html('%s')", h.appConfig.HTML) injectHTML = fmt.Sprintf("$('#app').html('%s')", h.appConfig.HTML)
h.evalJS(injectHTML, htmlMessage) h.evalJS(injectHTML, htmlMessage)
} }
}
func (h *Headless) start(conn *websocket.Conn) {
// set external.invoke
h.log.Infof("Connected to frontend.")
h.log.Infof("Mode = %s", h.connectionType)
wailsRuntime := BoxString(&defaultAssets, "wails.js")
h.evalJS(wailsRuntime, wailsRuntimeMessage)
if !h.bridgeMode {
// Inject jquery
jquery := BoxString(&defaultAssets, "jquery.3.3.1.min.js")
h.evalJS(jquery, jsMessage)
}
// Inject the initial JS
for _, js := range h.initialisationJS {
h.sendMessage(h.theConnection, js)
}
// Inject bindings
for _, binding := range h.bindingCache {
h.evalJS(binding, bindingMessage)
}
// In standard headless mode, we send all of the files
if !h.bridgeMode {
h.injectAllFiles()
} }
// Emit that everything is loaded and ready // Emit that everything is loaded and ready