-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
158 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ | |
.DS_store | ||
blog-* | ||
node_modules | ||
|
||
out | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Dature:新浪博客备份工具</title> | ||
<style> | ||
body { | ||
background-color: #484d5d; | ||
background-image: url(assets/bg.png); | ||
color: azure; | ||
} | ||
#app { | ||
padding: 20px 0; | ||
margin-left: auto; | ||
margin-right: auto; | ||
width: 420px; | ||
} | ||
label { | ||
width: 70px; | ||
display: inline-block; | ||
} | ||
.userid { | ||
display: flex; | ||
margin-bottom: 20px; | ||
} | ||
input[name=uid] { | ||
flex: 1; | ||
height: 30px; | ||
line-height: 30px; | ||
border-radius: 3px; | ||
} | ||
.cookie { | ||
display: flex; | ||
margin-bottom: 20px; | ||
} | ||
textarea[name=cookie] { | ||
flex: 1; | ||
height: 120px; | ||
border-radius: 3px; | ||
} | ||
.button { | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
.button a { | ||
cursor: pointer; | ||
display: inline-block; | ||
width: 80px; | ||
line-height: 30px; | ||
border-radius: 3px; | ||
border: 1px dashed #e2e2e2; | ||
} | ||
.help { | ||
font-size: 14px; | ||
padding-left: 70px; | ||
margin-bottom: 20px; | ||
} | ||
.output { | ||
font-size: 12px; | ||
overflow-y: auto; | ||
} | ||
a { | ||
color: darkseagreen; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<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="button"><a id="btn">确定</a></div> | ||
<div class="output" id="out"></div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { app, BrowserWindow } = require('electron') | ||
const path = require('path') | ||
|
||
const createWindow = () => { | ||
const win = new BrowserWindow({ | ||
width: 528, | ||
height: 600, | ||
webPreferences: { | ||
preload: path.join(__dirname, 'preload.js') | ||
} | ||
}) | ||
|
||
win.loadFile('index.html') | ||
} | ||
|
||
app.whenReady().then(() => { | ||
createWindow() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fetch = require('./lib/fetch') | ||
const join = require('path').join | ||
const { shell } = require('electron') | ||
|
||
const $ = (selector) => document.getElementById(selector) | ||
|
||
window.addEventListener('DOMContentLoaded', () => { | ||
const btn = $('btn') | ||
const out = $('out') | ||
|
||
btn.addEventListener('click', () => { | ||
const uid = $('uid').value | ||
const cookie = ($('cookie').value || '') | ||
.replace(/(NowDate|BLOG_TITLE|mblog_userinfo)[^;]*;/g, '') | ||
|
||
const dir = join(process.cwd(), `./blog-${uid}`) | ||
|
||
console.log = (log) => out.innerHTML += log.replace('\n', '<br>') | ||
|
||
fetch(dir, uid, cookie).then(function() { | ||
console.log(`\n备份完毕, 博客存储目录:<a href="${dir}/index.html">${dir}</a>\n`) | ||
}) | ||
}) | ||
|
||
out.addEventListener('click', (event) => { | ||
if (event.target.tagName === 'A') { | ||
event.preventDefault() | ||
shell.openExternal(event.target.href) | ||
} | ||
}) | ||
}) |