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