mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:02:19 +08:00
Merge pull request #113 from wailsapp/112-deprecate-backend-injection-of-css-js
112 deprecate backend injection of css js
This commit is contained in:
commit
dcc3e5fa79
@ -8,5 +8,6 @@ Wails is what it is because of the time and effort given by these great people.
|
||||
* [Adrian Lanzafame](https://github.com/lanzafame)
|
||||
* [0xflotus](https://github.com/0xflotus)
|
||||
* [Michael D Henderson](https://github.com/mdhender)
|
||||
* [fred2104] (https://github.com/fishfishfish2104)
|
||||
* [intelwalk] (https://github.com/intelwalk)
|
||||
* [fred2104](https://github.com/fishfishfish2104)
|
||||
* [intelwalk](https://github.com/intelwalk)
|
||||
* [Mark Stenglein](https://github.com/ocelotsloth)
|
||||
|
23
app.go
23
app.go
@ -22,11 +22,6 @@ type App struct {
|
||||
bindingManager *bindingManager // Handles binding of Go code to renderer
|
||||
eventManager *eventManager // Handles all the events
|
||||
runtime *Runtime // The runtime object for registered structs
|
||||
|
||||
// This is a list of all the JS/CSS that needs injecting
|
||||
// It will get injected in order
|
||||
jsCache []string
|
||||
cssCache []string
|
||||
}
|
||||
|
||||
// CreateApp creates the application window with the given configuration
|
||||
@ -111,12 +106,6 @@ func (a *App) start() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Inject CSS
|
||||
a.renderer.AddCSSList(a.cssCache)
|
||||
|
||||
// Inject JS
|
||||
a.renderer.AddJSList(a.jsCache)
|
||||
|
||||
// Run the renderer
|
||||
return a.renderer.Run()
|
||||
}
|
||||
@ -126,15 +115,3 @@ func (a *App) start() error {
|
||||
func (a *App) Bind(object interface{}) {
|
||||
a.bindingManager.bind(object)
|
||||
}
|
||||
|
||||
// AddJS adds a piece of Javascript to a cache that
|
||||
// gets injected at runtime
|
||||
func (a *App) AddJS(js string) {
|
||||
a.jsCache = append(a.jsCache, js)
|
||||
}
|
||||
|
||||
// AddCSS adds a CSS string to a cache that
|
||||
// gets injected at runtime
|
||||
func (a *App) AddCSS(js string) {
|
||||
a.cssCache = append(a.cssCache, js)
|
||||
}
|
||||
|
@ -12,10 +12,6 @@ type Renderer interface {
|
||||
// Events
|
||||
NotifyEvent(eventData *eventData) error
|
||||
|
||||
// Injection
|
||||
AddJSList(js []string)
|
||||
AddCSSList(css []string)
|
||||
|
||||
// Dialog Runtime
|
||||
SelectFile() string
|
||||
SelectDirectory() string
|
||||
|
@ -37,10 +37,6 @@ type Headless struct {
|
||||
appConfig *AppConfig
|
||||
eventManager *eventManager
|
||||
bindingCache []string
|
||||
frameworkJS string
|
||||
frameworkCSS string
|
||||
jsCache []string
|
||||
cssCache []string
|
||||
|
||||
// Headless specific
|
||||
initialisationJS []string
|
||||
@ -190,18 +186,6 @@ func (h *Headless) SelectSaveFile() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// AddJSList adds a slice of JS strings to the list of js
|
||||
// files injected at startup
|
||||
func (h *Headless) AddJSList(jsCache []string) {
|
||||
h.jsCache = jsCache
|
||||
}
|
||||
|
||||
// AddCSSList adds a slice of CSS strings to the list of css
|
||||
// files injected at startup
|
||||
func (h *Headless) AddCSSList(cssCache []string) {
|
||||
h.cssCache = cssCache
|
||||
}
|
||||
|
||||
// Callback sends a callback to the frontend
|
||||
func (h *Headless) Callback(data string) error {
|
||||
return h.evalJS(data, callbackMessage)
|
||||
|
@ -21,13 +21,6 @@ type webViewRenderer struct {
|
||||
config *AppConfig
|
||||
eventManager *eventManager
|
||||
bindingCache []string
|
||||
frameworkJS string
|
||||
frameworkCSS string
|
||||
|
||||
// This is a list of all the JS/CSS that needs injecting
|
||||
// It will get injected in order
|
||||
jsCache []string
|
||||
cssCache []string
|
||||
}
|
||||
|
||||
// Initialise sets up the WebView
|
||||
@ -175,13 +168,13 @@ func (w *webViewRenderer) Run() error {
|
||||
w.evalJSSync(binding)
|
||||
}
|
||||
|
||||
// Inject Framework
|
||||
if w.frameworkJS != "" {
|
||||
w.evalJSSync(w.frameworkJS)
|
||||
}
|
||||
if w.frameworkCSS != "" {
|
||||
w.injectCSS(w.frameworkCSS)
|
||||
}
|
||||
// // Inject Framework
|
||||
// if w.frameworkJS != "" {
|
||||
// w.evalJSSync(w.frameworkJS)
|
||||
// }
|
||||
// if w.frameworkCSS != "" {
|
||||
// w.injectCSS(w.frameworkCSS)
|
||||
// }
|
||||
|
||||
// Inject user CSS
|
||||
if w.config.CSS != "" {
|
||||
@ -199,16 +192,6 @@ func (w *webViewRenderer) Run() error {
|
||||
w.injectCSS(defaultCSS)
|
||||
}
|
||||
|
||||
// Inject all the CSS files that have been added
|
||||
for _, css := range w.cssCache {
|
||||
w.injectCSS(css)
|
||||
}
|
||||
|
||||
// Inject all the JS files that have been added
|
||||
for _, js := range w.jsCache {
|
||||
w.evalJSSync(js)
|
||||
}
|
||||
|
||||
// Inject user JS
|
||||
if w.config.JS != "" {
|
||||
outputJS := fmt.Sprintf("%.45s", w.config.JS)
|
||||
@ -289,17 +272,6 @@ func (w *webViewRenderer) SelectSaveFile() string {
|
||||
return result
|
||||
}
|
||||
|
||||
// AddJS adds a piece of Javascript to a cache that
|
||||
// gets injected at runtime
|
||||
func (w *webViewRenderer) AddJSList(jsCache []string) {
|
||||
w.jsCache = jsCache
|
||||
}
|
||||
|
||||
// AddCSSList sets the cssCache to the given list of strings
|
||||
func (w *webViewRenderer) AddCSSList(cssCache []string) {
|
||||
w.cssCache = cssCache
|
||||
}
|
||||
|
||||
// Callback sends a callback to the frontend
|
||||
func (w *webViewRenderer) Callback(data string) error {
|
||||
callbackCMD := fmt.Sprintf("window.wails._.callback('%s');", data)
|
||||
|
Loading…
Reference in New Issue
Block a user