Skip to content

Commit

Permalink
build macOS version
Browse files Browse the repository at this point in the history
  • Loading branch information
junyiz committed Jun 3, 2022
1 parent da48c6f commit bd24daa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
}
.output {
font-size: 12px;
height: 222px;
overflow-y: auto;
}
a {
Expand All @@ -68,7 +69,7 @@
<div id="app">
<div class="userid"><label for="uid">UID:</label> <input name="uid" id="uid" /></div>
<div class="cookie"><label for="cookie">Cookie:</label><textarea name="cookie" id="cookie"></textarea></div>
<div class="help"><a href="https://gitee.com/junyiz/dature#%E5%A6%82%E4%BD%95%E6%9F%A5%E7%9C%8B%E6%96%B0%E6%B5%AA%E5%8D%9A%E5%AE%A2%E7%9A%84-uid">点击查看如何获取是 UID 和 Cookie?</a></div>
<div class="help"><a id="help" href="https://gitee.com/junyiz/dature#%E5%A6%82%E4%BD%95%E6%9F%A5%E7%9C%8B%E6%96%B0%E6%B5%AA%E5%8D%9A%E5%AE%A2%E7%9A%84-uid">点击查看如何获取是 UID 和 Cookie?</a></div>
<div class="button"><a id="btn">确定</a></div>
<div class="output" id="out"></div>
</div>
Expand Down
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 <junyime@qq.com>",
Expand Down
10 changes: 9 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -15,13 +16,20 @@ window.addEventListener('DOMContentLoaded', () => {

const dir = join(process.cwd(), `./blog-${uid}`)

console.log = (log) => out.innerHTML += log.replace('\n', '<br>')
console.log = (log) => out.innerHTML += log.replace('\n', '<br>') + '<br>'

fetch(dir, uid, cookie).then(function() {
console.log(`\n备份完毕, 博客存储目录:<a href="${dir}/index.html">${dir}</a>\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()
Expand Down

0 comments on commit bd24daa

Please sign in to comment.