From bd24daa92cb611c11c0dbdd8e9566cab1a61a721 Mon Sep 17 00:00:00 2001 From: junyiz Date: Fri, 3 Jun 2022 16:59:05 +0800 Subject: [PATCH] build macOS version --- index.html | 3 ++- package.json | 14 +++++++++++--- preload.js | 10 +++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 0846098..bb613c3 100644 --- a/index.html +++ b/index.html @@ -57,6 +57,7 @@ } .output { font-size: 12px; + height: 222px; overflow-y: auto; } a { @@ -68,7 +69,7 @@
- +
diff --git a/package.json b/package.json index 1a2d175..30bb66b 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,9 @@ "build": "pkg .", "build:macos": "pkg . -t node12-macos-x64 -o ./dist/dature-macos -d", "test": "echo \"Error: no test specified\" && exit 1", - "dist": "electron-builder --win --x64" + "dist": "npm run dist:mac && npm run dist:win", + "dist:mac": "electron-builder --mac --x64", + "dist:win": "electron-builder --win --x64" }, "keywords": [ "data", @@ -57,10 +59,16 @@ "build": { "appId": "cn.dature.app", "mac": { - "target": ["dmg", "zip"] + "target": [ + "dmg", + "zip" + ] }, "win": { - "target": ["nsis", "zip"] + "target": [ + "nsis", + "zip" + ] } }, "author": "Junyi Zhang ", diff --git a/preload.js b/preload.js index 4af37d9..9dac13a 100644 --- a/preload.js +++ b/preload.js @@ -1,6 +1,7 @@ const fetch = require('./lib/fetch') const join = require('path').join const { shell } = require('electron') +const { help } = require('yargs') const $ = (selector) => document.getElementById(selector) @@ -15,13 +16,20 @@ window.addEventListener('DOMContentLoaded', () => { const dir = join(process.cwd(), `./blog-${uid}`) - console.log = (log) => out.innerHTML += log.replace('\n', '
') + console.log = (log) => out.innerHTML += log.replace('\n', '
') + '
' fetch(dir, uid, cookie).then(function() { console.log(`\n备份完毕, 博客存储目录:${dir}\n`) }) }) + $('help').addEventListener('click', (event) => { + if (event.target.tagName === 'A') { + event.preventDefault() + shell.openExternal(event.target.href) + } + }) + out.addEventListener('click', (event) => { if (event.target.tagName === 'A') { event.preventDefault()