Update system.Environment

This commit is contained in:
Lea Anthony
2024-03-19 20:37:03 +11:00
parent e92994d2e7
commit aba82cc527
9 changed files with 210 additions and 9 deletions
+19
View File
@@ -0,0 +1,19 @@
# Screen Example
This example will detect all attached screens and display their details.
## Running the example
To run the example, simply run the following command:
```bash
go run .
```
# Status
| Platform | Status |
|----------|---------|
| Mac | Working |
| Windows | Working |
| Linux | |
+66
View File
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Screens Demo</title>
<style>
body {
padding-top: 75px;
margin: 0 auto;
color: white;
text-align: -webkit-center;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif
}
article {
padding: 1em;
}
::-webkit-scrollbar-track {
background-color: #888;
}
.center {
text-align: -webkit-center;
}
th {
text-align: left;
}
tr {
border: 1px solid white;
}
th, td {
padding: 5px;
}
</style>
<script src="/wails/runtime.js"></script>
</head>
<body>
<script>
let environment = wails.System.Environment();
environment.then((result) => {
console.log({result})
let html = "";
html += "<h1 class='center'>Environment</h1><br><br>";
html += "<table>";
html += "<tr><td>Name</td><td>"+ result.OSInfo.Name +"</td></tr>";
html += "<tr><td>Branding</td><td>"+ result.OSInfo.Branding +"</td></tr>";
html += "<tr><td>Version</td><td>"+ result.OSInfo.Version +"</td></tr>";
html += "<tr><td>ID</td><td>"+ result.OSInfo.ID +"</td></tr>";
html += "<tr><td>GOOS</td><td>"+ result.OS +"</td></tr>";
html += "<tr><td>GOARCH</td><td>"+ result.Arch +"</td></tr>";
html += "<tr><td>Debug</td><td>"+ result.Debug +"</td></tr>";
if(result.PlatformInfo) {
for (let key in result.PlatformInfo) {
if (obj.hasOwnProperty(key)) {
html += "<tr><td>"+key+"</td><td>"+ result.PlatformInfo[key] +"</td></tr>";
}
}
}
html += "</table>";
document.body.innerHTML = html;
})
</script>
</body>
</html>
+43
View File
@@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed assets/*
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "Environment Demo",
Description: "A demo of the Environment API",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
Assets: application.AssetOptions{
Handler: application.BundledAssetFileServer(assets),
},
})
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Environment Demo",
Width: 800,
Height: 600,
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
})
err := app.Run()
if err != nil {
log.Fatal(err.Error())
}
}