diff --git a/README.md b/README.md index c58e8caf..681e8c89 100644 --- a/README.md +++ b/README.md @@ -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. 修复代码块样式 diff --git a/frontend/src/components/View.vue b/frontend/src/components/View.vue index 1fc2af01..da24dbe2 100644 --- a/frontend/src/components/View.vue +++ b/frontend/src/components/View.vue @@ -536,7 +536,7 @@ button:hover { @media print { .view table.hljs-ln td { - white-space: normal; + white-space: pre-wrap; } .view .run-in-xterm { diff --git a/frontend/src/components/Xterm.vue b/frontend/src/components/Xterm.vue index a593bf03..507f157c 100644 --- a/frontend/src/components/Xterm.vue +++ b/frontend/src/components/Xterm.vue @@ -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; diff --git a/frontend/src/file.js b/frontend/src/file.js index d5056baa..41dbd343 100644 --- a/frontend/src/file.js +++ b/frontend/src/file.js @@ -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) { diff --git a/frontend/src/pages/Home.vue b/frontend/src/pages/Home.vue index a5c78cf5..a5cd6e88 100644 --- a/frontend/src/pages/Home.vue +++ b/frontend/src/pages/Home.vue @@ -8,7 +8,7 @@
-
+
- +
@@ -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; }