1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

Merge pull request #1011 from anytypeio/feature/CU-g98fkm

Feature/cu-g98fkm
This commit is contained in:
Razor 2021-04-07 11:39:21 +03:00 committed by GitHub
commit 688533c62f
60 changed files with 815 additions and 555 deletions

View file

@ -29,6 +29,7 @@ try { env = JSON.parse(fs.readFileSync(envPath)); } catch (e) {};
let isUpdating = false;
let userPath = app.getPath('userData');
let tmpPath = path.join(userPath, 'tmp');
let waitLibraryPromise;
let useGRPC = !process.env.ANYTYPE_USE_ADDON && (env.USE_GRPC || process.env.ANYTYPE_USE_GRPC || (process.platform == "win32") || is.development);
let defaultChannel = version.match('alpha') ? 'alpha' : 'latest';
@ -65,9 +66,7 @@ if (app.isPackaged && !app.requestSingleInstanceLock()) {
storage.setDataPath(userPath);
if (process.env.DATA_PATH) {
try {
fs.mkdirSync(process.env.DATA_PATH);
} catch (err) {};
try { fs.mkdirSync(process.env.DATA_PATH); } catch (e) {};
dataPath.push(process.env.DATA_PATH);
} else {
@ -78,6 +77,8 @@ if (process.env.DATA_PATH) {
dataPath.push('data');
};
try { fs.mkdirSync(tmpPath); } catch (e) {};
if (useGRPC) {
console.log('Connect via gRPC');
@ -295,6 +296,20 @@ function createWindow () {
send.apply(this, args);
});
ipcMain.on('screenshot', (event, arg) => {
win.webContents.capturePage().then((image) => {
const fp = path.join(tmpPath, 'screenshot.jpg');
fs.writeFile(fp, image.toJPEG(90), (err) => {
if (err) {
throw err;
};
send('commandEditor', 'screenshot', fp);
});
});
});
ipcMain.on('winCommand', (e, cmd) => {
switch (cmd) {
case 'menu':
@ -660,8 +675,6 @@ app.on('activate', () => {
});
function send () {
console.log('SEND', arguments);
if (win) {
win.webContents.send.apply(win.webContents, arguments);
};