Merge branch 'release/1.18.2'

This commit is contained in:
purocean
2019-03-21 16:49:00 +08:00
5 changed files with 35 additions and 10 deletions
+5 -1
View File
@@ -97,7 +97,7 @@
+ 内置终端 [XTERM.JS](https://xtermjs.org/) [node-pty](https://github.com/Microsoft/node-pty)
## 开发贡献
+ 后端: `cd backend; node main.js`
+ 前端: `cd backend; node main.js`
+ 后端: `cd frontend; yarn run dev`
## 捐赠
@@ -117,6 +117,10 @@
## 更新日志
[最新发布](https://github.com/purocean/yn/releases)
### [v1.18.2](https://github.com/purocean/yn/releases/tag/v1.18.2) 2019-03-21
1. 保存加密文件密码不一致时增加提示
1. 修复样式问题
### [v1.18.1](https://github.com/purocean/yn/releases/tag/v1.18.1) 2019-03-01
1. 修复目录样式
1. 修复代码块样式
+1 -1
View File
@@ -536,7 +536,7 @@ button:hover {
@media print {
.view table.hljs-ln td {
white-space: normal;
white-space: pre-wrap;
}
.view .run-in-xterm {
-1
View File
@@ -126,7 +126,6 @@ export default {
box-sizing: border-box;
padding: 5px;
padding-bottom: 20px;
height: 40vh;
background: rgb(29, 31, 33);
border: 1px solid rgb(92, 91, 100);
flex: 0 0 auto;
+18 -4
View File
@@ -13,6 +13,7 @@ const getCryptKey = () => {
const encrypt = content => {
let key = getCryptKey()
let iv = key
const passwordHash = CryptoJS.MD5(key).toString()
key = CryptoJS.enc.Utf8.parse(key)
iv = CryptoJS.enc.Utf8.parse(iv)
@@ -23,12 +24,13 @@ const encrypt = content => {
padding: CryptoJS.pad.Pkcs7
})
return encrypted.toString()
return {content: encrypted.toString(), passwordHash}
}
const decrypt = content => {
let key = getCryptKey()
let iv = key
const passwordHash = CryptoJS.MD5(key).toString()
key = CryptoJS.enc.Utf8.parse(key)
iv = CryptoJS.enc.Utf8.parse(iv)
@@ -44,9 +46,10 @@ const decrypt = content => {
throw new Error('解密失败!!!')
}
return result
return {content: result, passwordHash}
}
const oldPasswordHash = {}
export default {
read: (repo, path, call, ecall) => {
fetch(`/api/file?path=${encodeURIComponent(path)}&repo=${repo}`).then(response => {
@@ -55,7 +58,9 @@ export default {
try {
let content = result.data.content
if (path.endsWith('.c.md')) {
content = decrypt(content)
const data = decrypt(content)
content = data.content
oldPasswordHash[`${repo}_${path}`] = data.passwordHash
}
call(content, result.data.hash)
@@ -75,7 +80,16 @@ export default {
write: (repo, path, content, oldHash, call, ecall) => {
try {
if (path.endsWith('.c.md')) {
content = encrypt(content)
const data = encrypt(content)
const oldPasswdHash = oldPasswordHash[`${repo}_${path}`]
if (oldPasswdHash) {
if (oldPasswdHash !== data.passwordHash && !window.confirm('密码和上一次输入的密码不一致,是否用新密码保存?')) {
return
}
delete oldPasswordHash[`${repo}_${path}`]
}
content = data.content
}
} catch (e) {
if (ecall) {
+11 -3
View File
@@ -8,7 +8,7 @@
<div style="display: flex; justify-content: space-between;" :class="{'show-view': showView}">
<Tree ref="tree" class="tree" v-model="file"></Tree>
<div class="content" style="flex-direction: column;">
<div class="content">
<div :class="{content: true, 'show-xterm': showXterm}">
<Editor
ref="editor"
class="editor"
@@ -29,7 +29,7 @@
@sync-scroll="syncScrollEditor"
@switch-todo="switchTodoEditor"></XView>
</div>
<Xterm ref="xterm" v-show="showXterm"></Xterm>
<Xterm ref="xterm" v-show="showXterm" class="xterm"></Xterm>
</div>
</div>
<div class="status-bar">
@@ -294,6 +294,14 @@ export default {
display: flex;
height: 95vh;
}
.content.show-xterm {
height: 55vh;
}
.xterm {
height: 40vh;
}
}
@media (max-width: 767px) {
@@ -327,7 +335,7 @@ export default {
width: 100%;
}
.editor, .header, .tree, .status-bar {
.editor, .header, .tree, .status-bar, .xterm {
display: none;
}