Skip to content

Commit 8c21d9f

Browse files
committed
Merge branch 'master' into develop
2 parents 1f4602b + d9dded0 commit 8c21d9f

10 files changed

Lines changed: 95 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
## v0.9.1
2+
3+
`2020-01-01`
4+
5+
- 修复首次安装使用 Gridea,无法预览 BUG
6+
7+
## v0.9.0
8+
9+
`2019-12-28`
10+
11+
**注意:若你之前有手动放置文件或文件夹到构建后文件夹(output 文件夹)本次升级有非兼容升级,请看下升级说明,若没有,可直接升级啦**
12+
13+
升级说明:
14+
需手动复制到博客源文件夹的 static 文件夹(若无此文件夹可新建一个,新版使用时会自动生成,有静态文件需求的可放在此文件夹,构建时会直接复制到 output 文件夹)
15+
16+
17+
## 新增
18+
- 新增 SFTP 部署
19+
- 新增文章置顶功能
20+
- 自定义配置支持图片类型和数组类型,增加文章数据卡片类型
21+
- 自定义归档路径前缀
22+
- 文章页与标签页支持精简 URL 与默认 URL
23+
- 新增菜单拖动排序
24+
- 支持自定义模板渲染,具体可见[Gridea 文档](https://gridea.dev/docs)
25+
26+
27+
## 修复
28+
- 修复更改文章 URL 大小写会删除文章的 bug
29+
- 修复编辑器超出一屏后回车不会滚动的 bug
30+
- 修复 Linux(Ubuntu)初始化配置时,检测远程链接失败的 BUG
31+
32+
## 优化
33+
- 文章内图片支持懒加载(基于 chrome 的lazy loading)
34+
- 升级 Electron 至 7.x
35+
- 标签页支持渲染列表隐藏文章(break change)
36+
- 增加预览唤出快捷键(Ctrl + P)
37+
- 优化编辑器 Windows 下字体显示
38+
- 增加渲染过程错误日志弹窗
39+
- 增加应用内通知系统
40+
141
## v0.8.3
242

343
`2019-09-23`

gridea-app-en.png

-123 KB
Loading

gridea-app.png

-183 KB
Loading

src/assets/locales.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ const message = {
7373
change: '更 换',
7474
editorTip: '你可以插入单独行的 <!-- more --> 为摘要分隔标识(此行之前内容为摘要)',
7575
saveError: '保存失败',
76+
privateKeyTip: '请填写绝对路径,例如:/home/username/.ssh/id_rsa',
77+
remotePathTip: '请填写绝对路径,例如:/home/username/www/',
7678
testConnection: '检测远程连接',
7779
connectSuccess: '远程连接成功',
7880
connectFailed: '远程连接失败,请检查仓库、用户名和 Token 设置',
@@ -182,6 +184,8 @@ const message = {
182184
change: '更 換',
183185
editorTip: '你可以插入單獨行的 <!-- more --> 為摘要分隔標識(此行之前內容為摘要)',
184186
saveError: '保存失敗',
187+
privateKeyTip: '請填寫絕對路徑,例如:/home/username/.ssh/id_rsa',
188+
remotePathTip: '請填寫絕對路徑,例如:/home/username/www/',
185189
testConnection: '檢測遠程連接',
186190
connectSuccess: '遠程連接成功',
187191
connectFailed: '遠程連接失敗,請檢查倉庫、用戶名和 Token 設置',
@@ -290,6 +294,8 @@ const message = {
290294
change: 'Change',
291295
editorTip: 'You can insert a separate line <!-- more --> is the abstract separator identifier ( the content before this line is the abstract)',
292296
saveError: 'Save failed',
297+
privateKeyTip: 'Please fill in the absolute path, for example: /home/username/.ssh/id_rsa',
298+
remotePathTip: 'Please fill in the absolute path, for example::/home/username/www/',
293299
testConnection: 'Test Connection',
294300
connectSuccess: 'Remote connection succeeded',
295301
connectFailed: 'Remote connection failed, please check repository, username and token settings',

src/interfaces/setting.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface ISetting {
1010
port: string
1111
server: string
1212
password: string
13+
privateKey: string
1314
remotePath: string
1415
[index: string]: string
1516
}

src/server/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default class App {
7575
port: '22',
7676
server: '',
7777
password: '',
78+
privateKey: '',
7879
remotePath: '',
7980
},
8081
commentSetting: {

src/server/plugins/deploys/sftp.ts

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import * as fse from 'fs-extra'
2+
// import * as fs from 'fs'
23
import path from 'path'
34
import SftpClient from 'ssh2-sftp-client'
45
import NodeSsh from 'node-ssh'
56
import normalizePath from 'normalize-path'
67
import Model from '../../model'
78

9+
type sftpConnectConfig = {
10+
host: string;
11+
port: number;
12+
type?: string;
13+
username: string;
14+
password?: string;
15+
privateKey?: string | Buffer;
16+
}
17+
818
export default class SftpDeploy extends Model {
919
// connect: SftpClient
1020
constructor(appInstance: any) {
@@ -22,11 +32,24 @@ export default class SftpDeploy extends Model {
2232
const client = new SftpClient()
2333

2434
const { setting } = this.db
25-
const connectConfig = {
35+
36+
const connectConfig: sftpConnectConfig = {
2637
host: setting.server,
2738
port: Number(setting.port),
2839
username: setting.username,
29-
password: setting.password,
40+
}
41+
42+
if (setting.privateKey) {
43+
try {
44+
connectConfig.privateKey = fse.readFileSync(setting.privateKey)
45+
} catch (e) {
46+
console.error('SFTP Test Remote Error: ', e.message)
47+
result.success = false
48+
result.message = e.message
49+
return result
50+
}
51+
} else {
52+
connectConfig.password = setting.password
3053
}
3154

3255
const testFilename = 'gridea.txt'
@@ -58,7 +81,7 @@ export default class SftpDeploy extends Model {
5881
} finally {
5982
await client.end()
6083
}
61-
84+
6285
return result
6386
}
6487

@@ -71,12 +94,19 @@ export default class SftpDeploy extends Model {
7194
const client = new NodeSsh()
7295

7396
const { setting } = this.db
74-
const connectConfig = {
97+
98+
const connectConfig: sftpConnectConfig = {
7599
host: setting.server,
76100
port: Number(setting.port),
77-
username: setting.username,
78-
password: setting.password,
79101
type: 'sftp',
102+
username: setting.username,
103+
}
104+
105+
// node-ssh: privateKey is path string.
106+
if (setting.privateKey) {
107+
connectConfig.privateKey = setting.privateKey
108+
} else {
109+
connectConfig.password = setting.password
80110
}
81111

82112
const localPath = normalizePath(path.join(this.appDir, 'output'))

src/server/renderer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,9 @@ export default class Renderer extends Model {
615615
}
616616

617617
// Copy favicon.ico
618-
const faviconPath = urlJoin(this.appDir, 'favicon.ico')
619-
if (fse.existsSync(faviconPath)) {
620-
fse.copyFileSync(faviconPath, urlJoin(this.outputDir, 'favicon.ico'))
618+
const faviconInputPath = urlJoin(this.appDir, 'favicon.ico')
619+
if (fse.existsSync(faviconInputPath)) {
620+
fse.copyFileSync(faviconInputPath, urlJoin(this.outputDir, 'favicon.ico'))
621621
}
622622
}
623623

src/store/modules/site.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const siteState: Site = {
5959
port: '22',
6060
server: '',
6161
password: '',
62+
privateKey: '',
6263
remotePath: '',
6364
},
6465
commentSetting: {

src/views/setting/includes/BasicSetting.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
<a-icon class="icon" slot="addonAfter" :type="passVisible ? 'eye-invisible' : 'eye'" @click="passVisible = !passVisible" />
4949
</a-input>
5050
</a-form-item>
51-
<a-form-item label="Remote Path" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false" help="请填写绝对路径,例如:/home/username/www/">
51+
<a-form-item label="Private Key" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false" :help="$t('privateKeyTip')">
52+
<a-input v-model="form.privateKey" />
53+
</a-form-item>
54+
<a-form-item label="Remote Path" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false" :help="$t('remotePathTip')">
5255
<a-input v-model="form.remotePath" />
5356
</a-form-item>
5457
</template>
@@ -99,6 +102,7 @@ export default class BasicSetting extends Vue {
99102
port: '22',
100103
server: '',
101104
password: '',
105+
privateKey: '',
102106
remotePath: '',
103107
}
104108
@@ -110,13 +114,13 @@ export default class BasicSetting extends Vue {
110114
&& form.branch
111115
&& form.username
112116
&& form.token
113-
117+
114118
const sftpPlatformValid = ['sftp'].includes(form.platform)
115119
&& form.port
116120
&& form.server
117121
&& form.username
118-
&& form.password
119122
&& form.remotePath
123+
&& (form.password || form.privateKey)
120124
121125
return pagesPlatfomValid || sftpPlatformValid
122126
}

0 commit comments

Comments
 (0)