@thirty-coder/electron-base-kit 0.2.1 → 0.2.2
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 +1 -1
- package/dist/index.js +11 -3
- package/package.json +2 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -104,13 +104,15 @@ function initSettings() {
|
|
|
104
104
|
filePath = (0, import_node_path.join)(import_electron.app.getPath("userData"), "settings.json");
|
|
105
105
|
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(filePath), { recursive: true });
|
|
106
106
|
store = load();
|
|
107
|
-
|
|
107
|
+
const flushNow = () => {
|
|
108
108
|
if (timer) {
|
|
109
109
|
clearTimeout(timer);
|
|
110
110
|
timer = null;
|
|
111
111
|
}
|
|
112
112
|
writeNow();
|
|
113
|
-
}
|
|
113
|
+
};
|
|
114
|
+
import_electron.app.on("before-quit", flushNow);
|
|
115
|
+
import_electron.app.on("will-quit", flushNow);
|
|
114
116
|
}
|
|
115
117
|
var settings = {
|
|
116
118
|
get(key, fallback) {
|
|
@@ -274,6 +276,7 @@ function attachPersistence(win, key) {
|
|
|
274
276
|
timer2 = null;
|
|
275
277
|
}
|
|
276
278
|
save();
|
|
279
|
+
void settings.flush();
|
|
277
280
|
});
|
|
278
281
|
}
|
|
279
282
|
var guarded = /* @__PURE__ */ new Set();
|
|
@@ -335,7 +338,12 @@ function createWindow(options) {
|
|
|
335
338
|
}
|
|
336
339
|
});
|
|
337
340
|
if (maximized) win.maximize();
|
|
338
|
-
win.once("ready-to-show", () =>
|
|
341
|
+
win.once("ready-to-show", () => {
|
|
342
|
+
win.show();
|
|
343
|
+
if (!remember) return;
|
|
344
|
+
if (win.isMaximized() || win.isMinimized() || win.isFullScreen()) return;
|
|
345
|
+
settings.set(`${key}.bounds`, win.getBounds());
|
|
346
|
+
});
|
|
339
347
|
if (process.env.ELECTRON_RENDERER_URL) {
|
|
340
348
|
win.loadURL(process.env.ELECTRON_RENDERER_URL);
|
|
341
349
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thirty-coder/electron-base-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Electron 桌面应用基础能力",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsup",
|
|
24
24
|
"dev": "tsup --watch",
|
|
25
|
+
"test": "tsup && node --test test/*.test.cjs",
|
|
25
26
|
"typecheck": "tsc --noEmit",
|
|
26
27
|
"release": "node scripts/release.mjs"
|
|
27
28
|
},
|