Files

86 lines
3.1 KiB
Plaintext
Raw Permalink Normal View History

2022-08-09 20:48:29 +10:00
---
sidebar_position: 1
---
2022-12-01 16:18:59 +08:00
# イントロダクション
2022-08-09 20:48:29 +10:00
2022-12-01 16:18:59 +08:00
ランタイムは、アプリケーションにユーティリティメソッドを提供するライブラリです。 GoとJavaScriptの両方にランタイムがあり、どちらにもほぼ同じメソッドが提供されています。
2022-08-09 20:48:29 +10:00
2022-09-18 11:00:39 +10:00
ユーティリティメソッドには次のようなものがあります:
2022-08-27 20:17:15 +10:00
2022-12-01 16:18:59 +08:00
- [ウィンドウ](window.mdx)
2022-11-28 17:13:22 +08:00
- [メニュー](menu.mdx)
2022-09-30 05:17:34 +08:00
- [ダイアログ](dialog.mdx)
- [イベント](events.mdx)
2022-11-28 17:13:22 +08:00
- [ブラウザ](browser.mdx)
2022-09-30 05:17:34 +08:00
- [ログ](log.mdx)
2023-03-11 17:57:56 +11:00
- [クリップボード](clipboard.mdx)
2022-08-27 20:17:15 +10:00
2022-09-30 05:17:34 +08:00
Goのランタイムは、`github.com/wailsapp/wails/v2/pkg/runtime`をインポートすることで利用できます。 このパッケージのすべてのメソッドは、1番目の引数でContextを渡す必要があります。 このContextは、[OnStartup](../options.mdx#onstartup)フック、または[OnDomReady](../options.mdx#ondomready)フックからあらかじめ取得しておいてください。
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
:::info 備考
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
[OnStartup](../options.mdx#onstartup)で提供されるContextは、ウィンドウが別のスレッドで初期化されているため、ランタイムが機能する保証がありません。 起動時にランタイムメソッドを呼び出したい場合は、[OnDomReady](../options.mdx#ondomready)を使用してください。
2022-08-09 20:48:29 +10:00
:::
2022-12-01 16:18:59 +08:00
JavaScriptのランタイムは、`window.runtime`マップを介してフロントエンド上で利用できます。 `dev`モードでは、TypeScript型定義を提供するランタイムパッケージが生成されます。 これらは、フロントエンドディレクトリの`wailsjs`ディレクトリに配置しておく必要があります。
2022-08-09 20:48:29 +10:00
2022-12-03 22:32:08 +11:00
### Hide
2022-08-09 20:48:29 +10:00
2022-08-27 20:17:15 +10:00
Go: `Hide(ctx context.Context)`<br/> JS: `Hide()`
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
アプリケーションを非表示にします。
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
:::info 備考
2022-09-18 11:00:39 +10:00
2022-09-30 05:17:34 +08:00
Macでこのメソッドを使用すると、標準のMacアプリケーションにおけるメニュー項目の`Hide`と同じ方法で、アプリケーションが非表示になります。 これはウィンドウの非表示とは異なりますが、アプリケーションはフォアグラウンドに残ったままになります。 WindowsおよびLinuxでは、`WindowHide`メソッドと同等です。
2022-09-18 11:00:39 +10:00
:::
2022-12-03 22:32:08 +11:00
### Show
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
アプリケーションを表示します。
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
:::info 備考
2022-09-18 11:00:39 +10:00
2022-09-30 05:17:34 +08:00
Macでこのメソッドを使用すると、アプリケーションがフォアグラウンドに戻ります。 WindowsおよびLinuxでは、`WindowShow`メソッドと同等です。
2022-09-18 11:00:39 +10:00
:::
2022-08-27 20:17:15 +10:00
Go: `Show(ctx context.Context)`<br/> JS: `Show()`
2022-08-09 20:48:29 +10:00
2022-12-03 22:32:08 +11:00
### Quit
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
アプリケーションを終了します。
2022-08-09 20:48:29 +10:00
2022-08-27 20:17:15 +10:00
Go: `Quit(ctx context.Context)`<br/> JS: `Quit()`
2022-08-09 20:48:29 +10:00
2022-12-03 22:32:08 +11:00
### Environment
2022-08-09 20:48:29 +10:00
2022-09-30 05:17:34 +08:00
現在の環境の詳細情報を取得します。
2022-08-09 20:48:29 +10:00
2022-08-27 20:17:15 +10:00
Go: `Environment(ctx context.Context) EnvironmentInfo`<br/> JS: `Environment(): Promise<EnvironmentInfo>`
2022-08-09 20:48:29 +10:00
#### EnvironmentInfo
2022-08-27 20:17:15 +10:00
Go:
2022-09-18 11:00:39 +10:00
2022-08-09 20:48:29 +10:00
```go
type EnvironmentInfo struct {
2022-08-27 20:17:15 +10:00
BuildType string
Platform string
Arch string
}
```
2022-09-18 11:00:39 +10:00
2022-08-27 20:17:15 +10:00
JS:
2022-09-18 11:00:39 +10:00
2022-08-27 20:17:15 +10:00
```ts
interface EnvironmentInfo {
2022-09-18 11:00:39 +10:00
buildType: string;
platform: string;
arch: string;
2022-08-09 20:48:29 +10:00
}
```