├── README.md ├── examples ├── commits │ ├── app.go │ ├── index.html │ ├── vue.js │ └── wasm_exec.js └── todolist │ ├── data.go │ ├── index.html │ ├── item.go │ ├── todolist.go │ ├── vue.js │ ├── vuego_data.go │ ├── vuego_item.go │ └── wasm_exec.js ├── gen └── gen.go ├── methods.go ├── vuego.go └── xhr └── xhr.go /README.md: -------------------------------------------------------------------------------- 1 | Vuego Framework 2 | =============== 3 | 4 | This is a WASM-based Vue.js wrapper written in Go. 5 | It uses the Go 1.11+ Web Assembly compiler to compile the wrapper. 6 | 7 | The first version of Vuego aims to be a thin Vue.js wrapper which allows writing frontend in the Go programming language. 8 | 9 | The immediate benefit of Vuego is that it allows Vue.js users to deliver their Web applications in binary (Web Assembly) forms. 10 | So your companies would have a better way to protect IPs for Vue.js applications. -------------------------------------------------------------------------------- /examples/commits/app.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "strings" 7 | "syscall/js" 8 | 9 | . "github.com/chanwit/vuego" 10 | "github.com/chanwit/vuego/xhr" 11 | ) 12 | 13 | const ( 14 | apiURL = "https://api.github.com/repos/vuejs/vue/commits?per_page=3&sha=" 15 | ) 16 | 17 | type Commits struct { 18 | js.Value 19 | Branches []string `json:"branches"` 20 | CurrentBranch string `json:"currentBranch"` 21 | Commits []Commit `json:"commits"` 22 | } 23 | 24 | type Commit = map[string]interface{} 25 | 26 | func (this *Commits) FetchData() { 27 | req := xhr.New() 28 | req.Open("GET", apiURL + this.CurrentBranch) 29 | req.OnLoad(func(args []js.Value) { 30 | this.Commits = []Commit{} 31 | json.Unmarshal([]byte(req.GetResponseText()), &this.Commits) 32 | fmt.Println(this.Commits[0]["html_url"]) 33 | arrayConstructor := js.Global().Get("Array") 34 | a := arrayConstructor.New(len(this.Commits)) 35 | for i, s := range this.Commits { 36 | a.SetIndex(i, js.ValueOf(s)) 37 | } 38 | this.Value.Set("commits", a) 39 | }) 40 | req.Send() 41 | } 42 | 43 | func main() { 44 | 45 | New(&Vue{ 46 | El: "#demo", 47 | Data: &Commits{ 48 | Branches: []string{"master", "dev"}, 49 | CurrentBranch: "master", 50 | Commits: nil, 51 | }, 52 | Created: func(this Any, args []js.Value) { 53 | this.(*Commits).FetchData() 54 | }, 55 | Watch: &Watch{ 56 | "currentBranch": "fetchData", 57 | }, 58 | Filters: &Filters{ 59 | "truncate": func(v Any) Any { 60 | s := v.(js.Value).String() 61 | return strings.TrimSuffix(s, "\n") 62 | }, 63 | "formatDate": func(v Any) Any { 64 | return strings.Replace(v.(js.Value).String(), "Z", " ", -1) 65 | }, 66 | }, 67 | Methods: &Methods{ 68 | "fetchData": func(this Any) { 69 | this.(*Commits).FetchData() 70 | }, 71 | }, 72 | }) 73 | 74 | select { } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /examples/commits/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |vuejs/vue@{{ currentBranch }}
45 |