🔨 Refactor(db): rm config store (#1371)

This commit is contained in:
PiEgg
2026-01-07 15:13:25 +08:00
committed by GitHub
parent 2936b19008
commit 50881b071a
26 changed files with 211 additions and 247 deletions
+2 -1
View File
@@ -26,4 +26,5 @@ scripts/*.yml
.serena/
dist/*
test.js
specs/
specs/
.cache/
+2 -1
View File
@@ -4,13 +4,14 @@
PicGo is an Electron + Vue 3 desktop client. Source lives in `src/`: `src/main` for main-process and IPC logic, `src/renderer` for Vue views, and `src/universal` for shared helpers (`types/`, `events/constants.ts`). `background.ts` wires Electron Builder. Static assets and locale YAML files stay in `public/` (add languages under `public/i18n/`), while `docs/` hosts user-facing guides. Automation scripts live in `scripts/`, and legacy tests sit under `test/unit` (Karma) and `test/e2e` (Spectron).
## Build, Test, and Development Commands
- `pnpm install` — install dependencies; `npm install` is unsupported.
- `pnpm install` — install dependencies; `npm install` is unsupported. Only run this when the user explicitly asks/coordinates it.
- Always add/remove dependencies with `pnpm` (never edit package.json versions by hand then install).
- `pnpm dev` — electron-vite dev server for main/preload/renderer.
- `pnpm build` — electron-vite build outputs to `dist/main`, `dist/preload`, `dist/renderer`; `pnpm preview` for preview mode.
- Packaging config lives in `electron-builder.yml` (read by electron-builder via package.json `build` field/extraResources); set `ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/` if downloads are slow.
- `pnpm lint` / `pnpm lint:fix` — run or auto-fix ESLint (Standard, TypeScript, Vue rules).
- `pnpm lint:dpdm` — fail fast on circular dependencies in `src/`.
- `pnpm check` — run `tsc` + `lint` (run once before finishing a task).
- `pnpm gen-i18n` — regenerate typed locales after touching `public/i18n/*.yml`.
## Coding Style & Naming Conventions
+7 -2
View File
@@ -6,6 +6,7 @@ const tsParser = require('@typescript-eslint/parser')
const importPlugin = require('eslint-plugin-import')
const promisePlugin = require('eslint-plugin-promise')
const vuePlugin = require('eslint-plugin-vue')
const stylistic = require('@stylistic/eslint-plugin')
const isProduction = process.env.NODE_ENV === 'production'
const vueConfigs = vuePlugin.configs['flat/recommended'].map(config => ({
@@ -76,7 +77,8 @@ module.exports = [
},
plugins: {
import: importPlugin,
promise: promisePlugin
promise: promisePlugin,
'@stylistic': stylistic
},
settings: {
'import/resolver': {
@@ -98,7 +100,10 @@ module.exports = [
'no-debugger': isProduction ? 'error' : 'off',
'no-async-promise-executor': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-unused-vars': 'off'
'no-unused-vars': 'off',
'@stylistic/indent': ['error', 2],
'@stylistic/semi': ['error', 'never'],
'no-unexpected-multiline': 'error'
}
},
...vueConfigs,
+5 -3
View File
@@ -14,7 +14,7 @@
"build:mac": "npm run build && electron-builder --config electron-builder.config.ts --mac --publish never",
"build:linux": "npm run build && electron-builder --config electron-builder.config.ts --linux --publish never",
"build:local": "dotenv -e .env -- electron-vite build && electron-builder --config electron-builder.config.ts --publish never",
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.vue src/",
"lint": "pnpm lint:dpdm && eslint --ext .js,.jsx,.ts,.tsx,.vue src/",
"tsc": "tsc --noEmit",
"bump": "bump-version",
"cz": "git-cz",
@@ -25,7 +25,8 @@
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps",
"upload-dist": "node ./scripts/upload-dist.js",
"lint:dpdm": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/background.ts"
"lint:dpdm": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/background.ts",
"check": "pnpm run tsc && pnpm run lint"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.2",
@@ -68,6 +69,7 @@
"@eslint/js": "^9.39.1",
"@molunerfinn/vite-plugin-electron-renderer": "^0.14.7",
"@picgo/bump-version": "^2.0.0",
"@stylistic/eslint-plugin": "^5.6.1",
"@types/electron-devtools-installer": "^2.2.0",
"@types/fs-extra": "^9.0.13",
"@types/inquirer": "^6.5.0",
@@ -126,4 +128,4 @@
"commit-msg": "npm run lint:dpdm && commitlint -E HUSKY_GIT_PARAMS"
}
}
}
}
+22 -2
View File
@@ -123,6 +123,9 @@ importers:
'@picgo/bump-version':
specifier: ^2.0.0
version: 2.0.0(@types/node@20.19.26)(typescript@5.9.3)
'@stylistic/eslint-plugin':
specifier: ^5.6.1
version: 5.6.1(eslint@9.39.1(jiti@1.21.7))
'@types/electron-devtools-installer':
specifier: ^2.2.0
version: 2.2.5
@@ -215,7 +218,7 @@ importers:
version: 7.2.1(eslint@9.39.1(jiti@1.21.7))
eslint-plugin-vue:
specifier: ^10.6.2
version: 10.6.2(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7)))
version: 10.6.2(@stylistic/eslint-plugin@5.6.1(eslint@9.39.1(jiti@1.21.7)))(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7)))
globals:
specifier: ^16.5.0
version: 16.5.0
@@ -1408,6 +1411,12 @@ packages:
resolution: {integrity: sha512-4aUIteuyxtBUhVdiQqcDhKFitwfd9hqoSDYY2KRXiWtgoWJ9Bmise+KfEPDiVHWeJepvF8xJO9/9+WDIciMFFw==}
engines: {node: '>=18.0.0'}
'@stylistic/eslint-plugin@5.6.1':
resolution: {integrity: sha512-JCs+MqoXfXrRPGbGmho/zGS/jMcn3ieKl/A8YImqib76C8kjgZwq5uUFzc30lJkMvcchuRn6/v8IApLxli3Jyw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: '>=9.0.0'
'@sxzz/popperjs-es@2.11.7':
resolution: {integrity: sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==}
@@ -7352,6 +7361,16 @@ snapshots:
dependencies:
tslib: 2.8.1
'@stylistic/eslint-plugin@5.6.1(eslint@9.39.1(jiti@1.21.7))':
dependencies:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@1.21.7))
'@typescript-eslint/types': 8.49.0
eslint: 9.39.1(jiti@1.21.7)
eslint-visitor-keys: 4.2.1
espree: 10.4.0
estraverse: 5.3.0
picomatch: 4.0.3
'@sxzz/popperjs-es@2.11.7': {}
'@szmarczak/http-timer@4.0.6':
@@ -9165,7 +9184,7 @@ snapshots:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@1.21.7))
eslint: 9.39.1(jiti@1.21.7)
eslint-plugin-vue@10.6.2(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7))):
eslint-plugin-vue@10.6.2(@stylistic/eslint-plugin@5.6.1(eslint@9.39.1(jiti@1.21.7)))(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7))):
dependencies:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@1.21.7))
eslint: 9.39.1(jiti@1.21.7)
@@ -9176,6 +9195,7 @@ snapshots:
vue-eslint-parser: 10.2.0(eslint@9.39.1(jiti@1.21.7))
xml-name-validator: 4.0.0
optionalDependencies:
'@stylistic/eslint-plugin': 5.6.1(eslint@9.39.1(jiti@1.21.7))
'@typescript-eslint/parser': 8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3)
eslint-scope@8.4.0:
@@ -4,7 +4,6 @@ import {
} from 'electron'
import logger from '@core/picgo/logger'
import GuiApi from '../../gui'
import db from '~/main/apis/core/datastore'
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
import shortKeyService from './shortKeyService'
import picgo from '@core/picgo'
@@ -25,7 +24,7 @@ class ShortKeyHandler {
}
private initBuiltInShortKey () {
const commands = db.get('settings.shortKey') as IShortKeyConfigs
const commands = picgo.getConfig<IShortKeyConfigs>('settings.shortKey') || {}
Object.keys(commands)
.filter(item => item.includes('picgo:'))
.forEach(command => {
@@ -57,8 +56,8 @@ class ShortKeyHandler {
const commands = plugin.commands(picgo) as IPluginShortKeyConfig[]
for (const cmd of commands) {
const command = `${item}:${cmd.name}`
if (db.has(`settings.shortKey[${command}]`)) {
const commandConfig = db.get(`settings.shortKey.${command}`) as IShortKeyConfig
const commandConfig = picgo.getConfig<IShortKeyConfig | undefined>(`settings.shortKey.${command}`)
if (commandConfig) {
// if disabled, don't register #534
if (commandConfig.enable) {
this.registerShortKey(commandConfig, command, cmd.handle, false)
@@ -168,8 +167,8 @@ class ShortKeyHandler {
const commands = plugin.commands(picgo) as IPluginShortKeyConfig[]
for (const cmd of commands) {
const command = `${pluginName}:${cmd.name}`
if (db.has(`settings.shortKey[${command}]`)) {
const commandConfig = db.get(`settings.shortKey[${command}]`) as IShortKeyConfig
const commandConfig = picgo.getConfig<IShortKeyConfig | undefined>(`settings.shortKey.${command}`)
if (commandConfig) {
this.registerShortKey(commandConfig, command, cmd.handle, false)
} else {
this.registerShortKey(cmd, command, cmd.handle, true)
@@ -179,7 +178,7 @@ class ShortKeyHandler {
}
unregisterPluginShortKey (pluginName: string) {
const commands = db.get('settings.shortKey') as IShortKeyConfigs
const commands = picgo.getConfig<IShortKeyConfigs>('settings.shortKey') || {}
const keyList = Object.keys(commands)
.filter(command => command.includes(pluginName))
.map(command => {
@@ -191,7 +190,7 @@ class ShortKeyHandler {
keyList.forEach(item => {
globalShortcut.unregister(item.key)
shortKeyService.unregisterCommand(item.command)
db.unset('settings.shortKey', item.command)
picgo.removeConfig('settings.shortKey', item.command)
})
}
}
+13 -12
View File
@@ -7,9 +7,10 @@ import {
nativeTheme
} from 'electron'
import uploader from 'apis/app/uploader'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { GalleryDB } from '~/main/apis/core/datastore'
import windowManager from 'apis/app/window/windowManager'
import { IWindowList } from '#/types/enum'
import { IPasteStyle, IWindowList } from '#/types/enum'
import pasteTemplate from '~/main/utils/pasteTemplate'
import pkg from 'root/package.json'
import { ensureFilePath, getClipboardFilePathList, handleCopyUrl, showNotification } from '~/main/utils/common'
@@ -58,10 +59,10 @@ export function createContextMenu () {
{
label: T('OPEN_UPDATE_HELPER'),
type: 'checkbox',
checked: db.get('settings.showUpdateTip'),
checked: picgo.getConfig<boolean>('settings.showUpdateTip') !== false,
click () {
const value = db.get('settings.showUpdateTip')
db.set('settings.showUpdateTip', !value)
const value = picgo.getConfig<boolean>('settings.showUpdateTip') !== false
picgo.saveConfig({ 'settings.showUpdateTip': !value })
}
},
{
@@ -107,10 +108,10 @@ export function createContextMenu () {
{
label: T('OPEN_UPDATE_HELPER'),
type: 'checkbox',
checked: db.get('settings.showUpdateTip'),
checked: picgo.getConfig<boolean>('settings.showUpdateTip') !== false,
click () {
const value = db.get('settings.showUpdateTip')
db.set('settings.showUpdateTip', !value)
const value = picgo.getConfig<boolean>('settings.showUpdateTip') !== false
picgo.saveConfig({ 'settings.showUpdateTip': !value })
}
},
{
@@ -216,7 +217,7 @@ export function createTray () {
// drop-files only be supported in macOS
// so the tray window must be available
tray.on('drop-files', async (event, files: string[]) => {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
const imgs = await uploader
.setWebContents(trayWindow.webContents)
@@ -225,7 +226,7 @@ export function createTray () {
const pasteText: string[] = []
for (let i = 0; i < imgs.length; i++) {
pasteText.push(
pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))
pasteTemplate(pasteStyle, imgs[i], picgo.getConfig<string>('settings.customLink'))
)
setTimeout(() => {
showNotification({
@@ -271,7 +272,7 @@ export function handleMenubarIcon (visible?: boolean) {
}
return
}
const shouldShow = visible !== undefined ? visible : (db.get('settings.showMenubarIcon') !== false)
const shouldShow = visible !== undefined ? visible : (picgo.getConfig<boolean>('settings.showMenubarIcon') !== false)
if (shouldShow) {
if (!tray) {
createTray()
@@ -283,7 +284,7 @@ export function handleMenubarIcon (visible?: boolean) {
export function handleDockIcon () {
if (isMacOS) {
if (db.get('settings.showDockIcon') !== false) {
if (picgo.getConfig<boolean>('settings.showDockIcon') !== false) {
app.dock?.show()
app.dock?.setMenu(createContextMenu())
} else {
+8 -7
View File
@@ -2,17 +2,18 @@ import {
WebContents
} from 'electron'
import windowManager from 'apis/app/window/windowManager'
import { IRPCActionType, IWindowList } from '#/types/enum'
import { IPasteStyle, IRPCActionType, IWindowList } from '#/types/enum'
import uploader from '.'
import pasteTemplate from '~/main/utils/pasteTemplate'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import { GalleryDB } from '~/main/apis/core/datastore'
import { handleCopyUrl, handleUrlEncodeWithSetting, showNotification } from '~/main/utils/common'
import { T } from '~/main/i18n/index'
import logger from '@core/picgo/logger'
import picgo from '@core/picgo'
// import dayjs from 'dayjs'
const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
const useBuiltinClipboard = !!db.get('settings.useBuiltinClipboard')
const useBuiltinClipboard = !!picgo.getConfig<boolean>('settings.useBuiltinClipboard')
const win = windowManager.getAvailableWindow()
if (useBuiltinClipboard) {
return await uploader.setWebContents(win!.webContents).uploadWithBuildInClipboard()
@@ -26,8 +27,8 @@ export const uploadClipboardFiles = async (): Promise<string> => {
if (img !== false) {
if (img.length > 0) {
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], picgo.getConfig<string>('settings.customLink')))
setTimeout(() => {
showNotification({
title: T('UPLOAD_SUCCEED'),
@@ -60,10 +61,10 @@ export const uploadSelectedFiles = async (webContents: WebContents, files: IFile
const imgs = await uploader.setWebContents(webContents).upload(input)
const result = []
if (imgs !== false) {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
const pasteText: string[] = []
for (let i = 0; i < imgs.length; i++) {
pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))
pasteText.push(pasteTemplate(pasteStyle, imgs[i], picgo.getConfig<string>('settings.customLink')))
setTimeout(() => {
showNotification({
title: T('UPLOAD_SUCCEED'),
+4 -5
View File
@@ -6,7 +6,6 @@ import {
} from 'electron'
import dayjs from 'dayjs'
import picgo from '@core/picgo'
import db from '~/main/apis/core/datastore'
import windowManager from 'apis/app/window/windowManager'
import { IWindowList } from '#/types/enum'
import util from 'util'
@@ -56,7 +55,7 @@ class Uploader {
this.webContents?.send('uploadProgress', progress)
})
picgo.on('beforeTransform', () => {
if (db.get('settings.uploadNotification')) {
if (picgo.getConfig<boolean>('settings.uploadNotification')) {
showNotification({
title: T('UPLOAD_PROGRESS'),
body: T('UPLOADING')
@@ -65,8 +64,8 @@ class Uploader {
})
picgo.helper.beforeUploadPlugins.register('renameFn', {
handle: async (ctx: IPicGo) => {
const rename = db.get('settings.rename')
const autoRename = db.get('settings.autoRename')
const rename = picgo.getConfig<boolean>('settings.rename')
const autoRename = picgo.getConfig<boolean>('settings.autoRename')
if (autoRename || rename) {
await Promise.all(ctx.output.map(async (item, index) => {
let name: undefined | string | null
@@ -144,7 +143,7 @@ class Uploader {
fromClipboard: !img,
duration: Date.now() - startTime,
outputList: output
});
})
}
return output.filter(item => item.imgUrl)
} else {
+4 -4
View File
@@ -9,12 +9,12 @@ import {
import { IStartupMode, IWindowList } from '#/types/enum'
import bus from '@core/bus'
import { CREATE_APP_MENU } from '@core/bus/constants'
import db from '~/main/apis/core/datastore'
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
import { app } from 'electron'
import { T } from '~/main/i18n'
import { isLinux } from '~/universal/utils/common'
import { getStaticPath } from '#/utils/staticPath'
import picgo from '@core/picgo'
// import { URLSearchParams } from 'url'
const windowList = new Map<IWindowList, IWindowListItem>()
@@ -37,7 +37,7 @@ const handleWindowParams = (windowURL: string) => {
}
export const isWindowShouldShowOnStartup = (currentWindow: IWindowList) => {
const startupMode = db.get('settings.startupMode') || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : IStartupMode.HIDE)
const startupMode = picgo.getConfig<IStartupMode | undefined>('settings.startupMode') || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : IStartupMode.HIDE)
switch (currentWindow) {
case IWindowList.MINI_WINDOW: {
return startupMode === IStartupMode.SHOW_MINI_WINDOW
@@ -82,7 +82,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
isValid: true,
multiple: false,
options () {
const showDockIcon = db.get('settings.showDockIcon') !== false
const showDockIcon = picgo.getConfig<boolean>('settings.showDockIcon') !== false
const options: IBrowserWindowOptions = {
height: 450,
width: 800,
@@ -142,7 +142,7 @@ windowList.set(IWindowList.MINI_WINDOW, {
}
}
if (db.get('settings.miniWindowOnTop')) {
if (picgo.getConfig<boolean>('settings.miniWindowOnTop')) {
obj.alwaysOnTop = true
}
return obj
+6 -77
View File
@@ -1,85 +1,14 @@
import path from 'path'
import fs from 'fs-extra'
import { dbPathChecker, dbPathDir, getGalleryDBPath } from './dbChecker'
import { DBStore, JSONStore } from '@picgo/store'
import { T } from '~/main/i18n'
import { DBStore } from '@picgo/store'
import { getGalleryDBPath } from './dbChecker'
const STORE_PATH = dbPathDir()
const DB_PATH: string = getGalleryDBPath().dbPath
fs.ensureDirSync(path.dirname(DB_PATH))
if (!fs.pathExistsSync(STORE_PATH)) {
fs.mkdirpSync(STORE_PATH)
}
const CONFIG_PATH: string = dbPathChecker()
export const DB_PATH: string = getGalleryDBPath().dbPath
class ConfigStore {
private db: JSONStore
constructor () {
this.db = new JSONStore(CONFIG_PATH)
if (!this.db.has('picBed')) {
this.db.set('picBed', {
current: 'smms', // deprecated
uploader: 'smms',
smms: {
token: ''
}
})
}
if (!this.db.has('settings.shortKey')) {
this.db.set('settings.shortKey[picgo:upload]', {
enable: true,
key: 'CommandOrControl+Shift+P',
name: 'upload',
label: T('QUICK_UPLOAD')
})
}
this.read()
}
flush () {
this.db = new JSONStore(CONFIG_PATH)
}
read () {
this.db.read()
return this.db
}
get (key = ''): any {
if (key === '') {
return this.db.read()
}
return this.db.get(key)
}
set (key: string, value: any): void {
return this.db.set(key, value)
}
has (key: string) {
return this.db.has(key)
}
unset (key: string, value: any): boolean {
return this.db.unset(key, value)
}
getConfigPath () {
return CONFIG_PATH
}
}
const db = new ConfigStore()
export default db
// v2.3.0 add gallery db
class GalleryDB {
private static instance: DBStore
private constructor () {
console.log('init gallery db')
}
private constructor () {}
public static getInstance (): DBStore {
if (!GalleryDB.instance) {
+10 -12
View File
@@ -1,8 +1,6 @@
import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker'
import pkg from 'root/package.json'
import { PicGo } from 'picgo'
import db from 'apis/core/datastore'
import debounce from 'lodash/debounce'
const CONFIG_PATH = dbPathChecker()
@@ -17,18 +15,18 @@ picgo.saveConfig({
global.PICGO_GUI_VERSION = pkg.version
picgo.GUI_VERSION = global.PICGO_GUI_VERSION
const originPicGoSaveConfig = picgo.saveConfig.bind(picgo)
// const originPicGoSaveConfig = picgo.saveConfig.bind(picgo)
function flushDB () {
db.flush()
}
// function flushDB () {
// db.flush()
// }
const debounced = debounce(flushDB, 1000)
// const debounced = debounce(flushDB, 1000)
picgo.saveConfig = (config: IStringKeyMap) => {
originPicGoSaveConfig(config)
// flush electron's db
debounced()
}
// picgo.saveConfig = (config: IStringKeyMap) => {
// originPicGoSaveConfig(config)
// // flush electron's db
// debounced()
// }
export default picgo
+5 -4
View File
@@ -3,7 +3,8 @@ import {
BrowserWindow,
ipcMain
} from 'electron'
import db, { GalleryDB } from 'apis/core/datastore'
import picgo from '@core/picgo'
import { GalleryDB } from 'apis/core/datastore'
import { dbPathChecker, defaultConfigPath, getGalleryDBPath } from 'apis/core/datastore/dbChecker'
import uploader from 'apis/app/uploader'
import pasteTemplate from '~/main/utils/pasteTemplate'
@@ -17,7 +18,7 @@ import {
} from '~/universal/events/constants'
import { DBStore } from '@picgo/store'
import { T } from '~/main/i18n'
import { IRPCActionType } from '~/universal/types/enum'
import { IPasteStyle, IRPCActionType } from '~/universal/types/enum'
class GuiApi implements IGuiApi {
private static instance: GuiApi
@@ -76,10 +77,10 @@ class GuiApi implements IGuiApi {
const webContents = this.getWebContentsByWindowId(this.windowId)
const imgs = await uploader.setWebContents(webContents!).upload(input)
if (imgs !== false) {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
const pasteText: string[] = []
for (let i = 0; i < imgs.length; i++) {
pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))
pasteText.push(pasteTemplate(pasteStyle, imgs[i], picgo.getConfig<string>('settings.customLink')))
setTimeout(() => {
showMainNotification({
title: T('UPLOAD_SUCCEED'),
+6 -5
View File
@@ -6,10 +6,11 @@ import {
BrowserWindow
} from 'electron'
import windowManager from 'apis/app/window/windowManager'
import { IRPCActionType, IWindowList } from '#/types/enum'
import { IPasteStyle, IRPCActionType, IWindowList } from '#/types/enum'
import uploader from 'apis/app/uploader'
import pasteTemplate from '~/main/utils/pasteTemplate'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { GalleryDB } from '~/main/apis/core/datastore'
import server from '~/main/server'
import getPicBeds from '~/main/utils/getPicBeds'
import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
@@ -48,8 +49,8 @@ export default {
// macOS use builtin clipboard is OK
const img = await uploader.setWebContents(trayWindow.webContents).uploadWithBuildInClipboard()
if (img !== false) {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], picgo.getConfig<string>('settings.customLink')))
showNotification({
title: T('UPLOAD_SUCCEED'),
body: img[0].imgUrl!
@@ -129,7 +130,7 @@ export default {
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
if (db.get('settings.miniWindowOnTop')) {
if (picgo.getConfig<boolean>('settings.miniWindowOnTop')) {
miniWindow.setAlwaysOnTop(true)
}
@@ -11,7 +11,7 @@ const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_
const defaultClipboardImagePath = path.join(defaultConfigPath, CLIPBOARD_IMAGE_FOLDER)
export const checkClipboardUploadMap: IToolboxCheckerMap<
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
> = {
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async (event) => {
sendToolboxRes(event, {
@@ -51,7 +51,7 @@ IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
}
export const fixClipboardUploadMap: IToolboxFixMap<
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
> = {
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async () => {
const configFilePath = dbPathChecker()
@@ -2,8 +2,8 @@ import fs from 'fs-extra'
import { IpcMainEvent } from 'electron'
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
import { sendToolboxResWithType } from './utils'
import { dbPathChecker } from '~/main/apis/core/datastore/dbChecker'
import { GalleryDB, DB_PATH } from '~/main/apis/core/datastore'
import { dbPathChecker, getGalleryDBPath } from '~/main/apis/core/datastore/dbChecker'
import { GalleryDB } from '~/main/apis/core/datastore'
import path from 'path'
import { T } from '~/main/i18n'
@@ -40,20 +40,21 @@ IToolboxItemType.IS_CONFIG_FILE_BROKEN | IToolboxItemType.IS_GALLERY_FILE_BROKEN
sendToolboxRes(event, {
status: IToolboxItemCheckStatus.LOADING
})
const { dbPath } = getGalleryDBPath()
const galleryDB = GalleryDB.getInstance()
if (galleryDB.errorList.length === 0) {
sendToolboxRes(event, {
status: IToolboxItemCheckStatus.SUCCESS,
msg: T('TOOLBOX_CHECK_GALLERY_FILE_PATH_TIPS', {
path: DB_PATH
path: dbPath
}),
value: path.dirname(DB_PATH)
value: path.dirname(dbPath)
})
} else {
sendToolboxRes(event, {
status: IToolboxItemCheckStatus.ERROR,
msg: T('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
value: path.dirname(DB_PATH)
value: path.dirname(dbPath)
})
}
}
@@ -75,7 +76,7 @@ IToolboxItemType.IS_CONFIG_FILE_BROKEN | IToolboxItemType.IS_GALLERY_FILE_BROKEN
},
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async () => {
try {
fs.unlinkSync(DB_PATH)
fs.unlinkSync(getGalleryDBPath().dbPath)
} catch (e) {
// do nothing
}
@@ -25,7 +25,7 @@ const getProxy = (proxyStr: string): AxiosRequestConfig['proxy'] | false => {
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_PROXY)
export const checkProxyMap: IToolboxCheckerMap<
IToolboxItemType.HAS_PROBLEM_WITH_PROXY
IToolboxItemType.HAS_PROBLEM_WITH_PROXY
> = {
[IToolboxItemType.HAS_PROBLEM_WITH_PROXY]: async (event) => {
sendToolboxRes(event, {
+6 -6
View File
@@ -25,7 +25,7 @@ import server from '~/main/server/index'
import updateChecker from '~/main/utils/updateChecker'
import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
import { getUploadFiles } from '~/main/utils/handleArgv'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import { GalleryDB } from '~/main/apis/core/datastore'
import bus from '@core/bus'
import logger from 'apis/core/picgo/logger'
import picgo from 'apis/core/picgo'
@@ -65,8 +65,8 @@ class LifeCycle {
initI18n()
ipcList.listen()
busEventList.listen()
updateShortKeyFromVersion212(db, db.get('settings.shortKey'))
await migrateGalleryFromVersion230(db, GalleryDB.getInstance(), picgo)
updateShortKeyFromVersion212(picgo)
await migrateGalleryFromVersion230(GalleryDB.getInstance(), picgo)
}
private onReady () {
@@ -98,7 +98,7 @@ class LifeCycle {
}
handleMenubarIcon()
handleDockIcon()
db.set('needReload', false)
picgo.saveConfig({ needReload: false })
updateChecker()
// 不需要阻塞
process.nextTick(() => {
@@ -147,13 +147,13 @@ class LifeCycle {
// click dock to open setting window
if (isMacOS) {
handleDockIcon()
if (db.get('settings.showDockIcon') !== false) {
if (picgo.getConfig<boolean>('settings.showDockIcon') !== false) {
windowManager.get(IWindowList.SETTING_WINDOW)?.show()
}
}
})
app.setLoginItemSettings({
openAtLogin: db.get('settings.autoStart') || false
openAtLogin: picgo.getConfig<boolean>('settings.autoStart') || false
})
if (process.platform === 'win32') {
app.setAppUserModelId('com.molunerfinn.picgo')
+19 -14
View File
@@ -1,12 +1,12 @@
import { DBStore } from '@picgo/store'
import ConfigStore from '~/main/apis/core/datastore'
import path from 'path'
import fse from 'fs-extra'
import { PicGo as PicGoCore } from 'picgo'
import { T } from '~/main/i18n'
import { SHORTKEY_COMMAND_UPLOAD } from 'apis/core/bus/constants'
// from v2.1.2
const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IShortKeyConfigs | IOldShortKeyConfigs) => {
const updateShortKeyFromVersion212 = (picgo: PicGoCore) => {
const shortKeyConfig = picgo.getConfig<IShortKeyConfigs | IOldShortKeyConfigs | undefined>('settings.shortKey')
// #557 极端情况可能会出现配置不存在,需要重新写入
if (shortKeyConfig === undefined) {
const defaultShortKeyConfig = {
@@ -15,33 +15,38 @@ const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IS
name: 'upload',
label: T('QUICK_UPLOAD')
}
db.set('settings.shortKey[picgo:upload]', defaultShortKeyConfig)
picgo.saveConfig({
[`settings.shortKey[${SHORTKEY_COMMAND_UPLOAD}]`]: defaultShortKeyConfig
})
return true
}
if (shortKeyConfig.upload) {
// @ts-ignore
shortKeyConfig[SHORTKEY_COMMAND_UPLOAD] = {
if (typeof (shortKeyConfig as IOldShortKeyConfigs).upload === 'string') {
const oldKey = (shortKeyConfig as IOldShortKeyConfigs).upload
const nextConfig = Object.fromEntries(
Object.entries(shortKeyConfig).filter(([key]) => key !== 'upload')
) as IShortKeyConfigs
nextConfig[SHORTKEY_COMMAND_UPLOAD] = {
enable: true,
key: shortKeyConfig.upload,
key: oldKey,
name: 'upload',
label: T('QUICK_UPLOAD')
}
// @ts-ignore
delete shortKeyConfig.upload
db.set('settings.shortKey', shortKeyConfig)
picgo.saveConfig({
'settings.shortKey': nextConfig
})
return true
}
return false
}
const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galleryDB: DBStore, picgo: PicGoCore) => {
const originGallery: ImgInfo[] = picgo.getConfig('uploaded')
const migrateGalleryFromVersion230 = async (galleryDB: DBStore, picgo: PicGoCore) => {
const originGallery = picgo.getConfig<ImgInfo[] | undefined>('uploaded')
// if hasMigrate, we don't need to migrate
const hasMigrate: boolean = configDB.get('__migrateUploaded')
const hasMigrate = picgo.getConfig<boolean | undefined>('__migrateUploaded') === true
if (hasMigrate) {
return
}
const configPath = configDB.getConfigPath()
const configPath = picgo.configPath
const configBakPath = path.join(path.dirname(configPath), 'config.bak.json')
// migrate gallery from config to gallery db
if (originGallery && Array.isArray(originGallery) && originGallery?.length > 0) {
+1 -1
View File
@@ -20,7 +20,7 @@ export type MulterMiddleware = (
req: http.IncomingMessage,
res: http.ServerResponse,
callback: (error?: MulterError) => void
) => void;
) => void
// 扩展 multer 函数的返回类型
declare module 'multer' {
+11 -11
View File
@@ -1,5 +1,4 @@
import fs from 'fs-extra'
import db from '~/main/apis/core/datastore'
import logger from '@core/picgo/logger'
import { clipboard, Notification, dialog } from 'electron'
import { handleUrlEncode } from '~/universal/utils/common'
@@ -8,7 +7,7 @@ import crypto from 'node:crypto'
import picgo from '@core/picgo'
export const handleCopyUrl = (str: string): void => {
if (db.get('settings.autoCopyUrl') !== false) {
if (picgo.getConfig<boolean>('settings.autoCopyUrl') !== false) {
clipboard.writeText(str)
}
}
@@ -27,6 +26,7 @@ export const showNotification = (options: IPrivateShowNotificationOption = {
}) => {
if (options.text) {
logger.info('[PicGo Notification]', options.text)
clipboard.writeText(options.text)
}
const title = options.title || ''
@@ -94,18 +94,18 @@ export const calcUploadProcessDurationRange = (duration: number) => {
export const calcUploadBigFileSizeRange = (fileSizeMB: number) => {
if (fileSizeMB < 10) {
// 3.2 -> 3, 3.6 -> 4
const result = Math.round(fileSizeMB);
return result === 0 && fileSizeMB > 0 ? 1 : result;
const result = Math.round(fileSizeMB)
return result === 0 && fileSizeMB > 0 ? 1 : result
}
else if (fileSizeMB < 100) {
// 13 -> 1.3 -> 1 -> 10
// 17 -> 1.7 -> 2 -> 20
return Math.round(fileSizeMB / 10) * 10;
return Math.round(fileSizeMB / 10) * 10
}
else {
// 135 -> 1.35 -> 1 -> 100
// 160 -> 1.60 -> 2 -> 200
return Math.round(fileSizeMB / 100) * 100;
return Math.round(fileSizeMB / 100) * 100
}
}
@@ -113,18 +113,18 @@ export const calcUploadBigFileSizeRange = (fileSizeMB: number) => {
export const calcVideoDurationRange = (durationSec: number) => {
if (durationSec < 10) {
// 3.2 -> 3, 3.6 -> 4
const result = Math.round(durationSec);
return result === 0 && durationSec > 0 ? 1 : result;
const result = Math.round(durationSec)
return result === 0 && durationSec > 0 ? 1 : result
}
else if (durationSec < 100) {
// 13 -> 1.3 -> 1 -> 10
// 17 -> 1.7 -> 2 -> 20
return Math.round(durationSec / 10) * 10;
return Math.round(durationSec / 10) * 10
}
else {
// 135 -> 1.35 -> 1 -> 100
// 160 -> 1.60 -> 2 -> 200
return Math.round(durationSec / 100) * 100;
return Math.round(durationSec / 100) * 100
}
}
@@ -154,7 +154,7 @@ export const getClipboardFilePathList = (): string[] => {
}
export const handleUrlEncodeWithSetting = (url: string) => {
if (db.get('settings.encodeOutputURL') === true) {
if (picgo.getConfig<boolean>('settings.encodeOutputURL') === true) {
url = handleUrlEncode(url)
}
return url
+46 -46
View File
@@ -1,12 +1,12 @@
import { ipcMain, IpcMainEvent, type WebContents } from "electron";
import { deviceIdManager } from "./deviceId";
import { REGISTER_DEVICE_ID, TALKING_DATA_EVENT } from "~/universal/events/constants";
import type { IImgInfo } from "picgo";
import { calcUploadBigFileSizeRange, calcUploadProcessDurationRange, calcVideoDurationRange } from "./common";
import { app } from "electron/main";
import db from "~/main/apis/core/datastore";
import { getVideoDuration } from "@picgo/video-duration";
import { MB, SECOND } from "./constants";
import { ipcMain, IpcMainEvent, type WebContents } from "electron"
import { deviceIdManager } from "./deviceId"
import { REGISTER_DEVICE_ID, TALKING_DATA_EVENT } from "~/universal/events/constants"
import type { IImgInfo } from "picgo"
import { calcUploadBigFileSizeRange, calcUploadProcessDurationRange, calcVideoDurationRange } from "./common"
import { app } from "electron/main"
import picgo from "@core/picgo"
import { getVideoDuration } from "@picgo/video-duration"
import { MB, SECOND } from "./constants"
export interface IReportUploadDataOptions {
fromClipboard: boolean;
@@ -15,26 +15,26 @@ export interface IReportUploadDataOptions {
}
class DataReportManager {
private deviceId: string | null = null;
private hasRegisterDeviceID: boolean = false;
private deviceId: string | null = null
private hasRegisterDeviceID: boolean = false
constructor () {
this.init()
this.handleRegisterDeviceID()
}
private handleRegisterDeviceID() {
ipcMain.once(REGISTER_DEVICE_ID, (_evt: IpcMainEvent) => {
this.hasRegisterDeviceID = true;
console.log('Device ID registered');
});
this.hasRegisterDeviceID = true
console.log('Device ID registered')
})
}
private async init () {
if (this.deviceId) return;
if (this.deviceId) return
this.deviceId = await deviceIdManager.getId()
}
public async reportUploadData(webContents: WebContents, options: IReportUploadDataOptions) {
await this.init();
await this.registerDeviceID(webContents);
const { fromClipboard, duration, outputList } = options;
await this.init()
await this.registerDeviceID(webContents)
const { fromClipboard, duration, outputList } = options
const fileList = outputList.map(item => {
return {
fileName: item.fileName,
@@ -50,56 +50,56 @@ class DataReportManager {
by: fromClipboard ? 'clipboard' : 'files', // 上传剪贴板图片还是选择的文文件
count: fileList.length, // 上传的数量
duration: calcUploadProcessDurationRange(duration || 0), // 上传耗时
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
}
}
this.reportDataToWebContents(webContents, uploadEventData);
this.reportDataToWebContents(webContents, uploadEventData)
fileList.forEach(async file => {
if (file?.mimeType?.startsWith('video/') && file.filePath) {
const metadata = await getVideoDuration(file.filePath);
const sizeMB = metadata.size / MB;
const durationSec = (metadata.duration / SECOND) || 0;
const metadata = await getVideoDuration(file.filePath)
const sizeMB = metadata.size / MB
const durationSec = (metadata.duration / SECOND) || 0
const videoEventData: ITalkingDataOptions = {
EventId: 'upload_video',
Label: '',
MapKv: {
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
mimeType: file.mimeType,
sizeRange: calcUploadBigFileSizeRange(sizeMB),
durationRange: calcVideoDurationRange(durationSec),
}
};
this.reportDataToWebContents(webContents, videoEventData);
}
this.reportDataToWebContents(webContents, videoEventData)
} else if (file?.mimeType?.startsWith('image/') || fromClipboard) {
const imageEventData: ITalkingDataOptions = {
EventId: 'upload_image',
Label: '',
MapKv: {
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
mimeType: file.mimeType || 'image/png',
sizeRange: calcUploadBigFileSizeRange(file.size / MB)
}
};
this.reportDataToWebContents(webContents, imageEventData);
}
this.reportDataToWebContents(webContents, imageEventData)
} else {
const otherEventData: ITalkingDataOptions = {
EventId: 'upload_file',
Label: '',
MapKv: {
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
mimeType: file.mimeType || 'UNKNOWN',
sizeRange: calcUploadBigFileSizeRange(file.size / MB)
}
};
this.reportDataToWebContents(webContents, otherEventData);
}
this.reportDataToWebContents(webContents, otherEventData)
}
});
})
}
public async registerDeviceID(webContents: WebContents) {
if (this.hasRegisterDeviceID) return;
await this.init();
webContents.send(REGISTER_DEVICE_ID, this.deviceId);
if (this.hasRegisterDeviceID) return
await this.init()
webContents.send(REGISTER_DEVICE_ID, this.deviceId)
}
private reportDataToWebContents(webContents: WebContents, data: ITalkingDataOptions) {
@@ -111,22 +111,22 @@ class DataReportManager {
version: app.getVersion(),
area: this.getAreaFromTimezone()
}
});
})
}
private getAreaFromTimezone() {
try {
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (!timeZone) return 'UNKNOWN';
try {
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
if (!timeZone) return 'UNKNOWN'
if (timeZone === 'Asia/Shanghai') return 'CN';
if (timeZone === 'Asia/Shanghai') return 'CN'
const region = timeZone.split('/')[0]; // Asia, America, Europe
return region;
} catch (e) {
return 'UNKNOWN';
const region = timeZone.split('/')[0] // Asia, America, Europe
return region
} catch (e) {
return 'UNKNOWN'
}
}
}
}
export const dataReportManager = new DataReportManager()
+2 -2
View File
@@ -1,6 +1,6 @@
import db from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { i18nManager } from '~/main/i18n'
export const initI18n = () => {
const currentLanguage = db.get('settings.language') || 'zh-CN'
const currentLanguage = picgo.getConfig<string>('settings.language') || 'zh-CN'
i18nManager.setCurrentLanguage(currentLanguage)
}
+3 -3
View File
@@ -1,16 +1,16 @@
import db from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { showMessageBox } from '~/main/utils/common'
import { T } from '~/main/i18n'
class PrivacyManager {
async check () {
if (db.get('settings.privacyEnsure') !== true) {
if (picgo.getConfig<boolean>('settings.privacyEnsure') !== true) {
const res = await this.show(true)
// cancel
if (res.result === 1) {
return false
} else {
db.set('settings.privacyEnsure', true)
picgo.saveConfig({ 'settings.privacyEnsure': true })
return true
}
}
+6 -6
View File
@@ -1,5 +1,5 @@
import { dialog, shell } from 'electron'
import db from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import pkg from 'root/package.json'
import { lt } from 'semver'
import { T } from '~/main/i18n'
@@ -10,13 +10,13 @@ const version = pkg.version
const downloadUrl = 'https://github.com/Molunerfinn/PicGo/releases/latest'
const checkVersion = async () => {
let showTip = db.get('settings.showUpdateTip')
let showTip = picgo.getConfig<boolean | undefined>('settings.showUpdateTip')
if (showTip === undefined) {
db.set('settings.showUpdateTip', true)
picgo.saveConfig({ 'settings.showUpdateTip': true })
showTip = true
}
if (showTip) {
const isCheckBetaUpdate = db.get('settings.checkBetaUpdate') !== false
const isCheckBetaUpdate = picgo.getConfig<boolean>('settings.checkBetaUpdate') !== false
const res: string = await getLatestVersion(isCheckBetaUpdate)
if (res !== '') {
const latest = res
@@ -35,7 +35,7 @@ const checkVersion = async () => {
if (res.response === 0) { // if selected yes
shell.openExternal(downloadUrl)
}
db.set('settings.showUpdateTip', !res.checkboxChecked)
picgo.saveConfig({ 'settings.showUpdateTip': !res.checkboxChecked })
})
}
} else {
@@ -50,7 +50,7 @@ const checkVersion = async () => {
const compareVersion2Update = (current: string, latest: string) => {
try {
if (latest.includes('beta')) {
const isCheckBetaUpdate = db.get('settings.checkBetaUpdate') !== false
const isCheckBetaUpdate = picgo.getConfig<boolean>('settings.checkBetaUpdate') !== false
if (!isCheckBetaUpdate) {
return false
}
+6 -6
View File
@@ -24,13 +24,13 @@ ipcRenderer.on(TALKING_DATA_EVENT, (_, data: ITalkingDataOptions) => {
// 0:ANONYMOUS,匿名账号;
// 1:REGISTERED,自有帐户显性注册;
ipcRenderer.on(TALKING_DATA_DEVICE_ID_EVENT, (_, deviceId: string) => {
window.TDAPP.register({
window.TDAPP.register({
profileId: deviceId,
profileType: 1
})
window.TDAPP.login({
})
window.TDAPP.login({
profileId: deviceId,
profileType: 1
})
ipcRenderer.send(REGISTER_DEVICE_ID)
});
})
ipcRenderer.send(REGISTER_DEVICE_ID)
})