-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e92994d
commit aba82cc
Showing
9 changed files
with
211 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
package application | ||
|
||
import "github.com/wailsapp/wails/v3/internal/operatingsystem" | ||
|
||
// EnvironmentInfo represents information about the current environment. | ||
// | ||
// Fields: | ||
// - OS: the operating system that the program is running on. | ||
// - Arch: the architecture of the operating system. | ||
// - Debug: indicates whether debug mode is enabled. | ||
// - OSInfo: information about the operating system. | ||
type EnvironmentInfo struct { | ||
OS string | ||
Arch string | ||
Debug bool | ||
OS string | ||
Arch string | ||
Debug bool | ||
OSInfo *operatingsystem.OS | ||
PlatformInfo map[string]any | ||
} |