mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
MAIN_DETAIL_COPY, *_BY_SYNTAX, CLIENT_VERSION 追加
This commit is contained in:
@@ -162,6 +162,7 @@ export default class ArticleDetail extends React.Component {
|
||||
}
|
||||
|
||||
handleClipboardButtonClick (e) {
|
||||
activityRecord.emit('MAIN_DETAIL_COPY')
|
||||
clipboard.writeText(this.props.activeArticle.content)
|
||||
notify('Saved to Clipboard!', {
|
||||
body: 'Paste it wherever you want!'
|
||||
@@ -293,9 +294,9 @@ export default class ArticleDetail extends React.Component {
|
||||
if (newArticle.title.length === 0) {
|
||||
newArticle.title = `Created at ${moment(newArticle.createdAt).format('YYYY/MM/DD HH:mm')}`
|
||||
}
|
||||
activityRecord.emit('ARTICLE_CREATE')
|
||||
activityRecord.emit('ARTICLE_CREATE', {mode: newArticle.mode})
|
||||
} else {
|
||||
activityRecord.emit('ARTICLE_UPDATE')
|
||||
activityRecord.emit('ARTICLE_UPDATE', {mode: newArticle.mode})
|
||||
}
|
||||
|
||||
dispatch(updateArticle(newArticle))
|
||||
|
||||
@@ -4,6 +4,9 @@ import keygen from 'boost/keygen'
|
||||
import dataStore from 'boost/dataStore'
|
||||
import { request, WEB_URL } from 'boost/api'
|
||||
|
||||
const electron = require('electron')
|
||||
const version = electron.remote.app.getVersion()
|
||||
|
||||
function isSameDate (a, b) {
|
||||
a = moment(a).utcOffset(+540).format('YYYYMMDD')
|
||||
b = moment(b).utcOffset(+540).format('YYYYMMDD')
|
||||
@@ -81,7 +84,7 @@ export function postRecords (data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function emit (type, data) {
|
||||
export function emit (type, data = {}) {
|
||||
let records = getAllRecords()
|
||||
|
||||
let index = _.findIndex(records, record => {
|
||||
@@ -94,7 +97,6 @@ export function emit (type, data) {
|
||||
records.push(todayRecord)
|
||||
}
|
||||
else todayRecord = records[index]
|
||||
console.log(type)
|
||||
switch (type) {
|
||||
case 'ARTICLE_CREATE':
|
||||
case 'ARTICLE_UPDATE':
|
||||
@@ -104,6 +106,7 @@ export function emit (type, data) {
|
||||
case 'FOLDER_DESTROY':
|
||||
case 'FINDER_OPEN':
|
||||
case 'FINDER_COPY':
|
||||
case 'MAIN_DETAIL_COPY':
|
||||
todayRecord[type] = todayRecord[type] == null
|
||||
? 1
|
||||
: todayRecord[type] + 1
|
||||
@@ -111,9 +114,26 @@ export function emit (type, data) {
|
||||
break
|
||||
}
|
||||
|
||||
// Count ARTICLE_CREATE and ARTICLE_UPDATE again by syntax
|
||||
if ((type === 'ARTICLE_CREATE' || type === 'ARTICLE_UPDATE') && data.mode != null) {
|
||||
let recordKey = type + '_BY_SYNTAX'
|
||||
if (todayRecord[recordKey] == null) todayRecord[recordKey] = {}
|
||||
|
||||
todayRecord[recordKey][data.mode] = todayRecord[recordKey][data.mode] == null
|
||||
? 1
|
||||
: todayRecord[recordKey][data.mode] + 1
|
||||
}
|
||||
|
||||
let storeData = dataStore.getData()
|
||||
todayRecord.FOLDER_COUNT = _.isArray(storeData.folders) ? storeData.folders.length : 0
|
||||
todayRecord.ARTICLE_COUNT = _.isArray(storeData.articles) ? storeData.articles.length : 0
|
||||
todayRecord.CLIENT_VERSION = version
|
||||
|
||||
todayRecord.SYNTAX_COUNT = storeData.articles.reduce((sum, article) => {
|
||||
if (sum[article.mode] == null) sum[article.mode] = 1
|
||||
else sum[article.mode]++
|
||||
return sum
|
||||
}, {})
|
||||
|
||||
saveAllRecords(records)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user