🚧 WIP(custom): v3.0.0 migrate to vite and esm

This commit is contained in:
Kuingsmile
2025-07-31 17:37:30 +08:00
parent cd76bc7c10
commit 054f4b4cff
597 changed files with 197292 additions and 13329 deletions

View File

@@ -1,13 +1,30 @@
import { IObject, IResult, IGetResult, IFilter } from '@picgo/store/dist/types'
import { triggerRPC } from '@/utils/common'
import { IRPCActionType } from '#/types/enum'
import { IGalleryDB } from '#/types/extra-vue'
interface IFilter {
orderBy?: 'asc' | 'desc'
limit?: number
offset?: number
}
interface IGetResult<T> {
total: number
data: IResult<T>[]
}
interface IObject {
id?: string
[propName: string]: any
}
type IResult<T> = T & {
id: string
createdAt: number
updatedAt: number
}
export class GalleryDB implements IGalleryDB {
async #actionHandler<T>(method: IRPCActionType, ...args: any[]): Promise<T | undefined> {
return await triggerRPC<T>(method, ...args)
return await window.electron.triggerRPC<T>(method, ...args)
}
async get<T>(filter?: IFilter): Promise<IGetResult<T> | undefined> {
@@ -22,7 +39,7 @@ export class GalleryDB implements IGalleryDB {
return await this.#actionHandler<IResult<T>[]>(IRPCActionType.GALLERY_INSERT_DB_BATCH, value)
}
async updateById(id: string, value: IObject): Promise<boolean> {
async updateById (id: string, value: IObject): Promise<boolean> {
return (await this.#actionHandler<boolean>(IRPCActionType.GALLERY_UPDATE_BY_ID_DB, id, value)) || false
}
@@ -30,7 +47,7 @@ export class GalleryDB implements IGalleryDB {
return await this.#actionHandler<IResult<T> | undefined>(IRPCActionType.GALLERY_GET_BY_ID_DB, id)
}
async removeById(id: string): Promise<void> {
async removeById (id: string): Promise<void> {
return await this.#actionHandler<void>(IRPCActionType.GALLERY_REMOVE_BY_ID_DB, id)
}
}