Skip to content

Commit 05c9c69

Browse files
committed
adjusts front
1 parent 2b7b369 commit 05c9c69

File tree

10 files changed

+51
-10
lines changed

10 files changed

+51
-10
lines changed

app.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ import (
44
"context"
55
"database/sql"
66
"encoding/json"
7+
"io/ioutil"
8+
"log"
79
"os"
10+
"runtime"
811

912
_ "github.com/mattn/go-sqlite3"
1013
)
1114

1215
type App struct {
13-
ctx context.Context
14-
db *sql.DB
16+
ctx context.Context
17+
db *sql.DB
18+
version string
1519
}
1620

1721
func check(e error) {
@@ -27,6 +31,19 @@ func NewApp() *App {
2731
func (a *App) startup(ctx context.Context) {
2832
home, _ := os.UserHomeDir()
2933

34+
content, err := ioutil.ReadFile("./wails.json")
35+
if err != nil {
36+
log.Fatal("Error when opening file: ", err)
37+
}
38+
var payload map[string]interface{}
39+
err = json.Unmarshal(content, &payload)
40+
if err != nil {
41+
log.Fatal("Error during Unmarshal(): ", err)
42+
}
43+
infos := payload["info"].(map[string]interface{})
44+
45+
a.version = "v" + infos["productVersion"].(string) + " - " + runtime.GOOS + " - " + runtime.GOARCH
46+
3047
a.ctx = ctx
3148
if _, err := os.Stat(home + string(os.PathSeparator) + ".cheat_sheets.db"); os.IsNotExist(err) {
3249
a.db = nil
@@ -57,6 +74,10 @@ func (a *App) GetPrograms() string {
5774
return string(jsonData)
5875
}
5976

77+
func (a *App) GetVersion() string {
78+
return a.version
79+
}
80+
6081
func (a *App) GetCheatSheet(program string) string {
6182
if a.db == nil {
6283
return "{}"

frontend/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "frontend",
33
"private": true,
4-
"version": "0.2.0",
4+
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

frontend/package.json.md5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ced8d5b88095d219f174b5ebe09e134e
1+
171597fb47240adc88296a8bb9f34413

frontend/src/App.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts" setup>
22
import { reactive } from 'vue'
3-
import { GetPrograms, GetCheatSheet } from '../wailsjs/go/main/App'
3+
import { GetPrograms, GetCheatSheet, GetVersion } from '../wailsjs/go/main/App'
44
import DataTable from 'primevue/datatable';
55
import Column from 'primevue/column';
6-
import Menu from 'primevue/menu';
76
87
const data = reactive({
8+
app_version: "",
99
programs: [],
1010
currentContent: JSON.parse('{"Selecione um software no menu!": []}')
1111
})
@@ -16,6 +16,13 @@ function changeContent(content: string) {
1616
})
1717
}
1818
19+
function AppVersion() {
20+
GetVersion().then(result => {
21+
data.app_version = result
22+
})
23+
}
24+
AppVersion()
25+
1926
function listPrograms() {
2027
GetPrograms().then(result => {
2128
data.programs = JSON.parse(result)
@@ -29,6 +36,9 @@ listPrograms()
2936
<div class="vertical-menu">
3037
<a v-for="program in data.programs" :key="program" href="#" @click="changeContent(program)">{{ program }}</a>
3138
<br>
39+
<footer>
40+
<p class="app_footer">{{ data.app_version }}</p>
41+
</footer>
3242
</div>
3343
<div v-for="(value, key) in data.currentContent" class="content-area">
3444
<h4>{{ key }}</h4>

frontend/src/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ body {
2020

2121
.p-datatable .p-datatable-thead {
2222
display: none;
23+
}
24+
25+
.app_footer {
26+
font-size: smaller;
2327
}

frontend/wailsjs/go/main/App.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
export function GetCheatSheet(arg1:string):Promise<string>;
55

66
export function GetPrograms():Promise<string>;
7+
8+
export function GetVersion():Promise<string>;

frontend/wailsjs/go/main/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ export function GetCheatSheet(arg1) {
99
export function GetPrograms() {
1010
return window['go']['main']['App']['GetPrograms']();
1111
}
12+
13+
export function GetVersion() {
14+
return window['go']['main']['App']['GetVersion']();
15+
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func main() {
3939
},
4040
About: &mac.AboutInfo{
4141
Title: "Desktop Cheat Sheet",
42-
Message: "© @mvrpl_br",
42+
Message: app.version + " | © mvrpl_br",
4343
},
4444
},
4545
})

wails.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"info": {
1414
"companyName": "mvrpl_br",
1515
"productName": "Desktop Cheat Sheet",
16-
"productVersion": "0.2.0"
16+
"productVersion": "0.2.1"
1717
},
1818
"nsisType": "single"
1919
}

0 commit comments

Comments
 (0)