mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
updates for v0.1.0, update some js packages
This commit is contained in:
parent
8a7a114671
commit
daeef7a4d0
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Prompt",
|
"name": "Prompt",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"main": "dist/emain.js",
|
"main": "dist/emain.js",
|
||||||
"license": "Proprietary",
|
"license": "Proprietary",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
28
src/emain.ts
28
src/emain.ts
@ -20,6 +20,8 @@ let DistDir = (isDev ? "dist-dev" : "dist");
|
|||||||
let GlobalAuthKey = "";
|
let GlobalAuthKey = "";
|
||||||
let instanceId = uuidv4();
|
let instanceId = uuidv4();
|
||||||
let oldConsoleLog = console.log;
|
let oldConsoleLog = console.log;
|
||||||
|
let wasActive = true;
|
||||||
|
let wasInFg = true;
|
||||||
|
|
||||||
// these are either "darwin/amd64" or "darwin/arm64"
|
// these are either "darwin/amd64" or "darwin/arm64"
|
||||||
// normalize darwin/x64 to darwin/amd64 for GOARCH compatibility
|
// normalize darwin/x64 to darwin/amd64 for GOARCH compatibility
|
||||||
@ -180,6 +182,9 @@ function createMainWindow(clientData) {
|
|||||||
let indexHtml = (isDev ? "index-dev.html" : "index.html");
|
let indexHtml = (isDev ? "index-dev.html" : "index.html");
|
||||||
win.loadFile(path.join(getAppBasePath(), "static", indexHtml));
|
win.loadFile(path.join(getAppBasePath(), "static", indexHtml));
|
||||||
win.webContents.on("before-input-event", (e, input) => {
|
win.webContents.on("before-input-event", (e, input) => {
|
||||||
|
if (win.isFocused()) {
|
||||||
|
wasActive = true;
|
||||||
|
}
|
||||||
if (input.type != "keyDown") {
|
if (input.type != "keyDown") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -250,6 +255,10 @@ function createMainWindow(clientData) {
|
|||||||
win.webContents.on("will-navigate", shNavHandler);
|
win.webContents.on("will-navigate", shNavHandler);
|
||||||
win.on("resized", debounce(400, mainResizeHandler));
|
win.on("resized", debounce(400, mainResizeHandler));
|
||||||
win.on("moved", debounce(400, mainResizeHandler));
|
win.on("moved", debounce(400, mainResizeHandler));
|
||||||
|
win.on("focus", () => {
|
||||||
|
wasInFg = true;
|
||||||
|
wasActive = true;
|
||||||
|
});
|
||||||
win.on("close", () => {
|
win.on("close", () => {
|
||||||
MainWindow = null;
|
MainWindow = null;
|
||||||
});
|
});
|
||||||
@ -483,6 +492,24 @@ async function sleep(ms) {
|
|||||||
return new Promise((resolve, reject) => setTimeout(resolve, ms));
|
return new Promise((resolve, reject) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logActiveState() {
|
||||||
|
let activeState = {fg: wasInFg, active: wasActive, open: true};
|
||||||
|
let url = getBaseHostPort() + "/api/log-active-state";
|
||||||
|
let fetchHeaders = getFetchHeaders();
|
||||||
|
fetch(url, {method: "post", body: JSON.stringify(activeState), headers: fetchHeaders}).then((resp) => handleJsonFetchResponse(url, resp)).catch((err) => {
|
||||||
|
console.log("error logging active state", err)
|
||||||
|
});
|
||||||
|
// for next iteration
|
||||||
|
wasInFg = (MainWindow != null && MainWindow.isFocused());
|
||||||
|
wasActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this isn't perfect, but gets the job done without being complicated
|
||||||
|
function runActiveTimer() {
|
||||||
|
logActiveState();
|
||||||
|
setTimeout(runActiveTimer, 60000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ====== MAIN ====== //
|
// ====== MAIN ====== //
|
||||||
|
|
||||||
@ -501,6 +528,7 @@ async function sleep(ms) {
|
|||||||
console.log(e.toString());
|
console.log(e.toString());
|
||||||
}
|
}
|
||||||
await sleep(1000); // TODO remove this sleep, poll getClientData() in createMainWindow
|
await sleep(1000); // TODO remove this sleep, poll getClientData() in createMainWindow
|
||||||
|
setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe
|
||||||
await app.whenReady();
|
await app.whenReady();
|
||||||
await createMainWindowWrap();
|
await createMainWindowWrap();
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
|
@ -3,7 +3,7 @@ const merge = require('webpack-merge');
|
|||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const CopyPlugin = require("copy-webpack-plugin");
|
const CopyPlugin = require("copy-webpack-plugin");
|
||||||
const VERSION = "v0.1.0";
|
const VERSION = "v0.1.1";
|
||||||
|
|
||||||
var merged = merge.merge(common, {
|
var merged = merge.merge(common, {
|
||||||
mode: "development",
|
mode: "development",
|
||||||
|
@ -2,7 +2,7 @@ const webpack = require('webpack');
|
|||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
const common = require('./webpack.electron.js');
|
const common = require('./webpack.electron.js');
|
||||||
const moment = require("dayjs");
|
const moment = require("dayjs");
|
||||||
const VERSION = "v0.1.0";
|
const VERSION = "v0.1.1";
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
function makeBuildStr() {
|
function makeBuildStr() {
|
||||||
|
@ -2,7 +2,7 @@ const webpack = require('webpack');
|
|||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
const moment = require("dayjs");
|
const moment = require("dayjs");
|
||||||
const VERSION = "v0.1.0";
|
const VERSION = "v0.1.1";
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
function makeBuildStr() {
|
function makeBuildStr() {
|
||||||
|
Loading…
Reference in New Issue
Block a user