Skip to content

Commit

Permalink
修改发布流程
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyoubo committed Dec 3, 2018
1 parent 8590141 commit fb9926f
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
}
},
"dependencies": {
"electron-baidu-tongji": "^1.0.2",
"electron-json-storage": "^4.1.1",
"element-ui": "^2.4.5",
"hexo": "^3.8.0",
Expand Down
31 changes: 29 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict'

import { app, BrowserWindow, Menu } from 'electron'
import { app, BrowserWindow, Menu, shell, ipcMain } from 'electron'
import { ebtMain } from 'electron-baidu-tongji'

ebtMain(ipcMain)

/**
* Set `__static` path to static files in production
Expand Down Expand Up @@ -186,13 +189,37 @@ function createMenu () {
}
}
]
},
{
label: '关于',
submenu: [
{
label: '关于',
click: function () {
if (mainWindow) {
mainWindow.webContents.send('about')
}
}
},
{
label: '使用帮助',
click: function () {
shell.openExternal('https://www.mspring.org/2018/11/29/HexoClient%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9/')
}
},
{
label: '提交问题',
click: function () {
shell.openExternal('https://github.com/gaoyoubo/hexo-client/issues/new')
}
}
]
}
]
if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{role: 'about'},
{
label: '配置',
accelerator: 'Cmd+,',
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
ipcRenderer.on('createPost', function (eventEmitter) {
me.$router.push({name: 'create'})
})
ipcRenderer.on('settings', function (eventEmitter) {
me.$router.push({name: 'settings'})
})
ipcRenderer.on('about', function (eventEmitter) {
me.$router.push({name: 'about'})
})
},
mounted () {
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/components/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
<li>Blog:<a @click="openUrl('http://www.mspring.org')" href="#">http://www.mspring.org</a></li>
</ul>
</div>
<div>
<h3>使用帮助</h3>
<ul>
<li>帮助文档:<a @click="openUrl('https://www.mspring.org/2018/11/29/HexoClient%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9/')" href="#">点击查看帮助文档</a></li>
<li>提交问题:<a @click="openUrl('https://github.com/gaoyoubo/hexo-client/issues/new')" href="#">点击提交问题</a></li>
</ul>
</div>
<div>
<h3>站在巨人肩上</h3>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/ArticleList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>

<el-scrollbar style="height: 100%; width: 380px;" ref="scrollbar" class="el-scrollbar">
<el-scrollbar style="height: 100%; width: 280px; min-width: 280px;" ref="scrollbar" class="el-scrollbar">
<div class="tool-box">
<div class="tool-box-content">
<el-button style="margin: 0px;" size="mini" icon="el-icon-edit" type="info"
Expand Down
27 changes: 25 additions & 2 deletions src/renderer/components/Deploy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
methods: {
async deploy () {
if (await this.isModified()) {
this.commit('simple-git')
this.commit('Commit at ' + this.dateFormat('yyyy-MM-dd HH:mm:ss', new Date()))
} else {
this.$notify({message: '资料库无变更', type: 'warning'})
}
Expand All @@ -24,7 +24,9 @@
async isModified () {
try {
let statusSummary = await this.git().status()

This comment has been minimized.

Copy link
@ic-timon

ic-timon Dec 4, 2018

这里貌似用git做监测和发布?
为什么不直接用
hexo clean/g/d ?

This comment has been minimized.

Copy link
@gaoyoubo

gaoyoubo Dec 5, 2018

Author Owner

@loveward 是的,我之前的版本是使用hexo generate & hexo deploy来发布的。但是那个不是我认为的最佳实践方式,请看这篇文档:https://www.mspring.org/2018/11/29/HexoClient%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9/

如果直接使用hexo d/g来发布,那么我们的原hexo文件不会保存到git。

我推荐的最佳实践是用两个仓库,
A仓库开启github pages来发布静态网页,
B仓库用来存储hexo项目
然后使用travis-ci监控B仓库的提交记录,当B仓库有提交的时候,travis-ci自动hexo deploy到A仓库。

return statusSummary.modified.length > 0
if (statusSummary.modified.length > 0) return true
if (statusSummary.not_added.length > 0) return true
return false
} catch (e) {
console.error(e)
return false
Expand Down Expand Up @@ -59,6 +61,27 @@
workingDir () {
let config = this.$store.state.Config.config
return config.path
},
dateFormat (fmt, date) {
var o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
'q+': Math.floor((date.getMonth() + 3) / 3),
'S': date.getMilliseconds()
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
}
return fmt
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import App from './App'
import router from './router'
import store from './store'

import { ipcRenderer } from 'electron'
import { ebtRenderer } from 'electron-baidu-tongji'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/style.css'
Expand All @@ -16,6 +19,10 @@ Vue.use(mavonEditor)
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.config.productionTip = false

// 百度统计
const BAIDU_SITE_ID = '4b0947c1973db3139b436d8583b3fc00'
ebtRenderer(ipcRenderer, BAIDU_SITE_ID, router)

/* eslint-disable no-new */
new Vue({
components: {App},
Expand Down

0 comments on commit fb9926f

Please sign in to comment.