go语言用html桌面,使用go语言和webview编写桌面应用

具体思路是使用http实现页面跳转,使用jsonrpc实现ui和 go 之间的数据通讯。

golang版本的webview使用的是github.com/zserge/webview这个库,自己封装了一套Page,实现页面之间的跳转。具体使用

package main

import "time"

func main() {

StartWindow("golang html", 400, 400, true, func() {

pager := NewPager(&MyPage{},&MyPageAction{})

pager.StartPage(0)

})

}

type MyPage struct {

PageImpl

}

type MyPage1 struct {

PageImpl

}

type MyPageAction struct {

P *MyPage

i int

}

func (t *MyPageAction) Add(i int,s *string) error {

pager := NewPager(&MyPage1{},nil)

pager.StartPage(0)

*s = "success"

return nil

}

func (p *MyPage) Stop() {

}

func (p*MyPage)Start() {

p.SetContentView("html/page1.html")

}

func (p *MyPage1) Stop() {

}

func (p*MyPage1)Start() {

p.SetContentView("html/page2.html")

go func() {

time.Sleep(5*time.Second)

p.Window.Backup()

}()

}

这里默认打开第一个页面,点击按钮跳转到第二个页面,五秒钟后页面返回。

f890cc40961c750a515196f6dd1542ec.png

2018-11-29 17-38-04屏幕截图.png

2f6d7c84ceaa8205278d4f32de3795d5.png

2018-11-29 17-38-22屏幕截图.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值