Skip to content

Commit

Permalink
update i18n and remove initial columns state
Browse files Browse the repository at this point in the history
  • Loading branch information
XZB-1248 committed May 8, 2022
1 parent ee3726e commit f65307a
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 38 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v0.0.6

* Update: i18n.
* Remove: initial columns state.

* 更新:国际化。
* 移除:默认隐藏部分信息。



## v0.0.5

* Add: server and client now support macOS.
Expand Down
2 changes: 1 addition & 1 deletion client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Cfg struct {
Key string `json:"key"`
}

// localhost
// localhost for debug only
//var CfgBuffer = "\x00\xcd\x90\x50\x43\xfc\x3d\x36\x56\x6d\xf6\x01\xd1\xcd\x81\xc3\x1b\x80\xc9\x61\xd8\xdf\x5b\x76\x48\x88\xc5\xb1\x74\x22\x23\xab\x3b\xfc\x8b\xbe\x98\x27\xed\x05\xec\xbb\x40\x4f\xe9\xe7\xe5\xe0\x84\xaa\xb7\xfd\x4a\x30\x71\x08\x6c\x02\x50\xe9\xc5\x22\xcf\xcb\x89\x16\x0a\x89\x08\xd4\x26\xdc\x5c\xc1\xc9\xbf\xc4\xac\x0d\x92\x2f\x34\x7f\x45\xeb\x55\xa0\x6d\xf6\x64\xbc\xd5\x15\x40\x96\x43\x64\xe0\x24\x51\xfb\xe8\xc9\x7f\x48\x60\xcd\x30\x5e\x5e\x78\xba\xb6\x6f\x07\x64\xe8\x59\x81\x0b\x91\x13\x92\x1a\xdd\x49\x8f\x28\xe7\x74\xea\xff\x5b\x45\x0e\x4a\x2d\x60\x4e\xc9\xde\x9c\xbe\x50\xc6\x12\xc7\x45\xa2\x15\xa0\x58\x62\x45\x86\x74\x9f\xa5\x14\x5c\x17\x8a\xcc\x56\x73\xa7\x75\xb7\xf6\x6d\x52\x0f\xb8\xc1\xff\x9c\x39\x39\x00\x74\xe1\x4d\x65\x73\x9c\x02\x57\x8b\xcf\xdf\x0a\x20\x4c\xed\xe2\x25\xea\x01\x36\x12\x37\x12\x2e\x1a\x03\x41\x19\x2e\xc9\xdd\x71\xac\x73\x90\xfa\x5e\x60\x08\x43\x35\xef\x61\x45\xf9\xe3\xba\xcb\xb1\xc5\x7c\xf0\x11\xcd\x47\x57\x53\xdc\x35\x6b\x9f\xac\xad\x43\x4a\xc7\x54\x20\xb8\xd0\xf8\xb5\x0c\x45\x76\x57\xb9\xee\x4a\x3f\xd2\xda\xf7\x94\x54\x74\xf3\x91\xf3\x4d\x49\x98\xc6\xf8\x60\x80\xad\x84\x04\xef\x35\xca\x3a\xcf\xd3\x7e\x74\xc2\x4b\xb8\xb3\x9f\xb2\x83\xb8\xbd\x29\x13\x9f\x2b\xaa\x60\x47\x24\x7e\x20\xb2\x85\xdc\x47\xfe\x8f\x68\xb6\xc3\x43\xad\x61\x3d\x9b\x35\x60\x2e\x6c\x44\xf0\xaf\xb2\xf3\xdb\xe2\x1b\x8a\xec\x0a\x48\x5e\x43\xa9\xb3\x3a\x5e\xb6\x90\xa9\x3d\xee\x4f\xa1\x57\x7c\x94\xf4\xb1\x36\xda\x04\xa8\x5e\x48\x2a\xc3\xa1\xf0\x97\xf0\xe0\x10\x46\x32\x10\xe5\xd8\x36\x5a\x56\xa5\xbb\x37\x3c\x9f\xbd\xef\xf5\x2f"

// none
Expand Down
6 changes: 3 additions & 3 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ func heartbeat(wsConn *common.Conn) error {
for range time.NewTicker(2 * time.Second).C {
t++
// GetPartialInfo always costs more than 1 second.
// So it is actually get disk info every 200*3 seconds (10 minutes).
device, err := GetPartialInfo(t >= 200)
// So it is actually get disk info every 20*3 seconds (1 minute).
device, err := GetPartialInfo(t >= 20)
if err != nil {
golog.Error(err)
continue
}
if t >= 200 {
if t >= 20 {
t = 0
}
err = common.SendPack(modules.CommonPack{Act: `setDevice`, Data: device}, wsConn)
Expand Down
14 changes: 7 additions & 7 deletions client/core/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func GetCPUInfo() (modules.CPU, error) {
return result, nil
}

func GetMemInfo() (modules.IO, error) {
func GetRAMInfo() (modules.IO, error) {
result := modules.IO{}
stat, err := mem.VirtualMemory()
if err != nil {
Expand Down Expand Up @@ -194,9 +194,9 @@ func GetDevice() (*modules.Device, error) {
Recv: 0,
}
}
memInfo, err := GetMemInfo()
ramInfo, err := GetRAMInfo()
if err != nil {
memInfo = modules.IO{
ramInfo = modules.IO{
Total: 0,
Used: 0,
Usage: 0,
Expand Down Expand Up @@ -234,8 +234,8 @@ func GetDevice() (*modules.Device, error) {
LAN: localIP,
Mac: macAddr,
CPU: cpuInfo,
RAM: ramInfo,
Net: netInfo,
Mem: memInfo,
Disk: diskInfo,
Uptime: uptime,
Hostname: hostname,
Expand All @@ -258,7 +258,7 @@ func GetPartialInfo(getDisk bool) (modules.Device, error) {
Sent: 0,
}
}
memInfo, err := GetMemInfo()
memInfo, err := GetRAMInfo()
if err != nil {
memInfo = modules.IO{
Total: 0,
Expand All @@ -279,9 +279,9 @@ func GetPartialInfo(getDisk bool) (modules.Device, error) {
uptime = 0
}
return modules.Device{
CPU: cpuInfo,
Net: netInfo,
Mem: memInfo,
CPU: cpuInfo,
RAM: memInfo,
Disk: diskInfo,
Uptime: uptime,
}, nil
Expand Down
4 changes: 2 additions & 2 deletions client/service/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

type file struct {
Name string `json:"name"`
Size int64 `json:"size"`
Size uint64 `json:"size"`
Time int64 `json:"time"`
Type int `json:"type"` // 0: file, 1: folder, 2: volume
}
Expand All @@ -32,7 +32,7 @@ func listFiles(path string) ([]file, error) {
}
result = append(result, file{
Name: files[i].Name(),
Size: files[i].Size(),
Size: uint64(files[i].Size()),
Time: files[i].ModTime().Unix(),
Type: itemType,
})
Expand Down
10 changes: 9 additions & 1 deletion client/service/file/file_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package file
Expand All @@ -15,7 +16,14 @@ func ListFiles(path string) ([]file, error) {
return nil, err
}
for i := 0; i < len(partitions); i++ {
result = append(result, file{Name: partitions[i].Mountpoint, Type: 2})
size := uint64(0)
stat, err := disk.Usage(partitions[i].Mountpoint)
if err != nil || stat == nil {
size = 0
} else {
size = stat.Total
}
result = append(result, file{Name: partitions[i].Mountpoint, Type: 2, Size: size})
}
return result, nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Spark

go 1.18
go 1.17

require (
github.com/creack/pty v1.1.18
Expand Down
2 changes: 1 addition & 1 deletion modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Device struct {
Mac string `json:"mac"`
Net Net `json:"net"`
CPU CPU `json:"cpu"`
Mem IO `json:"mem"`
RAM IO `json:"ram"`
Disk IO `json:"disk"`
Uptime uint64 `json:"uptime"`
Latency uint `json:"latency"`
Expand Down
2 changes: 1 addition & 1 deletion server/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ func WSDevice(data []byte, session *melody.Session) error {
deviceInfo, ok := val.(*modules.Device)
if ok {
deviceInfo.CPU = pack.Device.CPU
deviceInfo.RAM = pack.Device.RAM
deviceInfo.Net = pack.Device.Net
deviceInfo.Mem = pack.Device.Mem
if pack.Device.Disk.Total > 0 {
deviceInfo.Disk = pack.Device.Disk
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function FileBrowser(props) {
dataIndex: 'size',
ellipsis: true,
width: 60,
renderText: (size, file) => file.type === 0 ? formatSize(size) : '-'
renderText: (size, file) => file.type === 0 || size > 0 ? formatSize(size) : '-'
},
{
key: 'Time',
Expand Down
8 changes: 4 additions & 4 deletions web/src/config/columnsState.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"mac": {
"show": false
"show": true
},
"mem_total": {
"show": false
"ram_total": {
"show": true
},
"disk_usage": {
"show": false
"show": true
}
}
4 changes: 2 additions & 2 deletions web/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"hostname": "Hostname",
"username": "Username",
"cpuUsage": "CPU Usage",
"memUsage": "Mem Usage",
"ramUsage": "RAM Usage",
"diskUsage": "Disk Usage",
"memTotal": "Memory",
"ram": "RAM",
"os": "OS",
"arch": "Arch",
"uptime": "Uptime",
Expand Down
4 changes: 2 additions & 2 deletions web/src/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"hostname": "主机名",
"username": "用户名",
"cpuUsage": "CPU使用率",
"memUsage": "内存使用率",
"ramUsage": "内存使用率",
"diskUsage": "磁盘使用率",
"memTotal": "内存大小",
"ram": "RAM",
"os": "操作系统",
"arch": "架构",
"uptime": "运行时间",
Expand Down
24 changes: 12 additions & 12 deletions web/src/pages/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function overview(props) {
width: 100
},
{
key: 'mem_usage',
title: i18n.t('memUsage'),
dataIndex: 'mem_usage',
key: 'ram_usage',
title: i18n.t('ramUsage'),
dataIndex: 'ram_usage',
ellipsis: true,
render: (_, v) => <Progress percent={v.mem_usage} showInfo={false} strokeWidth={12} trailColor='#FFECFF'/>,
render: (_, v) => <Progress percent={v.ram_usage} showInfo={false} strokeWidth={12} trailColor='#FFECFF'/>,
width: 100
},
{
Expand All @@ -71,14 +71,6 @@ function overview(props) {
render: (_, v) => <Progress percent={v.disk_usage} showInfo={false} strokeWidth={12} trailColor='#FFECFF'/>,
width: 100
},
{
key: 'mem_total',
title: i18n.t('memTotal'),
dataIndex: 'mem_total',
ellipsis: true,
renderText: formatSize,
width: 70
},
{
key: 'os',
title: i18n.t('os'),
Expand All @@ -93,6 +85,14 @@ function overview(props) {
ellipsis: true,
width: 70
},
{
key: 'ram_total',
title: i18n.t('ram'),
dataIndex: 'ram_total',
ellipsis: true,
renderText: formatSize,
width: 70
},
{
key: 'mac',
title: 'MAC',
Expand Down

0 comments on commit f65307a

Please sign in to comment.