create-basicjs 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/bin/create-basicjs.js +27 -1
- package/package.json +1 -1
- package/payload/projects/tauri/.github/workflows/build.yml +86 -0
- package/payload/projects/tauri/.github/workflows/tests.yml +87 -0
- package/payload/projects/tauri/AGENTS.md +128 -0
- package/payload/projects/tauri/CLAUDE.md +1 -0
- package/payload/projects/tauri/LICENSE +201 -0
- package/payload/projects/tauri/NOTICE +8 -0
- package/payload/projects/tauri/README.md +269 -0
- package/payload/projects/tauri/checks/window-check.js +189 -0
- package/payload/projects/tauri/gitignore +8 -0
- package/payload/projects/tauri/handbook/01-getting-started.md +188 -0
- package/payload/projects/tauri/handbook/02-the-project.md +264 -0
- package/payload/projects/tauri/handbook/03-the-page.md +260 -0
- package/payload/projects/tauri/handbook/04-commands.md +265 -0
- package/payload/projects/tauri/handbook/05-events-and-state.md +275 -0
- package/payload/projects/tauri/handbook/06-plugins.md +282 -0
- package/payload/projects/tauri/handbook/07-the-window-and-the-app.md +431 -0
- package/payload/projects/tauri/handbook/08-security.md +374 -0
- package/payload/projects/tauri/handbook/09-tests-and-checks.md +266 -0
- package/payload/projects/tauri/handbook/10-building-and-releasing.md +238 -0
- package/payload/projects/tauri/handbook/11-troubleshooting.md +259 -0
- package/payload/projects/tauri/handbook/README.md +125 -0
- package/payload/projects/tauri/handbook/turkce/01-getting-started.md +193 -0
- package/payload/projects/tauri/handbook/turkce/02-the-project.md +272 -0
- package/payload/projects/tauri/handbook/turkce/03-the-page.md +272 -0
- package/payload/projects/tauri/handbook/turkce/04-commands.md +271 -0
- package/payload/projects/tauri/handbook/turkce/05-events-and-state.md +284 -0
- package/payload/projects/tauri/handbook/turkce/06-plugins.md +286 -0
- package/payload/projects/tauri/handbook/turkce/07-the-window-and-the-app.md +433 -0
- package/payload/projects/tauri/handbook/turkce/08-security.md +384 -0
- package/payload/projects/tauri/handbook/turkce/09-tests-and-checks.md +275 -0
- package/payload/projects/tauri/handbook/turkce/10-building-and-releasing.md +241 -0
- package/payload/projects/tauri/handbook/turkce/11-troubleshooting.md +264 -0
- package/payload/projects/tauri/handbook/turkce/README.md +128 -0
- package/payload/projects/tauri/images/app.png +0 -0
- package/payload/projects/tauri/src-tauri/Cargo.lock +4389 -0
- package/payload/projects/tauri/src-tauri/Cargo.toml +31 -0
- package/payload/projects/tauri/src-tauri/app-icon.svg +16 -0
- package/payload/projects/tauri/src-tauri/build.rs +15 -0
- package/payload/projects/tauri/src-tauri/capabilities/default.json +7 -0
- package/payload/projects/tauri/src-tauri/gitignore +5 -0
- package/payload/projects/tauri/src-tauri/icons/128x128.png +0 -0
- package/payload/projects/tauri/src-tauri/icons/128x128@2x.png +0 -0
- package/payload/projects/tauri/src-tauri/icons/32x32.png +0 -0
- package/payload/projects/tauri/src-tauri/icons/icon.icns +0 -0
- package/payload/projects/tauri/src-tauri/icons/icon.ico +0 -0
- package/payload/projects/tauri/src-tauri/src/check.rs +144 -0
- package/payload/projects/tauri/src-tauri/src/files.rs +255 -0
- package/payload/projects/tauri/src-tauri/src/main.rs +45 -0
- package/payload/projects/tauri/src-tauri/src/sizes.rs +214 -0
- package/payload/projects/tauri/src-tauri/tauri.conf.json +44 -0
- package/payload/projects/tauri/src-tauri/tests/project.rs +243 -0
- package/payload/projects/tauri/ui/app.js +459 -0
- package/payload/projects/tauri/ui/backend.js +196 -0
- package/payload/projects/tauri/ui/basic/LICENSE +14 -0
- package/payload/projects/tauri/ui/basic/basic.min.css +1 -0
- package/payload/projects/tauri/ui/basic/basic.min.js +78 -0
- package/payload/projects/tauri/ui/basic/font/open-sans/LICENSE.txt +206 -0
- package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
- package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
- package/payload/projects/tauri/ui/basic/scroll-bar.min.js +3 -0
- package/payload/projects/tauri/ui/comp/_sources.txt +9 -0
- package/payload/projects/tauri/ui/comp/components.min.js +21 -0
- package/payload/projects/tauri/ui/index.html +28 -0
- package/payload/projects/tauri/ui/sizes.js +104 -0
- package/payload/starter/_basic/VERSION +1 -1
- package/payload/starter/_basic/comp/bottom-bar.js +31 -3
- package/payload/starter/_basic/comp/code-editor.js +219 -1
- package/payload/starter/_basic/comp/context-menu.js +6 -1
- package/payload/starter/_basic/comp/markdown-view.js +4 -2
- package/payload/starter/_basic/comp/property-panel.js +1 -1
- package/payload/starter/_basic/comp/slider.js +27 -12
- package/payload/starter/_basic/comp/smart-button.js +5 -1
- package/payload/starter/_basic/comp/smart-table.js +8 -1
- package/payload/starter/_basic/comp/stepper.js +29 -3
- package/payload/starter/_basic/comp/toggle.js +2 -1
- package/payload/starter/_basic/docs/component-index.md +53 -53
- package/payload/starter/_basic/examples/code-editor.htm +48 -1
- package/payload/starter/_basic/examples/gallery-styled.htm +896 -0
- package/payload/starter/_basic/examples/search-input.htm +1 -1
- package/payload/starter/_basic/examples/select-box-2-item-view.htm +304 -0
- package/payload/starter/_basic/examples/{slider-2-classic.htm → slider-2-split.htm} +36 -2
- package/payload/starter/_basic/examples/stepper-2.htm +22 -6
- package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
- package/payload/starter/_basic/min/code-editor.min.js +1 -1
- package/payload/starter/_basic/min/context-menu.min.js +1 -1
- package/payload/starter/_basic/min/markdown-view.min.js +1 -1
- package/payload/starter/_basic/min/slider.min.js +1 -1
- package/payload/starter/_basic/min/smart-button.min.js +1 -1
- package/payload/starter/_basic/min/smart-table.min.js +1 -1
- package/payload/starter/_basic/min/stepper.min.js +1 -1
- package/payload/starter/_basic/min/toggle.min.js +1 -1
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
# 7. Pencere ve uygulama
|
|
2
|
+
|
|
3
|
+
*English: [7. The window and the app](../07-the-window-and-the-app.md)*
|
|
4
|
+
|
|
5
|
+
Pencere ve çevresindekiler: ayarları, sayfadan değiştirilmesi ve her değişikliğin gerektirdiği izin (permission),
|
|
6
|
+
kapanmadan önce bir soru, ikinci bir pencere, menü, uygulamanın klasörleri, açık ve koyu görünüm. Her örnek,
|
|
7
|
+
şablonun bir kopyasında macOS'ta derlendi ve çalıştırıldı (Apple Silicon, 2026-11-27).
|
|
8
|
+
|
|
9
|
+
## tauri.conf.json içindeki pencere
|
|
10
|
+
|
|
11
|
+
Şablon bir pencere açar; `src-tauri/tauri.conf.json` dosyasında `app.windows` içinde yazılıdır:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"title": "Tauri Starter",
|
|
16
|
+
"width": 960,
|
|
17
|
+
"height": 640,
|
|
18
|
+
"minWidth": 760,
|
|
19
|
+
"minHeight": 420,
|
|
20
|
+
"theme": "Light"
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
En çok kullanılan alanlar (varsayılan, alan yazılmadığında geçen değerdir):
|
|
25
|
+
|
|
26
|
+
| Alan | Varsayılan | Ne yapar |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| `title` | `"Tauri App"` | başlık çubuğunun metni |
|
|
29
|
+
| `width`, `height` | 800, 600 | başlangıçtaki boyut, sayfanın px'iyle |
|
|
30
|
+
| `minWidth`, `minHeight`, `maxWidth`, `maxHeight` | yok | en küçük ve en büyük boyut |
|
|
31
|
+
| `resizable` | `true` | pencere büyütülüp küçültülebilir |
|
|
32
|
+
| `center` | `false` | `true`: başlangıçta ekranın ortasında |
|
|
33
|
+
| `maximized`, `fullscreen` | `false` | ekranın izin verdiği kadar büyük / bütün ekran |
|
|
34
|
+
| `decorations` | `true` | `false`: sistemin başlık çubuğu ve kenarı yok |
|
|
35
|
+
| `theme` | sistem | `"Light"` ya da `"Dark"` (aşağıda) |
|
|
36
|
+
| `label` | `"main"` | pencerenin kod ve yetenek dosyaları için adı |
|
|
37
|
+
|
|
38
|
+
- Denendi: `"center": true` pencereyi ekranın macOS menü çubuğunun altında kalan bölümünün ortasında açtı.
|
|
39
|
+
- Dosya uygulamanın içine derlenir: bir değişiklik, uygulama yeniden derlendiğinde görünür.
|
|
40
|
+
- Bütün alanlar: https://tauri.app/reference/config/ (`WindowConfig` bölümü).
|
|
41
|
+
|
|
42
|
+
## Sayfadan pencere
|
|
43
|
+
|
|
44
|
+
`window.__TAURI__.window.getCurrentWindow()` sayfanın penceresidir. `src-tauri/capabilities/default.json`
|
|
45
|
+
içindeki `core:default` sorulara izin verir, değişikliklere değil: her değişiklik kendi satırını ister.
|
|
46
|
+
|
|
47
|
+
| Sayfada | Ne yapar | `permissions` içindeki satırı |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `title()`, `innerSize()`, `scaleFactor()`, `isMaximized()`, `theme()` | sorular | yok (`core:default`) |
|
|
50
|
+
| `setTitle("Notes")` | başlık | `"core:window:allow-set-title"` |
|
|
51
|
+
| `setSize(new window.__TAURI__.dpi.LogicalSize(900, 600))` | boyut | `"core:window:allow-set-size"` |
|
|
52
|
+
| `minimize()` | Dock'a ya da görev çubuğuna | `"core:window:allow-minimize"` |
|
|
53
|
+
| `setTheme("light")` | tema | `"core:window:allow-set-theme"` |
|
|
54
|
+
| `close()` | kapatma düğmesinin yaptığı gibi pencerenin kapanmasını ister | `"core:window:allow-close"` |
|
|
55
|
+
| `destroy()` | soru sormadan hemen kapatır | `"core:window:allow-destroy"` |
|
|
56
|
+
|
|
57
|
+
Satırı olmadan promise, satırı adlandıran bir metinle reddedilir. Önce bir hata ayıklama derlemesinde (debug build:
|
|
58
|
+
`cargo tauri dev`, pencere denetimi), sonra derlenmiş uygulamada (bir sürüm derlemesiyle denendi):
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
window.set_title not allowed. Permissions associated with this command: core:window:allow-set-title
|
|
62
|
+
Command plugin:window|minimize not allowed by ACL
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- `innerSize()` ekranın piksellerini verir: Retina bir ekranda 960 x 640'lık pencere için 1920 x 1280; orada
|
|
66
|
+
`scaleFactor()` 2'dir.
|
|
67
|
+
- `document.title` (basic.js'te `page.title`) başlık çubuğunu değiştirmez (denendi): `setTitle()` kullanın.
|
|
68
|
+
- Çekirdeğin bütün satırları: https://tauri.app/reference/acl/core-permissions/
|
|
69
|
+
|
|
70
|
+
## Klasörü izleyen başlık
|
|
71
|
+
|
|
72
|
+
Başlık çubuğu klasörün adını gösterir: "Documents - Tauri Starter". **1.** `src-tauri/capabilities/default.json`
|
|
73
|
+
içindeki `permissions` listesine `"core:window:allow-set-title"` ekleyin. **2.** `ui/backend.js` içinde bir
|
|
74
|
+
fonksiyon (bir tarayıcıda sekmenin başlığını değiştirir):
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
// Pencerenin başlığı (capabilities/default.json içinde core:window:allow-set-title). Bir tarayıcıda: sekme.
|
|
78
|
+
Backend.setWindowTitle = function (title) {
|
|
79
|
+
if (!Backend.isInApp()) {
|
|
80
|
+
page.title = title;
|
|
81
|
+
return Promise.resolve(null);
|
|
82
|
+
}
|
|
83
|
+
return window.__TAURI__.window.getCurrentWindow().setTitle(title);
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**3.** `ui/app.js` içinde: en üstte bir sabit (`const APP_NAME = "Tauri Starter";`), `showFolder()`'ın sonunda
|
|
88
|
+
`showTitle(folder);` satırı ve altında fonksiyon:
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
// Başlık çubuğu klasörü gösterir: "Documents - Tauri Starter"
|
|
92
|
+
const showTitle = function (folder) {
|
|
93
|
+
const lastCrumb = folder.crumbs[folder.crumbs.length - 1];
|
|
94
|
+
Backend.setWindowTitle(lastCrumb.name + " - " + APP_NAME);
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Bunu pencere denetiminin bir adımı kanıtlar (`checks/window-check.js` içinde, "the table shows the entries"
|
|
99
|
+
adımından sonra):
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
const folderName = currentFolder.crumbs[currentFolder.crumbs.length - 1].name;
|
|
103
|
+
const title = await window.__TAURI__.window.getCurrentWindow().title();
|
|
104
|
+
WindowCheck.expect(title == folderName + " - Tauri Starter", "the title of the window follows the folder: " + title);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Satırı: `PASS the title of the window follows the folder: tauri-starter-check-49282 - Tauri Starter`.
|
|
108
|
+
|
|
109
|
+
## Pencere kapanmadan önce
|
|
110
|
+
|
|
111
|
+
`onCloseRequested(handler)`, pencereden kapanması istendiğinde (kapatma düğmesi ya da `close()`) bir fonksiyon
|
|
112
|
+
çalıştırır. Böyle bir fonksiyon varken Tauri pencereyi kendisi kapatmaz: fonksiyonu bekler (fonksiyon bir promise
|
|
113
|
+
verebilir), sonra, fonksiyon `event.preventDefault()` çağırmadıysa, sayfa pencereyi `destroy()` ile kapatır.
|
|
114
|
+
**Bu yüzden `"core:window:allow-destroy"` gerekir.** O olmadan pencere hiç kapanmaz ve konsol şunu yazar:
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
window.destroy not allowed. Permissions associated with this command: core:window:allow-destroy
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
"Sizes" ölçerken bir soru. `ui/backend.js` içinde:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
// handler(event), pencereden kapanması istendiğinde çalışır; event.preventDefault() onu açık tutar.
|
|
124
|
+
// handler bir promise verebilir: pencere onu bekler. NEDEN core:window:allow-destroy: bir handler varken Tauri
|
|
125
|
+
// pencereyi kendisi kapatmaz; handler'dan sonra sayfa kapatır (destroy).
|
|
126
|
+
Backend.onCloseRequested = function (handler) {
|
|
127
|
+
if (!Backend.isInApp()) return;
|
|
128
|
+
window.__TAURI__.window.getCurrentWindow().onCloseRequested(handler);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Sistemin Evet ve Hayır düğmeli bir sorusu (diyalog eklentisi): Evet için true
|
|
132
|
+
Backend.ask = function (question) {
|
|
133
|
+
if (!Backend.isInApp()) return Promise.resolve(window.confirm(question));
|
|
134
|
+
return window.__TAURI__.dialog.ask(question, { title: "Tauri Starter", kind: "warning" });
|
|
135
|
+
};
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`ui/app.js` içinde, `start()` içine `Backend.onCloseRequested(onCloseRequested);` satırı ve fonksiyon:
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
// Rust ölçerken pencereden kapanması istendi: önce bir soru; "No" pencereyi açık tutar
|
|
142
|
+
const onCloseRequested = function (event) {
|
|
143
|
+
if (!Sizes.job) return;
|
|
144
|
+
return Backend.ask("Rust is still measuring the folders. Close the window?").then(function (isSure) {
|
|
145
|
+
if (!isSure) event.preventDefault();
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- `permissions` içinde iki satır: `"core:window:allow-destroy"` ve `ask()` için `"dialog:allow-message"` (o,
|
|
151
|
+
eklentinin `message` komutudur; şablon yalnız `"dialog:allow-open"`'a izin verir: [6. Eklentiler](06-plugins.md)).
|
|
152
|
+
İkincisi olmadan soru reddedilir (denendi):
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
dialog.message not allowed. Permissions associated with this command: dialog:allow-ask, dialog:allow-confirm,
|
|
156
|
+
dialog:allow-message, dialog:default
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- Bir kapatma düğmesinin gönderdiği kapanma isteğiyle denendi (Rust'ta `close()` ile yapıldı); diyalog yerine kodun
|
|
160
|
+
bir cevabı kondu (bir diyalog bir insanı bekler, bu yüzden pencere denetimi onu açamaz): "No" pencereyi açık tuttu;
|
|
161
|
+
kapanmanın sürmesine izin veren bir handler pencereyi kapattı (aşağıdaki ikinci pencere). Soruyu kendiniz
|
|
162
|
+
`cargo tauri dev` içinde deneyin: büyük bir klasörde "Sizes", sonra pencereyi kapatın.
|
|
163
|
+
- Bütün uygulamadan çıkmak (macOS'ta uygulama menüsündeki Quit) bununla denenmedi.
|
|
164
|
+
|
|
165
|
+
Rust da pencereleri duyar, `src-tauri/src/main.rs` içinde (Ör: artık olmayan bir pencerenin işini durdurmak için):
|
|
166
|
+
|
|
167
|
+
```rust
|
|
168
|
+
.on_window_event(|window, event| {
|
|
169
|
+
if let tauri::WindowEvent::Destroyed = event {
|
|
170
|
+
println!("the window {} is closed", window.label());
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## İkinci bir pencere
|
|
176
|
+
|
|
177
|
+
Kendi sayfası olan küçük bir pencere: uygulamanın tuşları. **1. Rust** onu yapar; yeni bir dosya, `src-tauri/src/`
|
|
178
|
+
içinde `windows.rs` (öbür dosyaların başlığıyla), `main.rs` içinde `mod windows;` ve `generate_handler!` içinde
|
|
179
|
+
`windows::open_keys_window` ile eklenir:
|
|
180
|
+
|
|
181
|
+
```rust
|
|
182
|
+
use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
|
|
183
|
+
|
|
184
|
+
const KEYS_LABEL: &str = "keys";
|
|
185
|
+
const KEYS_WIDTH: f64 = 420.0;
|
|
186
|
+
const KEYS_HEIGHT: f64 = 330.0;
|
|
187
|
+
|
|
188
|
+
/// "keys" penceresini açar, ya da açıksa öne getirir
|
|
189
|
+
// NEDEN async: Windows'ta düz bir komutta ya da bir olay işleyicisinde yapılan bir pencere uygulamayı durdurur
|
|
190
|
+
// (WebviewWindowBuilder::new'in "Known issues" bölümü)
|
|
191
|
+
#[tauri::command]
|
|
192
|
+
pub async fn open_keys_window(app: AppHandle) -> Result<(), String> {
|
|
193
|
+
if let Some(window) = app.get_webview_window(KEYS_LABEL) {
|
|
194
|
+
return window.set_focus().map_err(|error| error.to_string());
|
|
195
|
+
}
|
|
196
|
+
WebviewWindowBuilder::new(&app, KEYS_LABEL, WebviewUrl::App("keys.html".into()))
|
|
197
|
+
.title("Keys")
|
|
198
|
+
.inner_size(KEYS_WIDTH, KEYS_HEIGHT)
|
|
199
|
+
.resizable(false)
|
|
200
|
+
.build()
|
|
201
|
+
.map_err(|error| error.to_string())?;
|
|
202
|
+
Ok(())
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Etiket (label, `"keys"`) pencerenin adıdır: bir etikete bir pencere; bu yüzden ikinci bir çağrı onu bulur ve öne
|
|
207
|
+
getirir. `WebviewUrl::App("keys.html")` `ui/` içindeki bir dosyadır. **2. Sayfası**, `ui/` içinde `keys.html`:
|
|
208
|
+
kütüphane, `backend.js` (Tauri'yi çağıran tek yer) ve `keys.js`:
|
|
209
|
+
|
|
210
|
+
```html
|
|
211
|
+
<!DOCTYPE html>
|
|
212
|
+
<html lang="en">
|
|
213
|
+
<head>
|
|
214
|
+
<title>Keys</title>
|
|
215
|
+
<meta charset="UTF-8">
|
|
216
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
217
|
+
<link rel="stylesheet" type="text/css" href="basic/basic.min.css">
|
|
218
|
+
<script src="basic/basic.min.js" type="text/javascript" charset="utf-8"></script>
|
|
219
|
+
<script src="backend.js" type="text/javascript" charset="utf-8"></script>
|
|
220
|
+
<script src="keys.js" type="text/javascript" charset="utf-8"></script>
|
|
221
|
+
</head>
|
|
222
|
+
<body></body>
|
|
223
|
+
</html>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
`ui/` içinde `keys.js`:
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
"use strict";
|
|
230
|
+
|
|
231
|
+
// Ana pencerenin tuşları, her biri bir satır
|
|
232
|
+
const KEYS = [
|
|
233
|
+
"↑ ↓: the row above or below",
|
|
234
|
+
"Page Up / Page Down: a page of rows",
|
|
235
|
+
"Home / End: the first or the last row",
|
|
236
|
+
"Enter: opens the folder of the row",
|
|
237
|
+
"Cmd / Ctrl + ↑: the folder above",
|
|
238
|
+
"Cmd / Ctrl + O: Open... (the folder dialog)",
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
const start = function () {
|
|
242
|
+
|
|
243
|
+
page.color = "white";
|
|
244
|
+
|
|
245
|
+
// GROUP: Uygulamanın adı, sonra her tuş için bir satır
|
|
246
|
+
VGroup({ align: "left top", gap: 10, padding: 24 });
|
|
247
|
+
const lblName = Label({ text: "Tauri Starter", fontSize: 18, bold: 1 });
|
|
248
|
+
KEYS.forEach(function (key) {
|
|
249
|
+
Label({ text: key, fontSize: 14 });
|
|
250
|
+
});
|
|
251
|
+
endGroup();
|
|
252
|
+
|
|
253
|
+
Backend.getAppVersion().then(function (version) {
|
|
254
|
+
lblName.plainText = "Tauri Starter " + version;
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
};
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**3. İki fonksiyon**, `ui/backend.js` içinde (ve örnek verilerin yanında `Backend.SAMPLE_VERSION = "0.1.0";`):
|
|
261
|
+
|
|
262
|
+
```js
|
|
263
|
+
// Kendi sayfası olan ikinci pencere: ui/keys.html (src-tauri/src/windows.rs)
|
|
264
|
+
Backend.openKeysWindow = function () {
|
|
265
|
+
if (!Backend.isInApp()) {
|
|
266
|
+
window.open("keys.html", "keys");
|
|
267
|
+
return Promise.resolve(null);
|
|
268
|
+
}
|
|
269
|
+
return window.__TAURI__.core.invoke("open_keys_window");
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// Uygulamanın sürümü: src-tauri/Cargo.toml içindeki sürüm
|
|
273
|
+
Backend.getAppVersion = function () {
|
|
274
|
+
if (!Backend.isInApp()) return Promise.resolve(Backend.SAMPLE_VERSION);
|
|
275
|
+
return window.__TAURI__.app.getVersion();
|
|
276
|
+
};
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**4. İzinleri.** `capabilities/default.json` `"windows": ["main"]` içindir. Hiçbir listede olmayan bir pencerede
|
|
280
|
+
uygulamanın komutları yine cevap verir (denendi: `list_folder`), ama Tauri'nin hiçbir şeyi vermez, `getVersion()`
|
|
281
|
+
bile. Pencere kendi dosyasını alır, `src-tauri/capabilities/` içinde `keys.json`; içinde yalnız sayfasının
|
|
282
|
+
kullandığı var:
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"$schema": "../gen/schemas/desktop-schema.json",
|
|
287
|
+
"identifier": "keys",
|
|
288
|
+
"description": "The Keys window (ui/keys.html) only reads the version of the app.",
|
|
289
|
+
"windows": ["keys"],
|
|
290
|
+
"permissions": ["core:app:allow-version"]
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
- Denendi: sürüm geldi; o sayfadan gönderilen bir olay reddedildi (`event.emit not allowed on window "keys"`, bütün
|
|
295
|
+
metni [8. Güvenlik](08-security.md) bölümünde).
|
|
296
|
+
- Bir pencere `tauri.conf.json` içinde `app.windows` listesine de, kendi `"label"` ve `"url"` alanlarıyla
|
|
297
|
+
(`"url": "keys.html"`) yazılabilir: uygulamayla birlikte açılır (denendi).
|
|
298
|
+
- Ana sayfa onu `Window.getByLabel("keys")`'in `destroy()`'u ile kapatır (`"core:window:allow-destroy"`).
|
|
299
|
+
|
|
300
|
+
## Uygulamanın menüsü
|
|
301
|
+
|
|
302
|
+
macOS'ta Tauri uygulamaya bir menü verir (çalışan uygulamada okundu): uygulamanın menüsü (About, Services, Hide,
|
|
303
|
+
Hide Others, Quit), File (Close Window), Edit (Undo, Redo, Cut, Copy, Paste, Select All), View (Toggle Full Screen),
|
|
304
|
+
Window (Minimize, Zoom, Close Window) ve boş bir Help. Windows'ta ve Linux'ta şablonun menüsü yoktur (Tauri'nin kodu
|
|
305
|
+
o menüyü yalnız macOS'ta yapar).
|
|
306
|
+
|
|
307
|
+
Kendi menünüz ondan başlar; böylece Quit ve Edit menüsü kalır. Yeni bir dosya, `src-tauri/src/` içinde
|
|
308
|
+
`app_menu.rs` (öbür dosyaların başlığıyla):
|
|
309
|
+
|
|
310
|
+
```rust
|
|
311
|
+
use tauri::menu::{Menu, MenuEvent, MenuItemBuilder, SubmenuBuilder, HELP_SUBMENU_ID};
|
|
312
|
+
use tauri::{AppHandle, Emitter, Wry};
|
|
313
|
+
|
|
314
|
+
// Sayfanın yaptığı öğelerin kimlikleri (ui/app.js: MENU_ACTIONS)
|
|
315
|
+
const PAGE_ITEMS: [&str; 2] = ["home", "keys"];
|
|
316
|
+
|
|
317
|
+
/// Tauri'nin menüsü (macOS'ta: uygulama menüsü, File, Edit, View, Window, Help), "Go" ve "Help" içinde bir öğeyle
|
|
318
|
+
pub fn create(app: &AppHandle) -> tauri::Result<Menu<Wry>> {
|
|
319
|
+
let menu = Menu::default(app)?;
|
|
320
|
+
|
|
321
|
+
let home = MenuItemBuilder::with_id("home", "Home Folder")
|
|
322
|
+
.accelerator("CmdOrCtrl+Shift+H")
|
|
323
|
+
.build(app)?;
|
|
324
|
+
let go = SubmenuBuilder::new(app, "Go").item(&home).build()?;
|
|
325
|
+
// NEDEN son ikiden önce: Window ve Help, öbür uygulamalardaki gibi sonda kalır
|
|
326
|
+
let place = menu.items()?.len() - 2;
|
|
327
|
+
menu.insert(&go, place)?;
|
|
328
|
+
|
|
329
|
+
let keys = MenuItemBuilder::with_id("keys", "Keys of Tauri Starter").build(app)?;
|
|
330
|
+
if let Some(help) = menu.get(HELP_SUBMENU_ID) {
|
|
331
|
+
if let Some(help) = help.as_submenu() {
|
|
332
|
+
help.append(&keys)?;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
Ok(menu)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/// Menünün bir öğesine bir tıklama
|
|
339
|
+
pub fn on_click(app: &AppHandle, event: MenuEvent) {
|
|
340
|
+
let id = event.id().as_ref();
|
|
341
|
+
if PAGE_ITEMS.contains(&id) {
|
|
342
|
+
let _ = app.emit("menu", id);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
`src-tauri/src/main.rs` içinde: `mod app_menu;` ve oluşturucuda (builder) iki satır (`.manage(...)`'dan sonra):
|
|
348
|
+
|
|
349
|
+
```rust
|
|
350
|
+
.menu(app_menu::create)
|
|
351
|
+
.on_menu_event(app_menu::on_click)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Bir tıklama, öğenin kimliğiyle `"menu"` olayını gönderir; sayfa onu kendi düğmesine bir tıklama gibi yapar.
|
|
355
|
+
`ui/app.js` içinde, `start()` içine `Backend.listen("menu", onMenuClick);` satırı ve:
|
|
356
|
+
|
|
357
|
+
```js
|
|
358
|
+
// Menünün öğeleri (src-tauri/src/app_menu.rs): öğenin kimliği -> sayfanın yaptığı
|
|
359
|
+
const MENU_ACTIONS = { home: openHome, keys: Backend.openKeysWindow };
|
|
360
|
+
|
|
361
|
+
const onMenuClick = function (itemId) {
|
|
362
|
+
const action = MENU_ACTIONS[itemId];
|
|
363
|
+
if (action) action();
|
|
364
|
+
};
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
- Neden sayfa üzerinden: bir düğmenin ve onun menü öğesinin yaptığı için tek bir yer; ayrıca Keys penceresini
|
|
368
|
+
menü işleyicisi değil, `async` bir komut yapar (yukarıdaki Windows sorunu).
|
|
369
|
+
- macOS'ta denendi, öğeler bir betikle tıklandı: Go > Home Folder ev klasörünü açtı, Help > Keys of Tauri Starter
|
|
370
|
+
ikinci pencereyi açtı.
|
|
371
|
+
- `.menu(...)` ile Tauri menüyü Windows'ta ve Linux'ta her pencereye verir (pencerede bir çubuk): bir sürümden önce
|
|
372
|
+
orada ona bakın.
|
|
373
|
+
- Pencere denetimi bir menüye tıklayamaz: öğenin olayını kendisi gönderir,
|
|
374
|
+
`window.__TAURI__.event.emit("menu", "keys")`, sonra `keys` penceresini bekler.
|
|
375
|
+
- İşaretli öğeler, menüde simgeler, tek bir pencerenin menüsü: https://tauri.app/learn/window-menu/
|
|
376
|
+
|
|
377
|
+
## Menü çubuğunda bir simge
|
|
378
|
+
|
|
379
|
+
Saatin yanında, menüsüyle birlikte uygulamanın bir simgesi (tray), Rust'ta oluşturucunun `.setup(...)` kısmında
|
|
380
|
+
`tauri::tray::TrayIconBuilder` ile yapılır ve `src-tauri/Cargo.toml` içinde `tauri` crate'inin bir özelliğini
|
|
381
|
+
(feature) ister: `tauri = { version = "2", features = ["tray-icon"] }` (`cargo tauri build` satırı bırakır:
|
|
382
|
+
denendi). Tauri, menüsündeki tıklamaları yukarıdaki menününkilerle aynı `on_menu_event`'e verir. Tauri'nin
|
|
383
|
+
rehberi: https://tauri.app/learn/system-tray/
|
|
384
|
+
|
|
385
|
+
## Uygulamanın klasörleri
|
|
386
|
+
|
|
387
|
+
Her sistemde bir uygulamanın verileri için, `identifier`'ından ad alan klasörler vardır. Rust `app.path()`'e sorar
|
|
388
|
+
(`use tauri::Manager;` ile), sayfa `window.__TAURI__.path`'e (`core:default` izin verir). macOS'ta (2026-11-27):
|
|
389
|
+
|
|
390
|
+
| Rust | Sayfa | macOS |
|
|
391
|
+
|---|---|---|
|
|
392
|
+
| `app_config_dir()` | `appConfigDir()` | `~/Library/Application Support/io.github.bug7a.tauri-starter` |
|
|
393
|
+
| `app_data_dir()`, `app_local_data_dir()` | `appDataDir()`, `appLocalDataDir()` | aynı klasör |
|
|
394
|
+
| `app_cache_dir()` | `appCacheDir()` | `~/Library/Caches/io.github.bug7a.tauri-starter` |
|
|
395
|
+
| `app_log_dir()` | `appLogDir()` | `~/Library/Logs/io.github.bug7a.tauri-starter` |
|
|
396
|
+
| `home_dir()` | `homeDir()` | ev klasörü (boş bir yol için `list_folder` onu açar) |
|
|
397
|
+
| `temp_dir()` | `tempDir()` | sistemin geçici klasörü |
|
|
398
|
+
|
|
399
|
+
- `identifier`'ı ilk sürümden önce değiştirin ([2. Proje](02-the-project.md)): eskisinin verileri eski adın
|
|
400
|
+
klasörlerinde kalır.
|
|
401
|
+
- Klasör henüz olmayabilir: Rust onu ilk dosyadan önce yapar, `std::fs::create_dir_all(&folder)`.
|
|
402
|
+
- Rust'ta: `let data_folder = app.path().app_data_dir().map_err(|error| error.to_string())?;` (8. bölümün komutu
|
|
403
|
+
notlarını `data_folder.join("notes")` içinden okur).
|
|
404
|
+
- Sayfanın iki çalıştırma arasında tuttuğu ayarlar (son klasör, "Hidden files"): store eklentisi onları bu
|
|
405
|
+
klasörlerden birindeki bir dosyada tutar, Rust olmadan ([6. Eklentiler](06-plugins.md)).
|
|
406
|
+
|
|
407
|
+
## Açık ve koyu
|
|
408
|
+
|
|
409
|
+
Pencere sistemin görünümünü alır, sayfa da bunu bilir. Koyu görünümlü bir Mac'te denendi:
|
|
410
|
+
|
|
411
|
+
| Pencerenin `theme`'i | `theme()` | `matchMedia("(prefers-color-scheme: dark)").matches` |
|
|
412
|
+
|---|---|---|
|
|
413
|
+
| yazılmamış | `"dark"` | `true` |
|
|
414
|
+
| `"Light"` | `"light"` | `false` |
|
|
415
|
+
|
|
416
|
+
- Şablonun sayfasında yalnız açık renkler var, bu yüzden penceresinin `tauri.conf.json` içinde `"theme": "Light"`
|
|
417
|
+
alanı vardır: koyu bir sistemde pencere sayfanın görünümünü korur. İki görünümü de olan bir sayfa bu alanı yazmaz.
|
|
418
|
+
- İki görünümü de olan bir sayfa, medya sorgusunu `start()` içinde okur ve bileşenlere koyu stil paketlerini verir
|
|
419
|
+
(`styleName`, her bileşenin başlığında).
|
|
420
|
+
- Sayfadan `setTheme()`, `"core:window:allow-set-theme"` ister.
|
|
421
|
+
|
|
422
|
+
## Bir seferde bir kopya, çalıştırmalar arasında boyut
|
|
423
|
+
|
|
424
|
+
Bu el kitabında denenmedi; ikisi de eklentidir ([6. Eklentiler](06-plugins.md) bölümünün yolu):
|
|
425
|
+
|
|
426
|
+
- Uygulamanın bir seferde tek kopyası (uygulamanın ikinci bir başlatılışı onun yerine ilkinin bir fonksiyonunu
|
|
427
|
+
çalıştırır): https://tauri.app/plugin/single-instance/
|
|
428
|
+
- Pencerenin iki çalıştırma arasında tutulan boyutu ve yeri: https://tauri.app/plugin/window-state/
|
|
429
|
+
|
|
430
|
+
## Sonraki
|
|
431
|
+
|
|
432
|
+
[8. Güvenlik](08-security.md): sayfanın neyi yükleyip çalıştırabileceği, her pencerenin neyi çağırabileceği ve kendi
|
|
433
|
+
kendini koruyan komutlar.
|