rhumdapp

command module
v0.0.0-...-45c874d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2019 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

rhumdapp

rhumdapp is based on webview go package. The purpose of rhumdapp is to be the starting package to write desktop application using go, javascript and html. Currently the project is tested on linux mint distro, so the following instructions are referred to debian based distro.

Getting started

Install go (see documentation):

create your user github (For example myuser) in folder ~/go/src/github.com

go to user folder (Example myuser) and download rhumdapp:

cd ~/go/src/github.com/myuser
git clone https://github.com/marcos9966/rhumdapp.git
cd rhumdapp

replace marcos9966 reference with your repository reference contained in the files main.go and route.go (for example using VS code editor)

code main.go
code router.go

download go-bindata utility (used in this project)

go get -u github.com/jteeuwen/go-bindata/...

download dependecies

go get -u github.com/gin-gonic/gin
go get -u github.com/zserge/webview
go get -u github.com/phayes/freeport

If you have problem downloading webview (Package webkit2gtk-4.0 requested by package webview) run follow commands

sudo apt-get update
sudo apt-get install build-essential libgtk-3-dev
sudo apt-get install libwebkit2gtk-4.0-dev

build package

cmd/build.sh

maybe you may see some notices about deprecated calls, however if it terminated without errors, you can run application with

cmd/rhumdapp
Examples
Adding a new api route

Add a new package route

mkdir routes/example
code routes/example/example.go

and write the follow text

// Example
package example
import (
    "github.com/gin-gonic/gin"
)

// Rhumdapp Standard function to add package routes
func AddRoutes(r *gin.Engine) {
    r.GET("/api/example/test", test)
}

// test api route
func test(c *gin.Context) {
        if c.Request.Body == nil {
            c.AbortWithStatus(404)
            return
        }
        params := struct {
            Text    	string `form:"text"`
        }{}
        c.Bind(&params)
        if params.Text=="" {
            c.JSON(500, gin.H{"err":"text is mandatory"})
            return
        }
        c.JSON(200, gin.H{
            "result":params.Text,
        })
}

change router.go

code router.go

add import package add follow line in import section

    "github.com/myuser/rhumdapp/routes/example"

add this line after comment

// add here other custom routes

    example.AddRoutes(router)
Adding api call in vue component

change first component example

code res/app/cmp/first/first.vue

add html into template html (after h5 html tag)

<v-btn rounded color="primary" dark @click="test">test</v-btn>
<v-text-field color="success" v-model="text" ></v-text-field>

change module exports data (add "text" json tag)

module.exports = {
    data: function() {
        return {
            text: ""
        }
    }

then add methods section like this:

    mounted: function() {
        console.log("first component mounted");
    },
    methods: {
        test: function(){
            var self = this;
            app.api({
                method:"GET",
                url:"/api/example/test",
                params:{text:self.text}
            }).then(data => {
                alert("you have typed: "+data.result)
            })
            .catch(error => {
                alert("you have an error:"+error)
            });
        }
    }

build project and run

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
resmgr
This package manage resource data
This package manage resource data
routes
systool
routes to use system resources and functionality
routes to use system resources and functionality

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址