mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
⚡ Perf: remove talkingdata
This commit is contained in:
parent
50d8d721ca
commit
d9d2a840c4
@ -8,7 +8,6 @@ import VueLazyLoad from 'vue3-lazyload'
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { mainMixin } from './renderer/utils/mainMixin'
|
import { mainMixin } from './renderer/utils/mainMixin'
|
||||||
import { dragMixin } from '@/utils/mixin'
|
import { dragMixin } from '@/utils/mixin'
|
||||||
import { initTalkingData } from './renderer/utils/analytics'
|
|
||||||
import db from './renderer/utils/db'
|
import db from './renderer/utils/db'
|
||||||
import { i18nManager, T } from './renderer/i18n/index'
|
import { i18nManager, T } from './renderer/i18n/index'
|
||||||
import { getConfig, saveConfig, sendToMain, triggerRPC } from '@/utils/dataSender'
|
import { getConfig, saveConfig, sendToMain, triggerRPC } from '@/utils/dataSender'
|
||||||
@ -65,5 +64,3 @@ console.log(hljsCommon.highlightAuto('<h1>Highlight.js has been registered succe
|
|||||||
app.use(hljsVuePlugin)
|
app.use(hljsVuePlugin)
|
||||||
app.use(VueVideoPlayer)
|
app.use(VueVideoPlayer)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
||||||
initTalkingData()
|
|
||||||
|
@ -12,8 +12,8 @@ import windowManager from 'apis/app/window/windowManager'
|
|||||||
import { IWindowList } from '#/types/enum'
|
import { IWindowList } from '#/types/enum'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
import { IPicGo } from 'piclist'
|
import { IPicGo } from 'piclist'
|
||||||
import { showNotification, calcDurationRange, getClipboardFilePath } from '~/main/utils/common'
|
import { showNotification, getClipboardFilePath } from '~/main/utils/common'
|
||||||
import { RENAME_FILE_NAME, TALKING_DATA_EVENT } from '~/universal/events/constants'
|
import { RENAME_FILE_NAME } from '~/universal/events/constants'
|
||||||
import logger from '@core/picgo/logger'
|
import logger from '@core/picgo/logger'
|
||||||
import { T } from '~/main/i18n'
|
import { T } from '~/main/i18n'
|
||||||
import fse from 'fs-extra'
|
import fse from 'fs-extra'
|
||||||
@ -45,20 +45,6 @@ const waitForRename = (window: BrowserWindow, id: number): Promise<string|null>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTalkingData = (webContents: WebContents, options: IAnalyticsData) => {
|
|
||||||
const data: ITalkingDataOptions = {
|
|
||||||
EventId: 'upload',
|
|
||||||
Label: options.type,
|
|
||||||
MapKv: {
|
|
||||||
by: options.fromClipboard ? 'clipboard' : 'files', // 上传剪贴板图片还是选择的文文件
|
|
||||||
count: options.count, // 上传的数量
|
|
||||||
duration: calcDurationRange(options.duration || 0), // 上传耗时
|
|
||||||
type: options.type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
webContents.send(TALKING_DATA_EVENT, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
class Uploader {
|
class Uploader {
|
||||||
private webContents: WebContents | null = null
|
private webContents: WebContents | null = null
|
||||||
// private uploading: boolean = false
|
// private uploading: boolean = false
|
||||||
@ -152,17 +138,8 @@ class Uploader {
|
|||||||
if (!privacyCheckRes) {
|
if (!privacyCheckRes) {
|
||||||
throw Error(T('PRIVACY_TIPS'))
|
throw Error(T('PRIVACY_TIPS'))
|
||||||
}
|
}
|
||||||
const startTime = Date.now()
|
|
||||||
const output = await picgo.upload(img)
|
const output = await picgo.upload(img)
|
||||||
if (Array.isArray(output) && output.some((item: ImgInfo) => item.imgUrl)) {
|
if (Array.isArray(output) && output.some((item: ImgInfo) => item.imgUrl)) {
|
||||||
if (this.webContents) {
|
|
||||||
handleTalkingData(this.webContents, {
|
|
||||||
fromClipboard: !img,
|
|
||||||
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
|
|
||||||
count: img ? img.length : 1,
|
|
||||||
duration: Date.now() - startTime
|
|
||||||
} as IAnalyticsData)
|
|
||||||
}
|
|
||||||
output.forEach((item: ImgInfo) => {
|
output.forEach((item: ImgInfo) => {
|
||||||
item.config = JSON.parse(JSON.stringify(db.get(`picBed.${item.type}`)))
|
item.config = JSON.parse(JSON.stringify(db.get(`picBed.${item.type}`)))
|
||||||
})
|
})
|
||||||
|
@ -53,23 +53,6 @@ export const showMessageBox = (options: any) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const thresholds = [
|
|
||||||
{ limit: 1000, value: 500 },
|
|
||||||
{ limit: 1500, value: 1000 },
|
|
||||||
{ limit: 3000, value: 2000 },
|
|
||||||
{ limit: 5000, value: 3000 },
|
|
||||||
{ limit: 7000, value: 5000 },
|
|
||||||
{ limit: 10000, value: 8000 },
|
|
||||||
{ limit: 12000, value: 10000 },
|
|
||||||
{ limit: 20000, value: 15000 },
|
|
||||||
{ limit: 30000, value: 20000 }
|
|
||||||
]
|
|
||||||
|
|
||||||
export const calcDurationRange = (duration: number) => {
|
|
||||||
const foundThreshold = thresholds.find(({ limit }) => duration < limit)
|
|
||||||
return foundThreshold ? foundThreshold.value : 100000
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macOS public.file-url will get encoded file path,
|
* macOS public.file-url will get encoded file path,
|
||||||
* so we need to decode it
|
* so we need to decode it
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/* eslint-disable camelcase */
|
|
||||||
import {
|
|
||||||
TALKING_DATA_APPID, TALKING_DATA_EVENT
|
|
||||||
} from '~/universal/events/constants'
|
|
||||||
import pkg from 'root/package.json'
|
|
||||||
import { ipcRenderer } from 'electron'
|
|
||||||
import { handleTalkingDataEvent } from './common'
|
|
||||||
const { version } = pkg
|
|
||||||
|
|
||||||
export const initTalkingData = () => {
|
|
||||||
setTimeout(() => {
|
|
||||||
const talkingDataScript = document.createElement('script')
|
|
||||||
|
|
||||||
talkingDataScript.src = `http://sdk.talkingdata.com/app/h5/v1?appid=${TALKING_DATA_APPID}&vn=${version}&vc=${version}`
|
|
||||||
|
|
||||||
const head = document.getElementsByTagName('head')[0]
|
|
||||||
head.appendChild(talkingDataScript)
|
|
||||||
}, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
ipcRenderer.on(TALKING_DATA_EVENT, (_, data: ITalkingDataOptions) => {
|
|
||||||
handleTalkingDataEvent(data)
|
|
||||||
})
|
|
@ -1,16 +1,5 @@
|
|||||||
import { isReactive, isRef, toRaw, unref } from 'vue'
|
import { isReactive, isRef, toRaw, unref } from 'vue'
|
||||||
|
|
||||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
|
||||||
/* eslint-disable camelcase */
|
|
||||||
export const handleTalkingDataEvent = (data: ITalkingDataOptions) => {
|
|
||||||
const { EventId, Label = '', MapKv = {} } = data
|
|
||||||
MapKv.from = window.location.href
|
|
||||||
window.TDAPP.onEvent(EventId, Label, MapKv)
|
|
||||||
if (isDevelopment) {
|
|
||||||
console.log('talkingData', data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get raw data from reactive or ref
|
* get raw data from reactive or ref
|
||||||
*/
|
*/
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
export const SHOW_INPUT_BOX = 'SHOW_INPUT_BOX'
|
export const SHOW_INPUT_BOX = 'SHOW_INPUT_BOX'
|
||||||
export const SHOW_INPUT_BOX_RESPONSE = 'SHOW_INPUT_BOX_RESPONSE'
|
export const SHOW_INPUT_BOX_RESPONSE = 'SHOW_INPUT_BOX_RESPONSE'
|
||||||
export const TOGGLE_SHORTKEY_MODIFIED_MODE = 'TOGGLE_SHORTKEY_MODIFIED_MODE'
|
export const TOGGLE_SHORTKEY_MODIFIED_MODE = 'TOGGLE_SHORTKEY_MODIFIED_MODE'
|
||||||
export const TALKING_DATA_APPID = 'B743C16E2989419A9B02EDE9D1E6A530'
|
|
||||||
export const C1N = 'WjJoeFdWWklhVTlXYVRKTU5EUmFOVkEwUlVRPQ=='
|
export const C1N = 'WjJoeFdWWklhVTlXYVRKTU5EUmFOVkEwUlVRPQ=='
|
||||||
export const TALKING_DATA_EVENT = 'TALKING_DATA_EVENT'
|
|
||||||
export const SHOW_PRIVACY_MESSAGE = 'SHOW_PRIVACY_MESSAGE'
|
export const SHOW_PRIVACY_MESSAGE = 'SHOW_PRIVACY_MESSAGE'
|
||||||
export const PICGO_SAVE_CONFIG = 'PICGO_SAVE_CONFIG'
|
export const PICGO_SAVE_CONFIG = 'PICGO_SAVE_CONFIG'
|
||||||
export const PICGO_GET_CONFIG = 'PICGO_GET_CONFIG'
|
export const PICGO_GET_CONFIG = 'PICGO_GET_CONFIG'
|
||||||
|
6
src/universal/types/types.d.ts
vendored
6
src/universal/types/types.d.ts
vendored
@ -337,12 +337,6 @@ interface IAppNotification {
|
|||||||
icon?: string
|
icon?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ITalkingDataOptions {
|
|
||||||
EventId: string
|
|
||||||
Label?: string
|
|
||||||
MapKv?: IStringKeyMap
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IAnalyticsData {
|
interface IAnalyticsData {
|
||||||
fromClipboard: boolean
|
fromClipboard: boolean
|
||||||
type: string
|
type: string
|
||||||
|
@ -41,9 +41,7 @@ export const simpleClone = (obj: any) => {
|
|||||||
return JSON.parse(JSON.stringify(obj))
|
return JSON.parse(JSON.stringify(obj))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enforceNumber = (num: number | string) => {
|
export const enforceNumber = (num: number | string) => isNaN(+num) ? 0 : +num
|
||||||
return isNaN(+num) ? 0 : +num
|
|
||||||
}
|
|
||||||
|
|
||||||
export const isDev = process.env.NODE_ENV === 'development'
|
export const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
|
@ -4,11 +4,8 @@ import { RELEASE_URL, RELEASE_URL_BACKUP } from './static'
|
|||||||
|
|
||||||
export const getLatestVersion = async (): Promise<string> => {
|
export const getLatestVersion = async (): Promise<string> => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(RELEASE_URL)
|
const { data: normalList } = await axios.get(RELEASE_URL)
|
||||||
const releases = data as IStringKeyMap[]
|
return normalList[0].name
|
||||||
const normalList = releases.filter(item => !item.name.includes('beta'))
|
|
||||||
const latestRelease = normalList[0]
|
|
||||||
return latestRelease.name
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user