mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 15:37:21 +08:00
✨ Feature(custom): optimize get config speed
This commit is contained in:
@@ -33,7 +33,7 @@ import { ref, reactive, onBeforeUnmount, onBeforeMount } from 'vue'
|
||||
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import $bus from '@/utils/bus'
|
||||
import { sendToMain } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
|
||||
import {
|
||||
SHOW_INPUT_BOX,
|
||||
|
||||
@@ -246,8 +246,8 @@ import { onBeforeRouteUpdate, useRouter } from 'vue-router'
|
||||
import InputBoxDialog from '@/components/InputBoxDialog.vue'
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import * as config from '@/router/config'
|
||||
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
|
||||
import { openURL } from '@/utils/common'
|
||||
import { getConfig, saveConfig } from '@/utils/dataSender'
|
||||
import { openURL, sendToMain } from '@/utils/common'
|
||||
|
||||
import {
|
||||
MINIMIZE_WINDOW,
|
||||
|
||||
@@ -287,11 +287,11 @@ import { ref, reactive, computed, onBeforeMount, watch } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
|
||||
import { supportedPicBedList } from '@/manage/utils/constants'
|
||||
import { invokeToMain } from '@/manage/utils/dataSender'
|
||||
import { useManageStore } from '@/manage/store/manageStore'
|
||||
import { newBucketConfig } from '@/manage/utils/newBucketConfig'
|
||||
|
||||
import { T as $T } from '@/i18n'
|
||||
import { invokeToMain } from '@/utils/common'
|
||||
|
||||
const manageStore = useManageStore() as any
|
||||
const route = useRoute()
|
||||
|
||||
@@ -248,11 +248,12 @@ import { ref, onBeforeMount, watch } from 'vue'
|
||||
import DynamicSwitch from '@/manage/components/DynamicSwitch.vue'
|
||||
import { fileCacheDbInstance } from '@/manage/store/bucketFileDb'
|
||||
import { formatFileSize, customRenameFormatTable } from '@/manage/utils/common'
|
||||
import { getConfig, saveConfig, invokeToMain } from '@/manage/utils/dataSender'
|
||||
import { getConfig, saveConfig } from '@/manage/utils/dataSender'
|
||||
|
||||
import { T as $T } from '@/i18n'
|
||||
|
||||
import { selectDownloadFolder } from '#/utils/static'
|
||||
import { invokeToMain } from '@/utils/common'
|
||||
|
||||
const form = ref<IStringKeyMap>({
|
||||
timestampRename: false,
|
||||
|
||||
@@ -34,13 +34,3 @@ export function saveConfig (_config: IObj | string, value?: any) {
|
||||
export function removeConfig (key: string, propName: string) {
|
||||
ipcRenderer.send(PICLIST_MANAGE_REMOVE_CONFIG, key, propName)
|
||||
}
|
||||
|
||||
export function sendToMain (channel: string, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
ipcRenderer.send(channel, ...data)
|
||||
}
|
||||
|
||||
export function invokeToMain (channel: string, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
return ipcRenderer.invoke(channel, ...data)
|
||||
}
|
||||
|
||||
@@ -475,7 +475,8 @@ import type { IResult } from '@picgo/store/dist/types'
|
||||
import ALLApi from '@/apis/allApi'
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import { customRenameFormatTable, customStrMatch, customStrReplace } from '@/manage/utils/common'
|
||||
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
import { getConfig, saveConfig } from '@/utils/dataSender'
|
||||
import $$db from '@/utils/db'
|
||||
|
||||
import { PASTE_TEXT, GET_PICBEDS } from '#/events/constants'
|
||||
|
||||
@@ -40,8 +40,8 @@ import { IConfig } from 'piclist'
|
||||
import { onBeforeUnmount, onBeforeMount, ref, watch } from 'vue'
|
||||
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import { invokeToMain } from '@/manage/utils/dataSender'
|
||||
import { getConfig, sendToMain } from '@/utils/dataSender'
|
||||
import { sendToMain, invokeToMain } from '@/utils/common'
|
||||
import { getConfig } from '@/utils/dataSender'
|
||||
|
||||
import { SHOW_MINI_PAGE_MENU, SET_MINI_WINDOW_POS } from '#/events/constants'
|
||||
import { isUrl } from '#/utils/common'
|
||||
|
||||
@@ -1388,9 +1388,8 @@ import { useRouter } from 'vue-router'
|
||||
import ImageProcessSetting from '@/components/ImageProcessSetting.vue'
|
||||
import { i18nManager, T as $T } from '@/i18n/index'
|
||||
import { buildInRenameFormatTable } from '@/manage/utils/common'
|
||||
import { invokeToMain } from '@/manage/utils/dataSender'
|
||||
import { SHORTKEY_PAGE } from '@/router/config'
|
||||
import { getConfig, saveConfig, sendRPC, sendToMain } from '@/utils/dataSender'
|
||||
import { getConfig, saveConfig, sendRPC } from '@/utils/dataSender'
|
||||
|
||||
import { PICGO_OPEN_FILE, PICGO_OPEN_DIRECTORY, OPEN_URL, GET_PICBEDS, HIDE_DOCK } from '#/events/constants'
|
||||
import { II18nLanguage, IRPCActionType, ISartMode } from '#/types/enum'
|
||||
@@ -1399,6 +1398,7 @@ import { configPaths, ISartModeValues } from '#/utils/configPaths'
|
||||
import { getLatestVersion } from '#/utils/getLatestVersion'
|
||||
|
||||
import pkg from 'root/package.json'
|
||||
import { invokeToMain, sendToMain } from '@/utils/common'
|
||||
|
||||
const $router = useRouter()
|
||||
const activeName = ref<'system' | 'syncAndConfigure' | 'upload' | 'advanced' | 'upadte'>('system')
|
||||
@@ -1422,7 +1422,7 @@ const languageList = i18nManager.languageList.map(item => ({
|
||||
}))
|
||||
|
||||
const startModeList = Object.values(ISartMode).map(item => ({
|
||||
label: $T(`SETTINGS_START_MODE_${item.toUpperCase().replace(/_/g, '')}` as any),
|
||||
label: $T(`SETTINGS_START_MODE_${item.toUpperCase().replace(/-/g, '_')}` as any),
|
||||
value: item
|
||||
}))
|
||||
|
||||
|
||||
@@ -241,7 +241,8 @@ import { computed, ref, onBeforeMount, onBeforeUnmount, watch, onMounted, reacti
|
||||
|
||||
import ConfigForm from '@/components/ConfigFormForPlugin.vue'
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import { getConfig, saveConfig, sendRPC, sendToMain } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
import { getConfig, saveConfig, sendRPC } from '@/utils/dataSender'
|
||||
|
||||
import {
|
||||
OPEN_URL,
|
||||
|
||||
@@ -60,7 +60,7 @@ import { onBeforeUnmount, onBeforeMount, ref, reactive } from 'vue'
|
||||
|
||||
import { useIPCOn } from '@/hooks/useIPC'
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import { sendToMain } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
|
||||
import { GET_RENAME_FILE_NAME, RENAME_FILE_NAME } from '#/events/constants'
|
||||
|
||||
|
||||
@@ -122,7 +122,8 @@ import { ipcRenderer, IpcRendererEvent } from 'electron'
|
||||
import { onBeforeUnmount, onBeforeMount, ref, watch } from 'vue'
|
||||
|
||||
import { T as $T } from '@/i18n'
|
||||
import { getConfig, sendToMain } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
import { getConfig } from '@/utils/dataSender'
|
||||
import keyBinding from '@/utils/key-binding'
|
||||
|
||||
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
|
||||
|
||||
@@ -67,7 +67,8 @@ import { reactive, ref, onBeforeUnmount, onBeforeMount } from 'vue'
|
||||
import { IResult } from '@picgo/store/dist/types'
|
||||
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import { getConfig, sendToMain } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
import { getConfig } from '@/utils/dataSender'
|
||||
|
||||
import $$db from '@/utils/db'
|
||||
|
||||
|
||||
@@ -164,7 +164,8 @@ import ImageProcessSetting from '@/components/ImageProcessSetting.vue'
|
||||
import { T as $T } from '@/i18n'
|
||||
import { PICBEDS_PAGE } from '@/router/config'
|
||||
import $bus from '@/utils/bus'
|
||||
import { getConfig, saveConfig, sendToMain, triggerRPC } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
import { getConfig, saveConfig, triggerRPC } from '@/utils/dataSender'
|
||||
|
||||
import {
|
||||
SHOW_INPUT_BOX,
|
||||
|
||||
@@ -110,7 +110,8 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import ConfigForm from '@/components/ConfigForm.vue'
|
||||
import { T as $T } from '@/i18n/index'
|
||||
import { getConfig, sendToMain, triggerRPC } from '@/utils/dataSender'
|
||||
import { sendToMain } from '@/utils/common'
|
||||
import { getConfig, triggerRPC } from '@/utils/dataSender'
|
||||
|
||||
import { OPEN_URL } from '#/events/constants'
|
||||
import { II18nLanguage, IRPCActionType } from '#/types/enum'
|
||||
|
||||
@@ -5,6 +5,7 @@ import { OPEN_URL } from '#/events/constants'
|
||||
import { ILogType } from '#/types/enum'
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
||||
|
||||
export const handleTalkingDataEvent = (data: ITalkingDataOptions) => {
|
||||
const { EventId, Label = '', MapKv = {} } = data
|
||||
MapKv.from = window.location.href
|
||||
@@ -31,11 +32,16 @@ export const getRawData = (args: any): any => {
|
||||
return args
|
||||
}
|
||||
|
||||
function sendToMain (channel: string, ...args: any[]) {
|
||||
export function sendToMain (channel: string, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
ipcRenderer.send(channel, ...data)
|
||||
}
|
||||
|
||||
export function invokeToMain (channel: string, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
return ipcRenderer.invoke(channel, ...data)
|
||||
}
|
||||
|
||||
export const openURL = (url: string) => {
|
||||
sendToMain(OPEN_URL, url)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { v4 as uuid } from 'uuid'
|
||||
|
||||
import { getRawData } from '@/utils/common'
|
||||
|
||||
import { PICGO_SAVE_CONFIG, PICGO_GET_CONFIG, RPC_ACTIONS } from '#/events/constants'
|
||||
import { PICGO_SAVE_CONFIG, PICGO_GET_CONFIG, RPC_ACTIONS, PICGO_GET_CONFIG_SYNC } from '#/events/constants'
|
||||
import { IRPCActionType } from '#/types/enum'
|
||||
|
||||
export function saveConfig (config: IObj | string, value?: any) {
|
||||
@@ -11,18 +11,12 @@ export function saveConfig (config: IObj | string, value?: any) {
|
||||
ipcRenderer.send(PICGO_SAVE_CONFIG, configObject)
|
||||
}
|
||||
|
||||
export function getConfig<T> (key?: string): Promise<T | undefined> {
|
||||
return new Promise((resolve) => {
|
||||
const callbackId = uuid()
|
||||
const callback = (_event: IpcRendererEvent, config: T | undefined, returnCallbackId: string) => {
|
||||
if (returnCallbackId === callbackId) {
|
||||
resolve(config)
|
||||
ipcRenderer.removeListener(PICGO_GET_CONFIG, callback)
|
||||
}
|
||||
}
|
||||
ipcRenderer.on(PICGO_GET_CONFIG, callback)
|
||||
ipcRenderer.send(PICGO_GET_CONFIG, key, callbackId)
|
||||
})
|
||||
export async function getConfig<T> (key?: string): Promise<T | undefined> {
|
||||
return await ipcRenderer.invoke(PICGO_GET_CONFIG, key)
|
||||
}
|
||||
|
||||
export async function getConfigSync<T> (key?: string): Promise<T | undefined> {
|
||||
return await ipcRenderer.sendSync(PICGO_GET_CONFIG_SYNC, key)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,8 +47,3 @@ export function sendRPC (action: IRPCActionType, ...args: any[]): void {
|
||||
const data = getRawData(args)
|
||||
ipcRenderer.send(RPC_ACTIONS, action, data)
|
||||
}
|
||||
|
||||
export function sendToMain (channel: string, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
ipcRenderer.send(channel, ...data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user