5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 02:50:36 +08:00

chore: remove old JS/CSS api

This commit is contained in:
Lea Anthony 2019-05-30 08:43:26 +10:00
parent e718a56ed9
commit f4e6c407ba
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
4 changed files with 7 additions and 78 deletions

23
app.go
View File

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

View File

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

View File

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

View File

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