mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-22 08:47:06 +08:00
🎨 Style(custom): format with prettier
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
/* eslint-disable camelcase */
|
||||
import { ipcRenderer } from 'electron'
|
||||
import {
|
||||
TALKING_DATA_APPID, TALKING_DATA_EVENT
|
||||
} from '#/events/constants'
|
||||
import { TALKING_DATA_APPID, TALKING_DATA_EVENT } from '#/events/constants'
|
||||
|
||||
import { handleTalkingDataEvent } from '@/utils/common'
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import mitt from 'mitt'
|
||||
import {
|
||||
SHOW_INPUT_BOX,
|
||||
SHOW_INPUT_BOX_RESPONSE
|
||||
} from '#/events/constants'
|
||||
import { SHOW_INPUT_BOX, SHOW_INPUT_BOX_RESPONSE } from '#/events/constants'
|
||||
|
||||
type IEvent ={
|
||||
type IEvent = {
|
||||
[SHOW_INPUT_BOX_RESPONSE]: string
|
||||
[SHOW_INPUT_BOX]: {
|
||||
value: string
|
||||
|
||||
@@ -36,7 +36,7 @@ export const getRawData = (args: any): any => {
|
||||
return args
|
||||
}
|
||||
|
||||
export function sendToMain (channel: string, ...args: any[]) {
|
||||
export function sendToMain(channel: string, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
ipcRenderer.send(channel, ...data)
|
||||
}
|
||||
@@ -46,26 +46,26 @@ export function sendToMain (channel: string, ...args: any[]) {
|
||||
*
|
||||
* or the response will be handled by other listener
|
||||
*/
|
||||
export function sendRPC (action: IRPCActionType, ...args: any[]): void {
|
||||
export function sendRPC(action: IRPCActionType, ...args: any[]): void {
|
||||
const data = getRawData(args)
|
||||
ipcRenderer.send(RPC_ACTIONS, action, data)
|
||||
}
|
||||
|
||||
export function sendRpcSync (action: IRPCActionType, ...args: any[]) {
|
||||
export function sendRpcSync(action: IRPCActionType, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
return ipcRenderer.sendSync(RPC_ACTIONS, action, data)
|
||||
}
|
||||
|
||||
export function invokeToMain (channel: string, ...args: any[]) {
|
||||
export function invokeToMain(channel: string, ...args: any[]) {
|
||||
const data = getRawData(args)
|
||||
return ipcRenderer.invoke(channel, ...data)
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger RPC action
|
||||
* TODO: create an isolate rpc handler
|
||||
*/
|
||||
export async function triggerRPC<T> (action: IRPCActionType, ...args: any[]): Promise<T | undefined> {
|
||||
* trigger RPC action
|
||||
* TODO: create an isolate rpc handler
|
||||
*/
|
||||
export async function triggerRPC<T>(action: IRPCActionType, ...args: any[]): Promise<T | undefined> {
|
||||
const data = getRawData(args)
|
||||
return await ipcRenderer.invoke(RPC_ACTIONS_INVOKE, action, data)
|
||||
}
|
||||
|
||||
@@ -5,17 +5,15 @@ import { sendRPC, triggerRPC } from '@/utils/common'
|
||||
import { RPC_ACTIONS } from '#/events/constants'
|
||||
import { IRPCActionType } from 'root/src/universal/types/enum'
|
||||
|
||||
export function saveConfig (config: IObj | string, value?: any) {
|
||||
const configObject = typeof config === 'string'
|
||||
? { [config]: value }
|
||||
: config
|
||||
export function saveConfig(config: IObj | string, value?: any) {
|
||||
const configObject = typeof config === 'string' ? { [config]: value } : config
|
||||
sendRPC(IRPCActionType.PICLIST_SAVE_CONFIG, configObject)
|
||||
}
|
||||
|
||||
export async function getConfig<T> (key?: string): Promise<T | undefined> {
|
||||
export async function getConfig<T>(key?: string): Promise<T | undefined> {
|
||||
return await triggerRPC<T>(IRPCActionType.PICLIST_GET_CONFIG, key)
|
||||
}
|
||||
|
||||
export async function getConfigSync<T> (key?: string): Promise<T | undefined> {
|
||||
export async function getConfigSync<T>(key?: string): Promise<T | undefined> {
|
||||
return await ipcRenderer.sendSync(RPC_ACTIONS, IRPCActionType.PICLIST_GET_CONFIG_SYNC, [key])
|
||||
}
|
||||
|
||||
@@ -6,37 +6,37 @@ import { IRPCActionType } from '#/types/enum'
|
||||
import { IGalleryDB } from '#/types/extra-vue'
|
||||
|
||||
export class GalleryDB implements IGalleryDB {
|
||||
async get<T> (filter?: IFilter): Promise<IGetResult<T> | undefined> {
|
||||
async get<T>(filter?: IFilter): Promise<IGetResult<T> | undefined> {
|
||||
const res = await this.#msgHandler<IGetResult<T>>(IRPCActionType.GALLERY_GET_DB, filter)
|
||||
return res
|
||||
}
|
||||
|
||||
async insert<T> (value: T): Promise<IResult<T> | undefined> {
|
||||
async insert<T>(value: T): Promise<IResult<T> | undefined> {
|
||||
const res = await this.#msgHandler<IResult<T>>(IRPCActionType.GALLERY_INSERT_DB, value)
|
||||
return res
|
||||
}
|
||||
|
||||
async insertMany<T> (value: T[]): Promise<IResult<T>[] | undefined> {
|
||||
async insertMany<T>(value: T[]): Promise<IResult<T>[] | undefined> {
|
||||
const res = await this.#msgHandler<IResult<T>[]>(IRPCActionType.GALLERY_INSERT_DB_BATCH, value)
|
||||
return res
|
||||
}
|
||||
|
||||
async updateById (id: string, value: IObject): Promise<boolean> {
|
||||
const res = await this.#msgHandler<boolean>(IRPCActionType.GALLERY_UPDATE_BY_ID_DB, id, value) || false
|
||||
async updateById(id: string, value: IObject): Promise<boolean> {
|
||||
const res = (await this.#msgHandler<boolean>(IRPCActionType.GALLERY_UPDATE_BY_ID_DB, id, value)) || false
|
||||
return res
|
||||
}
|
||||
|
||||
async getById<T> (id: string): Promise<IResult<T> | undefined> {
|
||||
async getById<T>(id: string): Promise<IResult<T> | undefined> {
|
||||
const res = await this.#msgHandler<IResult<T> | undefined>(IRPCActionType.GALLERY_GET_BY_ID_DB, id)
|
||||
return res
|
||||
}
|
||||
|
||||
async removeById (id: string): Promise<void> {
|
||||
async removeById(id: string): Promise<void> {
|
||||
const res = await this.#msgHandler<void>(IRPCActionType.GALLERY_REMOVE_BY_ID_DB, id)
|
||||
return res
|
||||
}
|
||||
|
||||
async #msgHandler<T> (method: IRPCActionType, ...args: any[]): Promise<T | undefined> {
|
||||
async #msgHandler<T>(method: IRPCActionType, ...args: any[]): Promise<T | undefined> {
|
||||
return await triggerRPC<T>(method, ...args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,18 +6,12 @@ const osGlobal = ref<string>(process.platform)
|
||||
const picBedGlobal = ref<IPicBedType[]>([])
|
||||
const pageReloadCount = ref(0)
|
||||
|
||||
async function updatePicBedGlobal () {
|
||||
async function updatePicBedGlobal() {
|
||||
picBedGlobal.value = (await triggerRPC<IPicBedType[]>(IRPCActionType.MAIN_GET_PICBED))!
|
||||
}
|
||||
|
||||
async function updatePageReloadCount () {
|
||||
async function updatePageReloadCount() {
|
||||
pageReloadCount.value++
|
||||
}
|
||||
|
||||
export {
|
||||
osGlobal,
|
||||
pageReloadCount,
|
||||
picBedGlobal,
|
||||
updatePicBedGlobal,
|
||||
updatePageReloadCount
|
||||
}
|
||||
export { osGlobal, pageReloadCount, picBedGlobal, updatePicBedGlobal, updatePageReloadCount }
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { ComponentOptions } from 'vue'
|
||||
|
||||
export const dragMixin: ComponentOptions = {
|
||||
mounted () {
|
||||
mounted() {
|
||||
this.disableDragEvent()
|
||||
},
|
||||
|
||||
methods: {
|
||||
disableDragEvent () {
|
||||
disableDragEvent() {
|
||||
window.addEventListener('dragenter', this.disableDrag, false)
|
||||
window.addEventListener('dragover', this.disableDrag)
|
||||
window.addEventListener('drop', this.disableDrag)
|
||||
},
|
||||
|
||||
disableDrag (e: DragEvent) {
|
||||
disableDrag(e: DragEvent) {
|
||||
const dropzone = document.getElementById('upload-area')
|
||||
if (dropzone === null || !dropzone.contains(<Node>e.target)) {
|
||||
e.preventDefault()
|
||||
@@ -22,7 +22,7 @@ export const dragMixin: ComponentOptions = {
|
||||
}
|
||||
},
|
||||
|
||||
beforeUnmount () {
|
||||
beforeUnmount() {
|
||||
window.removeEventListener('dragenter', this.disableDrag, false)
|
||||
window.removeEventListener('dragover', this.disableDrag)
|
||||
window.removeEventListener('drop', this.disableDrag)
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { v4 as uuid } from 'uuid'
|
||||
|
||||
export const completeUploaderMetaConfig = (originData: IStringKeyMap): IStringKeyMap => {
|
||||
return Object.assign({
|
||||
_configName: 'Default'
|
||||
}, originData, {
|
||||
_id: uuid(),
|
||||
_createdAt: Date.now(),
|
||||
_updatedAt: Date.now()
|
||||
})
|
||||
return Object.assign(
|
||||
{
|
||||
_configName: 'Default'
|
||||
},
|
||||
originData,
|
||||
{
|
||||
_id: uuid(),
|
||||
_createdAt: Date.now(),
|
||||
_updatedAt: Date.now()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user