🔨 Refactor: refactored the import section of the code

This commit is contained in:
萌萌哒赫萝 2023-08-07 01:36:27 -07:00
parent 33b36d63c6
commit cb131d5250
64 changed files with 778 additions and 195 deletions

View File

@ -1,25 +1,43 @@
// Vue 相关
import { createApp } from 'vue'
import App from './renderer/App.vue'
import router from './renderer/router'
import ElementUI from 'element-plus'
import 'element-plus/dist/index.css'
import { webFrame } from 'electron'
import VueLazyLoad from 'vue3-lazyload'
import axios from 'axios'
import { mainMixin } from './renderer/utils/mainMixin'
import { dragMixin } from '@/utils/mixin'
import db from './renderer/utils/db'
import { i18nManager, T } from './renderer/i18n/index'
import { getConfig, saveConfig, sendToMain, triggerRPC } from '@/utils/dataSender'
import { store } from '@/store'
import vue3PhotoPreview from 'vue3-photo-preview'
import 'vue3-photo-preview/dist/index.css'
import VueVideoPlayer from '@videojs-player/vue'
// Electron 相关
import { webFrame } from 'electron'
// Axios
import axios from 'axios'
// Mixins
import { mainMixin } from './renderer/utils/mainMixin'
import { dragMixin } from '@/utils/mixin'
// 数据库
import db from './renderer/utils/db'
// 国际化
import { i18nManager, T } from './renderer/i18n/index'
// 工具函数
import { getConfig, saveConfig, sendToMain, triggerRPC } from '@/utils/dataSender'
// 状态管理
import { store } from '@/store'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
// 代码高亮
import 'highlight.js/styles/atom-one-dark.css'
import hljsVuePlugin from '@highlightjs/vue-plugin'
import hljsCommon from 'highlight.js/lib/common'
import VueVideoPlayer from '@videojs-player/vue'
import 'video.js/dist/video-js.css'
webFrame.setVisualZoomLevelLimits(1, 1)

View File

@ -1,15 +1,25 @@
// get notice from remote
// such as some notices for users; some updates for users
// External dependencies
import axios from 'axios'
import fs from 'fs-extra'
import { app, clipboard, dialog, shell } from 'electron'
import { IRemoteNoticeActionType, IRemoteNoticeTriggerCount, IRemoteNoticeTriggerHook } from '#/types/enum'
import { lte, gte } from 'semver'
import path from 'path'
import axios from 'axios'
// Electron modules
import { app, clipboard, dialog, shell } from 'electron'
// Custom modules and utilities
import windowManager from '../window/windowManager'
import { showNotification } from '~/main/utils/common'
// Custom types/enums
import {
IRemoteNoticeActionType,
IRemoteNoticeTriggerCount,
IRemoteNoticeTriggerHook
} from '#/types/enum'
// External utility functions
import { gte, lte } from 'semver'
// for test
const REMOTE_NOTICE_URL = 'https://release.piclist.cn/remote-notice.json'

View File

@ -1,14 +1,24 @@
import bus from '@core/bus'
// External dependencies
import {
globalShortcut
} from 'electron'
import logger from '@core/picgo/logger'
import GuiApi from '../../gui'
import bus from '@core/bus'
import db from '~/main/apis/core/datastore'
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
import shortKeyService from './shortKeyService'
import logger from '@core/picgo/logger'
import picgo from '@core/picgo'
// Electron modules
// Custom utilities and modules
import GuiApi from '../../gui'
import shortKeyService from './shortKeyService'
// Custom types/enums
// External utility functions
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
class ShortKeyHandler {
private isInModifiedMode: boolean = false
constructor () {

View File

@ -1,4 +1,5 @@
import logger from '@core/picgo/logger'
class ShortKeyService {
private commandList: Map<string, IShortKeyHandler> = new Map()
registerCommand (command: string, handler: IShortKeyHandler) {

View File

@ -1,4 +1,8 @@
// External dependencies
import fs from 'fs-extra'
import { cloneDeep } from 'lodash'
// Electron modules
import {
app,
Menu,
@ -9,6 +13,8 @@ import {
screen,
nativeTheme
} from 'electron'
// Custom utilities and modules
import uploader from 'apis/app/uploader'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import windowManager from 'apis/app/window/windowManager'
@ -22,7 +28,7 @@ import { buildPicBedListMenu } from '~/main/events/remotes/menu'
import clipboardPoll from '~/main/utils/clipboardPoll'
import picgo from '../../core/picgo'
import { uploadClipboardFiles } from '../uploader/apis'
import { cloneDeep } from 'lodash'
let contextMenu: Menu | null
let tray: Tray | null

View File

@ -1,10 +1,15 @@
// External dependencies
import fs from 'fs-extra'
import { cloneDeep } from 'lodash'
// Electron modules
import {
Notification,
WebContents
} from 'electron'
// Custom utilities and modules
import windowManager from 'apis/app/window/windowManager'
import { IWindowList } from '#/types/enum'
import uploader from '.'
import pasteTemplate from '~/main/utils/pasteTemplate'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import { handleCopyUrl, handleUrlEncodeWithSetting } from '~/main/utils/common'
@ -12,8 +17,8 @@ import { T } from '~/main/i18n/index'
import ALLApi from '@/apis/allApi'
import picgo from '@core/picgo'
import GuiApi from '../../gui'
import fs from 'fs-extra'
import { cloneDeep } from 'lodash'
import uploader from '.'
import { IWindowList } from '#/types/enum'
const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
const useBuiltinClipboard = db.get('settings.useBuiltinClipboard') === undefined ? true : !!db.get('settings.useBuiltinClipboard')

View File

@ -1,3 +1,11 @@
// External dependencies
import dayjs from 'dayjs'
import util from 'util'
import path from 'path'
import writeFile from 'write-file-atomic'
import fse from 'fs-extra'
// Electron modules
import {
Notification,
BrowserWindow,
@ -5,22 +13,26 @@ import {
WebContents,
clipboard
} from 'electron'
import dayjs from 'dayjs'
// Custom utilities and modules
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'
import { IPicGo } from 'piclist'
import { showNotification, getClipboardFilePath } from '~/main/utils/common'
import { GET_RENAME_FILE_NAME, RENAME_FILE_NAME } from '~/universal/events/constants'
import logger from '@core/picgo/logger'
import { T } from '~/main/i18n'
import fse from 'fs-extra'
import path from 'path'
import writeFile from 'write-file-atomic'
import { CLIPBOARD_IMAGE_FOLDER } from '~/universal/utils/static'
// Custom types/enums
import { IWindowList } from '#/types/enum'
// External utility functions
import { IPicGo } from 'piclist'
import {
GET_RENAME_FILE_NAME,
RENAME_FILE_NAME
} from '~/universal/events/constants'
const waitForRename = (window: BrowserWindow, id: number): Promise<string|null> => {
return new Promise((resolve) => {
const windowId = window.id

View File

@ -1,3 +1,14 @@
// External dependencies
import { app } from 'electron'
// Electron modules
// Custom utilities and modules
import bus from '@core/bus'
import db from '~/main/apis/core/datastore'
import picgo from '~/main/apis/core/picgo'
import { T } from '~/main/i18n'
import { remoteNoticeHandler } from '../remoteNotice'
import {
SETTING_WINDOW_URL,
TRAY_WINDOW_URL,
@ -5,15 +16,13 @@ import {
RENAME_WINDOW_URL,
TOOLBOX_WINDOW_URL
} from './constants'
// Custom types/enums
import { IRemoteNoticeTriggerHook, IWindowList } from '#/types/enum'
import bus from '@core/bus'
// External utility functions
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 { remoteNoticeHandler } from '../remoteNotice'
import picgo from '~/main/apis/core/picgo'
import { T } from '~/main/i18n'
const windowList = new Map<IWindowList, IWindowListItem>()

View File

@ -1,7 +1,12 @@
import {
BrowserWindow
} from 'electron'
// External dependencies
import windowList from './windowList'
// Electron modules
import { BrowserWindow } from 'electron'
// Custom utilities and modules
// Custom types/enums
import { IWindowList } from '#/types/enum'
class WindowManager implements IWindowManager {

View File

@ -1,10 +1,24 @@
// External dependencies
import fs from 'fs-extra'
import writeFile from 'write-file-atomic'
import path from 'path'
import { app } from 'electron'
import { getLogger } from '../utils/localLogger'
import dayjs from 'dayjs'
import path from 'path'
// Electron modules
import { app } from 'electron'
// Custom utilities and modules
import { getLogger } from '../utils/localLogger'
// Custom types/enums
// External utility functions
// External utility functions
import writeFile from 'write-file-atomic'
// Custom types/enums
import { T } from '~/main/i18n'
const STORE_PATH = app.getPath('userData')
const configFilePath = path.join(STORE_PATH, 'data.json')
const configFileBackupPath = path.join(STORE_PATH, 'data.bak.json')

View File

@ -1,6 +1,17 @@
// External dependencies
import fs from 'fs-extra'
// Electron modules
// Custom utilities and modules
import { dbPathChecker, dbPathDir, getGalleryDBPath } from './dbChecker'
// Custom types/enums
// External utility functions
import { DBStore, JSONStore } from '@picgo/store'
// External utility functions
import { T } from '~/main/i18n'
const STORE_PATH = dbPathDir()

View File

@ -1,8 +1,17 @@
import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker'
// External dependencies
import pkg from 'root/package.json'
import debounce from 'lodash/debounce'
// Electron modules
// Custom utilities and modules
import { PicGo } from 'piclist'
import db from 'apis/core/datastore'
import debounce from 'lodash/debounce'
import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker'
// Custom types/enums
// External utility functions
const CONFIG_PATH = dbPathChecker()

View File

@ -1,25 +1,29 @@
// External dependencies
import fs from 'fs-extra'
import { cloneDeep } from 'lodash'
// Electron modules
import {
dialog,
BrowserWindow,
Notification,
ipcMain
} from 'electron'
// Custom utilities and modules
import db, { 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'
import { handleCopyUrl } from '~/main/utils/common'
import {
getWindowId,
getSettingWindowId
} from '@core/bus/apis'
import {
SHOW_INPUT_BOX
} from '~/universal/events/constants'
import { getWindowId, getSettingWindowId } from '@core/bus/apis'
import { SHOW_INPUT_BOX } from '~/universal/events/constants'
// Custom types/enums
// External utility functions
import { DBStore } from '@picgo/store'
import { T } from '~/main/i18n'
import fs from 'fs-extra'
import { cloneDeep } from 'lodash'
// Cross-process support may be required in the future
class GuiApi implements IGuiApi {

View File

@ -1,4 +1,9 @@
// External dependencies
import bus from '@core/bus'
// Electron modules
// Custom utilities and modules
import {
uploadClipboardFiles,
uploadChoosedFiles
@ -6,8 +11,12 @@ import {
import {
createMenu
} from 'apis/app/system'
import { IWindowList } from '#/types/enum'
import windowManager from 'apis/app/window/windowManager'
// Custom types/enums
import { IWindowList } from '#/types/enum'
// External utility functions
import {
UPLOAD_WITH_FILES,
UPLOAD_WITH_FILES_RESPONSE,
@ -19,6 +28,7 @@ import {
GET_SETTING_WINDOW_ID_RESPONSE,
CREATE_APP_MENU
} from '@core/bus/constants'
function initEventCenter () {
const eventList: any = {
'picgo:upload': uploadClipboardFiles,

View File

@ -126,7 +126,7 @@ export default {
try {
const client = SSHClient.instance
await client.connect(config)
const uploadPath = `/${(config.uploadPath || '').replace(/^\/+|\/+$/g, '')}/`.replace(/\/+/g, '/')
const uploadPath = `/${(config.uploadPath || '')}/`.replace(/\/+/g, '/')
const remote = path.join(uploadPath, fileName)
const deleteResult = await client.deleteFile(remote)
client.close()

View File

@ -1,5 +1,5 @@
// External dependencies
import path from 'path'
import GuiApi from 'apis/gui'
import {
dialog,
shell,
@ -7,7 +7,11 @@ import {
ipcMain,
clipboard
} from 'electron'
import { IPasteStyle, IPicGoHelperType, IWindowList } from '#/types/enum'
// Electron modules
// Custom utilities and modules
import GuiApi from 'apis/gui'
import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
import picgo from '@core/picgo'
import { handleStreamlinePluginName, simpleClone } from '~/universal/utils/common'
@ -15,6 +19,16 @@ import { IGuiMenuItem, PicGo as PicGoCore } from 'piclist'
import windowManager from 'apis/app/window/windowManager'
import { showNotification } from '~/main/utils/common'
import { dbPathChecker } from 'apis/core/datastore/dbChecker'
import { GalleryDB } from 'apis/core/datastore'
import pasteTemplate from '../utils/pasteTemplate'
import { i18nManager, T } from '~/main/i18n'
import { rpcServer } from './rpc'
// Custom types/enums
import { IPasteStyle, IPicGoHelperType, IWindowList } from '#/types/enum'
import { IObject, IFilter } from '@picgo/store/dist/types'
// External utility functions
import {
PICGO_SAVE_CONFIG,
PICGO_GET_CONFIG,
@ -32,12 +46,6 @@ import {
GET_CURRENT_LANGUAGE
} from '#/events/constants'
import { GalleryDB } from 'apis/core/datastore'
import { IObject, IFilter } from '@picgo/store/dist/types'
import pasteTemplate from '../utils/pasteTemplate'
import { i18nManager, T } from '~/main/i18n'
import { rpcServer } from './rpc'
// eslint-disable-next-line
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
// const PluginHandler = requireFunc('picgo/lib/PluginHandler').default

View File

@ -1,20 +1,37 @@
import windowManager from 'apis/app/window/windowManager'
import { IWindowList } from '#/types/enum'
// External dependencies
import pkg from 'root/package.json'
// Electron modules
import { Menu, BrowserWindow, app, dialog } from 'electron'
// Custom utilities and modules
import windowManager from 'apis/app/window/windowManager'
import getPicBeds from '~/main/utils/getPicBeds'
import picgo from '@core/picgo'
import {
uploadClipboardFiles
} from '~/main/apis/app/uploader/apis'
import pkg from 'root/package.json'
import GuiApi from 'apis/gui'
import { PICGO_CONFIG_PLUGIN, PICGO_HANDLE_PLUGIN_DONE, PICGO_HANDLE_PLUGIN_ING, PICGO_TOGGLE_PLUGIN, SHOW_MAIN_PAGE_DONATION, SHOW_MAIN_PAGE_QRCODE } from '~/universal/events/constants'
import picgoCoreIPC from '~/main/events/picgoCoreIPC'
import { PicGo as PicGoCore } from 'piclist'
import { T } from '~/main/i18n'
import { changeCurrentUploader } from '~/main/utils/handleUploaderConfig'
import db from '~/main/apis/core/datastore'
import clipboardPoll from '~/main/utils/clipboardPoll'
// Custom types/enums
import { IWindowList } from '#/types/enum'
// External utility functions
import {
uploadClipboardFiles
} from '~/main/apis/app/uploader/apis'
import {
PICGO_CONFIG_PLUGIN,
PICGO_HANDLE_PLUGIN_DONE,
PICGO_HANDLE_PLUGIN_ING,
PICGO_TOGGLE_PLUGIN,
SHOW_MAIN_PAGE_DONATION,
SHOW_MAIN_PAGE_QRCODE
} from '~/universal/events/constants'
import { PicGo as PicGoCore } from 'piclist'
import { T } from '~/main/i18n'
interface GuiMenuItem {
label: string
handle: (arg0: PicGoCore, arg1: GuiApi) => Promise<void>

View File

@ -1,10 +1,19 @@
// External dependencies
import { ipcMain, IpcMainEvent } from 'electron'
import { IRPCActionType } from '~/universal/types/enum'
import { RPC_ACTIONS } from '#/events/constants'
// Electron modules
// Custom utilities and modules
import { configRouter } from './routes/config'
import { toolboxRouter } from './routes/toolbox'
import { systemRouter } from './routes/system'
// Custom types/enums
import { IRPCActionType } from '~/universal/types/enum'
// External utility functions
import { RPC_ACTIONS } from '#/events/constants'
class RPCServer implements IRPCServer {
private routes: IRPCRoutes = new Map()

View File

@ -1,6 +1,12 @@
import { IRPCActionType } from '~/universal/types/enum'
import { RPCRouter } from '../router'
import { deleteUploaderConfig, getUploaderConfigList, selectUploaderConfig, updateUploaderConfig, resetUploaderConfig } from '~/main/utils/handleUploaderConfig'
import {
deleteUploaderConfig,
getUploaderConfigList,
selectUploaderConfig,
updateUploaderConfig,
resetUploaderConfig
} from '~/main/utils/handleUploaderConfig'
const configRouter = new RPCRouter()

View File

@ -1,6 +1,11 @@
// External dependencies
import { app, clipboard, shell } from 'electron'
// Electron modules
// Custom utilities and modules
import { IRPCActionType } from '~/universal/types/enum'
import { RPCRouter } from '../router'
import { app, clipboard, shell } from 'electron'
const systemRouter = new RPCRouter()

View File

@ -1,9 +1,18 @@
// External dependencies
import fs from 'fs-extra'
import path from 'path'
// Electron modules
// Custom utilities and modules
import { dbPathChecker, defaultConfigPath } from '~/main/apis/core/datastore/dbChecker'
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
import { CLIPBOARD_IMAGE_FOLDER } from '~/universal/utils/static'
import { sendToolboxResWithType } from './utils'
// Custom types/enums
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
// External utility functions
import { CLIPBOARD_IMAGE_FOLDER } from '~/universal/utils/static'
import { T } from '~/main/i18n'
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD)

View File

@ -1,10 +1,19 @@
// External dependencies
import fs from 'fs-extra'
import path from 'path'
// Electron modules
import { IpcMainEvent } from 'electron'
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
import { sendToolboxResWithType } from './utils'
// Custom utilities and modules
import { dbPathChecker } from '~/main/apis/core/datastore/dbChecker'
import { GalleryDB, DB_PATH } from '~/main/apis/core/datastore'
import path from 'path'
import { sendToolboxResWithType } from './utils'
// Custom types/enums
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
// External utility functions
import { T } from '~/main/i18n'
export const checkFileMap: IToolboxCheckerMap<

View File

@ -1,10 +1,21 @@
// External dependencies
import fs from 'fs-extra'
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
import { sendToolboxResWithType } from './utils'
import tunnel from 'tunnel'
import { dbPathChecker } from '~/main/apis/core/datastore/dbChecker'
import { IConfig } from 'piclist'
import axios, { AxiosRequestConfig } from 'axios'
import tunnel from 'tunnel'
// Electron modules
// Custom utilities and modules
import { dbPathChecker } from '~/main/apis/core/datastore/dbChecker'
import { sendToolboxResWithType } from './utils'
// Custom types/enums
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
// External utility functions
// Custom types/enums
import { IConfig } from 'piclist'
import { T } from '~/main/i18n'
const getProxy = (proxyStr: string): AxiosRequestConfig['proxy'] | false => {

View File

@ -1,6 +1,11 @@
// External dependencies
import http from 'http'
import fs from 'fs-extra'
import path from 'path'
// Electron modules
// Custom utilities and modules
import picgo from '@core/picgo'
import logger from '../apis/core/picgo/logger'

View File

@ -1,7 +1,16 @@
// External dependencies
import yaml from 'js-yaml'
import { ObjectAdapter, I18n } from '@picgo/i18n'
import path from 'path'
import fs from 'fs-extra'
// Electron modules
// Custom utilities and modules
// Custom types/enums
// External utility functions
import { builtinI18nList } from '#/i18n'
class I18nManager {

View File

@ -493,7 +493,7 @@ class AliyunApi {
const res = client.signatureUrl(key, {
expires: expires || 3600
})
return customUrl ? `${customUrl.replace(/\/$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
}
/**

View File

@ -1,11 +1,11 @@
import TcyunApi from './tcyun'
import AliyunApi from './aliyun'
import QiniuApi from './qiniu'
import UpyunApi from './upyun'
import SmmsApi from './smms'
import GithubApi from './github'
import ImgurApi from './imgur'
import QiniuApi from './qiniu'
import S3plistApi from './s3plist'
import SmmsApi from './smms'
import TcyunApi from './tcyun'
import UpyunApi from './upyun'
import WebdavplistApi from './webdavplist'
export default {

View File

@ -35,12 +35,7 @@ class GithubApi {
}
formatFolder (item: any, slicedPrefix: string) {
let key = ''
if (slicedPrefix === '') {
key = `${item.path}/`
} else {
key = `${slicedPrefix}/${item.path}/`
}
const key = `${slicedPrefix ? `${slicedPrefix}/` : ''}${item.path}/`
return {
...item,
Key: key,
@ -57,27 +52,18 @@ class GithubApi {
formatFile (item: any, slicedPrefix: string, branch: string, repo: string, cdnUrl: string | undefined) {
let rawUrl = ''
if (cdnUrl) {
const placeholder = ['{username}', '{repo}', '{branch}', '{path}']
if (placeholder.some(item => cdnUrl.includes(item))) {
rawUrl = cdnUrl.replace('{username}', this.username)
.replace('{repo}', repo)
.replace('{branch}', branch)
.replace('{path}', `${slicedPrefix}/${item.path}`)
} else {
rawUrl = `${cdnUrl}/${slicedPrefix}/${item.path}`
}
} else {
rawUrl = `https://raw.githubusercontent.com/${this.username}/${repo}/${branch}/${slicedPrefix}/${item.path}`
}
const placeholders = ['{username}', '{repo}', '{branch}', '{path}']
const key = slicedPrefix === '' ? item.path : `${slicedPrefix}/${item.path}`
rawUrl = cdnUrl
? placeholders.some(item => cdnUrl.includes(item))
? placeholders.reduce((url, ph) => {
const value = ph === '{username}' ? this.username : ph === '{repo}' ? repo : ph === '{branch}' ? branch : ph === '{path}' ? `${slicedPrefix}/${item.path}` : ''
return url.replaceAll(ph, value)
}, cdnUrl)
: `${cdnUrl}/${key}`
: `https://raw.githubusercontent.com/${this.username}/${repo}/${branch}/${key}`
rawUrl = rawUrl.replace(/(?<!https?:)\/{2,}/g, '/')
let key = ''
if (slicedPrefix === '') {
key = item.path
} else {
key = `${slicedPrefix}/${item.path}`
}
const result = {
return {
...item,
Key: key,
key,
@ -88,12 +74,9 @@ class GithubApi {
checked: false,
match: false,
isImage: isImage(item.path),
rawUrl
rawUrl: item.url,
url: rawUrl
}
const temp = result.rawUrl
result.rawUrl = result.url
result.url = temp
return result
}
/**
@ -151,7 +134,7 @@ class GithubApi {
async getBucketListRecursively (configMap: IStringKeyMap): Promise<any> {
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
const { bucketName: repo, customUrl: branch, prefix, cancelToken, cdnUrl } = configMap
const slicedPrefix = prefix.replace(/^\//, '').replace(/\/$/, '')
const slicedPrefix = prefix.replace(/(^\/+|\/+$)/g, '')
const cancelTask = [false]
ipcMain.on(cancelDownloadLoadingFileList, (_evt: IpcMainEvent, token: string) => {
if (token === cancelToken) {
@ -202,7 +185,7 @@ class GithubApi {
async getBucketListBackstage (configMap: IStringKeyMap): Promise<any> {
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
const { bucketName: repo, customUrl: branch, prefix, cancelToken, cdnUrl } = configMap
const slicedPrefix = prefix.replace(/^\//, '').replace(/\/$/, '')
const slicedPrefix = prefix.replace(/(^\/+|\/+$)/g, '')
const cancelTask = [false]
ipcMain.on('cancelLoadingFileList', (_evt: IpcMainEvent, token: string) => {
if (token === cancelToken) {
@ -288,7 +271,7 @@ class GithubApi {
// TODO: if there are more than 10000 files in the folder, it will be truncated
// Rare cases, not considered for now
const treeRes = await got(
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${key.replace(/^\//, '').replace(/\/$/, '')}`,
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${key.replace(/(^\/+|\/+$)/g, '')}`,
getOptions('GET', this.commonHeaders, {
recursive: true
}, 'json', undefined, undefined, this.proxy)
@ -299,7 +282,7 @@ class GithubApi {
const oldTree = treeRes.body.tree
const newTree = oldTree.filter((item: any) => item.type === 'blob')
.map((item:any) => ({
path: `${key.replace(/^\//, '').replace(/\/$/, '')}/${item.path}`,
path: `${key.replace(/(^\/+|\/+$)/g, '')}/${item.path}`,
mode: item.mode,
type: item.type,
sha: null
@ -333,10 +316,7 @@ class GithubApi {
sha: commitSha
}), undefined, this.proxy)
) as any
if (updateRefRes.statusCode !== 200) {
return false
}
return true
return updateRefRes.statusCode === 200
}
/**
@ -352,20 +332,14 @@ class GithubApi {
*/
async getPreSignedUrl (configMap: IStringKeyMap): Promise<string> {
const { bucketName: repo, customUrl: branch, key, rawUrl, githubPrivate: isPrivate } = configMap
if (!isPrivate) {
return rawUrl
}
if (!isPrivate) return rawUrl
const res = await got(
`${this.baseUrl}/repos/${this.username}/${repo}/contents/${key}`,
getOptions('GET', this.commonHeaders, {
ref: branch
}, 'json', undefined, undefined, this.proxy)
) as any
if (res.statusCode === 200) {
return res.body.download_url
} else {
return ''
}
return res.statusCode === 200 ? res.body.download_url : ''
}
/**

View File

@ -1,17 +1,27 @@
import got from 'got'
import ManageLogger from '../utils/logger'
import { getAgent, getOptions, NewDownloader, gotUpload, getFileMimeType, ConcurrencyPromisePool, formatError } from '../utils/common'
import windowManager from 'apis/app/window/windowManager'
import { IWindowList } from '#/types/enum'
import { ipcMain, IpcMainEvent } from 'electron'
import { formatHttpProxy, isImage } from '~/renderer/manage/utils/common'
import path from 'path'
import UpDownTaskQueue,
{
commonTaskStatus
} from '../datastore/upDownTaskQueue'
import FormData from 'form-data'
// External dependencies
import fs from 'fs-extra'
import FormData from 'form-data'
import got from 'got'
import path from 'path'
// Electron modules
import { ipcMain, IpcMainEvent } from 'electron'
// Custom utilities and modules
import { IWindowList } from '#/types/enum'
import {
ConcurrencyPromisePool,
formatError,
getFileMimeType,
getOptions,
getAgent,
gotUpload,
NewDownloader
} from '../utils/common'
import ManageLogger from '../utils/logger'
import windowManager from 'apis/app/window/windowManager'
import { formatHttpProxy, isImage } from '~/renderer/manage/utils/common'
import UpDownTaskQueue, { commonTaskStatus } from '../datastore/upDownTaskQueue'
class ImgurApi {
userName: string
@ -35,17 +45,19 @@ class ImgurApi {
}
formatFile (item: any) {
const fileName = path.basename(item.link)
const isImg = isImage(fileName)
return {
...item,
Key: path.basename(item.link),
key: path.basename(item.link),
Key: fileName,
key: fileName,
fileName: `${item.name}${path.extname(item.link)}`,
formatedTime: new Date(item.datetime * 1000).toLocaleString(),
fileSize: item.size,
isDir: false,
checked: false,
match: false,
isImage: isImage(path.basename(item.link)),
isImage: isImg,
url: item.link,
sha: item.deletehash
}

View File

@ -410,7 +410,7 @@ class TcyunApi {
Sign: true
}, () => {
})
return customUrl ? `${customUrl.replace(/\/$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
}
/**

View File

@ -5,10 +5,19 @@
</template>
<script lang="ts" setup>
//
import { useStore } from '@/hooks/useStore'
// Vue
import { onBeforeMount, onMounted, onUnmounted } from 'vue'
//
import { getConfig } from './utils/dataSender'
//
import type { IConfig } from 'piclist'
//
import bus from './utils/bus'
import { FORCE_UPDATE } from '~/universal/events/constants'

View File

@ -24,7 +24,7 @@ export default class AliyunApi {
private static getKey (fileName: string, path?: string): string {
return path && path !== '/'
? `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
? `${path.replace(/^\/+|\/+$/, '')}/${fileName}`
: fileName
}

View File

@ -36,7 +36,7 @@ export default class AwsS3Api {
})
const result = await client.deleteObject({
Bucket: bucketName,
Key: fileKey.replace(/^\//, '')
Key: fileKey.replace(/^\/+/, '')
}).promise()
return result.$response.httpResponse.statusCode === 204
} catch (error) {

View File

@ -20,7 +20,7 @@ export default class GithubApi {
private static createKey (path: string | undefined, fileName: string): string {
return path && path !== '/'
? `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
? `${path.replace(/^\/+|\/+$/, '')}/${fileName}`
: fileName
}

View File

@ -17,7 +17,7 @@ export default class QiniuApi {
const qiniuConfig = new Qiniu.conf.Config()
try {
const bucketManager = new Qiniu.rs.BucketManager(mac, qiniuConfig)
const formattedPath = path?.replace(/^\//, '').replace(/\/$/, '') || ''
const formattedPath = path?.replace(/^\/+|\/+$/, '') || ''
const key = path === '/' || !path ? fileName : `${formattedPath}/${fileName}`
const res = await new Promise((resolve, reject) => {
bucketManager.delete(bucket, key, (err, respBody, respInfo) => {

View File

@ -27,7 +27,7 @@ export default class TcyunApi {
if (path === '/' || !path) {
key = `/${fileName}`
} else {
key = `/${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
key = `/${path.replace(/^\/+|\/+$/, '')}/${fileName}`
}
const result = await cos.deleteObject({
Bucket: bucket,

View File

@ -11,7 +11,7 @@ export default class UpyunApi {
if (path === '/' || !path) {
key = fileName
} else {
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
key = `${path.replace(/^\/+|\/+$/, '')}/${fileName}`
}
return await client.deleteFile(key)
} catch (error) {

View File

@ -16,7 +16,7 @@ export default class WebdavApi {
if (path === '/' || !path) {
key = fileName
} else {
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
key = `${path.replace(/^\/+|\/+$/, '')}/${fileName}`
}
try {
await ctx.deleteFile(key)

View File

@ -34,6 +34,8 @@ import {
} from '~/universal/events/constants'
import $bus from '@/utils/bus'
import { sendToMain } from '@/utils/dataSender'
import { T as $T } from '@/i18n/index'
const inputBoxValue = ref('')
const showInputBoxVisible = ref(false)
const inputBoxOptions = reactive({

View File

@ -10,6 +10,7 @@
</template>
<script lang="ts" setup>
import { IToolboxItemCheckStatus } from '~/universal/types/enum'
interface IProps {
status: IToolboxItemCheckStatus
value: any

View File

@ -18,6 +18,7 @@
import { CircleCloseFilled, Loading, SuccessFilled } from '@element-plus/icons-vue'
import { computed } from 'vue'
import { IToolboxItemCheckStatus } from '~/universal/types/enum'
interface IProps {
status: IToolboxItemCheckStatus
}

View File

@ -233,7 +233,7 @@
</div>
</template>
<script lang="ts" setup>
// import { Component, Vue, Watch } from 'vue-property-decorator'
// Element Plus
import {
Tools,
UploadFilled,
@ -248,20 +248,42 @@ import {
Link,
ArrowUpBold
} from '@element-plus/icons-vue'
// Element Plus
import { ElMessage as $message, ElMessageBox } from 'element-plus'
//
import { T as $T } from '@/i18n/index'
// Vue
import { ref, onBeforeUnmount, Ref, onBeforeMount, watch, nextTick, reactive } from 'vue'
// Vue Router
import { onBeforeRouteUpdate, useRouter } from 'vue-router'
//
import QrcodeVue from 'qrcode.vue'
// Lodash pick
import pick from 'lodash/pick'
// package.json
import pkg from 'root/package.json'
//
import * as config from '@/router/config'
// Electron
import {
ipcRenderer,
IpcRendererEvent,
clipboard
} from 'electron'
//
import InputBoxDialog from '@/components/InputBoxDialog.vue'
//
import {
MINIMIZE_WINDOW,
CLOSE_WINDOW,
@ -271,8 +293,13 @@ import {
GET_PICBEDS,
OPEN_URL
} from '~/universal/events/constants'
//
import { getConfig, sendToMain } from '@/utils/dataSender'
// Piclist
import { IConfig } from 'piclist'
const version = ref(process.env.NODE_ENV === 'production' ? pkg.version : 'Dev')
const routerConfig = reactive(config)
const defaultActive = ref(routerConfig.UPLOAD_PAGE)

View File

@ -1408,16 +1408,37 @@ https://www.baidu.com/img/bd_logo1.png"
</template>
<script lang="tsx" setup>
// Vue
import { ref, reactive, watch, onBeforeMount, computed, onBeforeUnmount } from 'vue'
// Vue Router
import { useRoute } from 'vue-router'
// Element Plus
import { InfoFilled, Grid, Fold, Close, Folder, FolderAdd, Upload, CircleClose, Loading, CopyDocument, Edit, DocumentAdd, Link, Refresh, ArrowRight, HomeFilled, Document, Coin, Download, DeleteFilled, Sort, FolderOpened } from '@element-plus/icons-vue'
//
import { useManageStore } from '../store/manageStore'
//
import { customRenameFormatTable, customStrMatch, customStrReplace, renameFile, formatLink, formatFileName, getFileIconPath, formatFileSize, getExtension, isValidUrl, svg } from '../utils/common'
//
import { cancelDownloadLoadingFileList, refreshDownloadFileTransferList } from '../utils/static'
// Electron
import { ipcRenderer, clipboard, IpcRendererEvent } from 'electron'
//
import { fileCacheDbInstance } from '../store/bucketFileDb'
//
import { trimPath } from '~/main/manage/utils/common'
// Axios
import axios from 'axios'
// Element Plus
import {
ElMessage, ElMessageBox, ElNotification,
ElButton,
@ -1434,19 +1455,42 @@ import {
ElTag,
ElCard
} from 'element-plus'
//
import type { Column, RowClassNameGetter } from 'element-plus'
//
import { useFileTransferStore, useDownloadFileTransferStore } from '@/manage/store/manageStore'
// UUID
import { v4 as uuidv4 } from 'uuid'
//
import path from 'path'
import { IUploadTask, IDownloadTask } from '~/main/manage/datastore/upDownTaskQueue'
//
import fs from 'fs-extra'
//
import { getConfig, saveConfig } from '../utils/dataSender'
// Markdown
import { marked } from 'marked'
//
import { textFileExt } from '../utils/textfile'
//
import { videoExt } from '../utils/videofile'
//
import ImageWebdav from '@/components/ImageWebdav.vue'
//
import { T as $T } from '@/i18n'
import { IUploadTask, IDownloadTask } from '~/main/manage/datastore/upDownTaskQueue'
/*
configMap:{
prefix: string, -> baseDir
@ -2408,7 +2452,7 @@ async function handleFolderBatchDownload (item: any) {
Location: configMap.bucketConfig.Location
},
paging: paging.value,
prefix: `/${item.key.replace(/\/+$/, '').replace(/^\/+/, '')}/`,
prefix: `/${item.key.replace(/^\/+|\/+$/, '')}/`,
marker: pagingMarker.value,
itemsPerPage: itemsPerPage.value,
customUrl: currentCustomUrl.value,
@ -2443,7 +2487,7 @@ async function handleFolderBatchDownload (item: any) {
bucketName: configMap.bucketName,
region: configMap.bucketConfig.Location,
key: item.key,
fileName: [undefined, true].includes(manageStore.config.settings.isDownloadFolderKeepDirStructure) ? `/${item.key.replace(/\/+$/, '').replace(/^\/+/, '')}` : item.fileName,
fileName: [undefined, true].includes(manageStore.config.settings.isDownloadFolderKeepDirStructure) ? `/${item.key.replace(/^\/+|\/+$/, '')}` : item.fileName,
customUrl: currentCustomUrl.value,
downloadUrl: item.downloadUrl,
githubUrl: item.url,
@ -2486,7 +2530,7 @@ async function handleBatchDownload () {
bucketName: configMap.bucketName,
region: configMap.bucketConfig.Location,
key: item.key,
fileName: manageStore.config.settings.isDownloadFileKeepDirStructure ? `/${item.key.replace(/\/+$/, '').replace(/^\/+/, '')}` : item.fileName,
fileName: manageStore.config.settings.isDownloadFileKeepDirStructure ? `/${item.key.replace(/^\/+|\/+$/, '')}` : item.fileName,
customUrl: currentCustomUrl.value,
downloadUrl: item.downloadUrl,
githubUrl: item.url,

View File

@ -258,17 +258,40 @@
</template>
<script lang="ts" setup>
// Vue
import { reactive, ref, onMounted, computed } from 'vue'
//
import { supportedPicBedList } from '../utils/constants'
// Element Plus
import { Delete, Edit, Pointer, InfoFilled } from '@element-plus/icons-vue'
// Element Plus
import { ElMessage, ElNotification } from 'element-plus'
//
import { getConfig, saveConfig, removeConfig } from '../utils/dataSender'
// Electron
import { shell } from 'electron'
// Vue Router
import { useRouter } from 'vue-router'
//
import { useManageStore } from '../store/manageStore'
//
import { formObjToTableData, svg } from '../utils/common'
//
import { getConfig as getPicBedsConfig } from '@/utils/dataSender'
//
import { formatEndpoint } from '~/main/manage/utils/common'
//
import { T as $T } from '@/i18n'
const activeName = ref('login')

View File

@ -273,15 +273,34 @@
</template>
<script lang="ts" setup>
// Vue
import { ref, reactive, computed, onBeforeMount, watch } from 'vue'
// Electron
import { shell } from 'electron'
//
import { supportedPicBedList } from '../utils/constants'
// Element Plus
import { CirclePlus, SuccessFilled, Folder, Switch, Tools, ChromeFilled, HomeFilled, FolderOpened } from '@element-plus/icons-vue'
// Vue Router
import { useRouter, useRoute } from 'vue-router'
// Element Plus
import { ElNotification } from 'element-plus'
//
import { invokeToMain } from '../utils/dataSender'
//
import { newBucketConfig } from '../utils/newBucketConfig'
//
import { useManageStore } from '../store/manageStore'
//
import { T as $T } from '@/i18n'
const manageStore = useManageStore() as any

View File

@ -513,14 +513,29 @@
</template>
<script lang="ts" setup>
// Element Plus
import { InfoFilled, Folder } from '@element-plus/icons-vue'
// Vue
import { ref, reactive, onBeforeMount, watch, onBeforeUnmount } from 'vue'
//
import { getConfig, saveConfig, invokeToMain } from '../utils/dataSender'
// Element Plus
import { ElMessage } from 'element-plus'
//
import { useManageStore } from '../store/manageStore'
import { fileCacheDbInstance } from '../store/bucketFileDb'
//
import { formatFileSize, customRenameFormatTable } from '../utils/common'
//
import { T as $T } from '@/i18n'
//
import { selectDownloadFolder } from '../utils/static'
const manageStore = useManageStore()

View File

@ -1,8 +1,19 @@
// UUID
import { v4 as uuidv4 } from 'uuid'
// 路径处理库
import path from 'path'
// 加密库
import crypto from 'crypto'
// 可用图标列表
import { availableIconList } from './icon'
// 数据发送工具函数
import { getConfig } from './dataSender'
// 工具函数
import { handleUrlEncode } from '~/universal/utils/common'
export function randomStringGenerator (length: number): string {

View File

@ -422,22 +422,46 @@
</div>
</template>
<script lang="ts" setup>
//
import type { IResult } from '@picgo/store/dist/types'
//
import { PASTE_TEXT, GET_PICBEDS } from '#/events/constants'
// Element Plus
import { CheckboxValueType, ElMessageBox, ElNotification, ElMessage } from 'element-plus'
// Element Plus
import { InfoFilled, Close, CaretBottom, Document, Edit, Delete, CaretTop, Sort } from '@element-plus/icons-vue'
// Electron
import {
ipcRenderer,
clipboard,
IpcRendererEvent
} from 'electron'
// Vue
import { computed, nextTick, onActivated, onBeforeUnmount, onBeforeMount, reactive, ref, watch } from 'vue'
//
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
// Vue Router
import { onBeforeRouteUpdate } from 'vue-router'
//
import { T as $T } from '@/i18n/index'
//
import $$db from '@/utils/db'
// API
import ALLApi from '@/apis/allApi'
//
import { customRenameFormatTable, customStrMatch, customStrReplace } from '../manage/utils/common'
const images = ref<ImgInfo[]>([])
const dialogVisible = ref(false)
const imgInfo = reactive({

View File

@ -30,21 +30,38 @@
</div>
</template>
<script lang="ts" setup>
//
import { T as $T } from '@/i18n/index'
// Element Plus
import { ElMessage as $message } from 'element-plus'
// Electron
import {
ipcRenderer,
IpcRendererEvent
} from 'electron'
// Vue
import { onBeforeUnmount, onBeforeMount, ref, watch, reactive } from 'vue'
//
import { SHOW_MINI_PAGE_MENU, SET_MINI_WINDOW_POS } from '~/universal/events/constants'
//
import {
isUrl
} from '~/universal/utils/common'
//
import { getConfig, sendToMain } from '@/utils/dataSender'
// Piclist
import { IConfig } from 'piclist'
//
import { invokeToMain } from '@/manage/utils/dataSender'
const logoPath = reactive({
value: ''
})

View File

@ -1470,23 +1470,49 @@
<script lang="ts" setup>
// @ts-ignore
import { ElForm, ElMessage as $message, ElMessage, ElMessageBox, FormRules } from 'element-plus'
// Element Plus
import { Reading, Close, Edit, InfoFilled } from '@element-plus/icons-vue'
// package.json
import pkg from 'root/package.json'
//
import { PICGO_OPEN_FILE, OPEN_URL, GET_PICBEDS, HIDE_DOCK } from '#/events/constants'
// Electron
import {
ipcRenderer
} from 'electron'
//
import { i18nManager, T as $T } from '@/i18n/index'
//
import { enforceNumber } from '~/universal/utils/common'
import { getLatestVersion } from '#/utils/getLatestVersion'
import { compare } from 'compare-versions'
import { STABLE_RELEASE_URL } from '#/utils/static'
// Vue
import { computed, onBeforeMount, onBeforeUnmount, reactive, ref, toRaw } from 'vue'
//
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
// Vue Router
import { useRouter } from 'vue-router'
//
import { SHORTKEY_PAGE } from '@/router/config'
// Piclist
import { IConfig, IBuildInCompressOptions, IBuildInWaterMarkOptions } from 'piclist'
//
import { invokeToMain } from '@/manage/utils/dataSender'
//
import { buildInRenameFormatTable } from '../manage/utils/common'
const imageProcessDialogVisible = ref(false)

View File

@ -200,15 +200,28 @@
</div>
</template>
<script lang="ts" setup>
// Element Plus
import { Close, Download, Goods, Remove, Tools } from '@element-plus/icons-vue'
//
import { T as $T } from '@/i18n/index'
//
import ConfigForm from '@/components/ConfigFormForPlugin.vue'
// Lodash
import { debounce, DebouncedFunc } from 'lodash'
// Electron
import {
ipcRenderer,
IpcRendererEvent
} from 'electron'
//
import { handleStreamlinePluginName } from '~/universal/utils/common'
//
import {
OPEN_URL,
PICGO_CONFIG_PLUGIN,
@ -218,10 +231,20 @@ import {
GET_PICBEDS,
PICGO_HANDLE_PLUGIN_DONE
} from '#/events/constants'
// Vue
import { computed, ref, onBeforeMount, onBeforeUnmount, watch, onMounted } from 'vue'
//
import { getConfig, saveConfig, sendRPC, sendToMain } from '@/utils/dataSender'
// Element Plus
import { ElMessageBox } from 'element-plus'
// Axios
import axios from 'axios'
//
import { IRPCActionType } from '~/universal/types/enum'
const $confirm = ElMessageBox.confirm

View File

@ -52,16 +52,28 @@
</div>
</template>
<script lang="ts" setup>
// Element Plus
import { Close } from '@element-plus/icons-vue'
//
import { GET_RENAME_FILE_NAME, RENAME_FILE_NAME } from '#/events/constants'
//
import { sendToMain } from '@/utils/dataSender'
//
import { T as $T } from '@/i18n/index'
import {
ipcRenderer,
IpcRendererEvent
} from 'electron'
// Electron
import { ipcRenderer, IpcRendererEvent } from 'electron'
// Vue
import { onBeforeUnmount, onBeforeMount, ref, reactive } from 'vue'
//
import { useIPCOn } from '@/hooks/useIPC'
// Element Plus
import { FormInstance } from 'element-plus'
const id = ref<string | null>(null)

View File

@ -114,11 +114,22 @@
</div>
</template>
<script lang="ts" setup>
//
import keyBinding from '@/utils/key-binding'
// Electron
import { ipcRenderer, IpcRendererEvent } from 'electron'
//
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
// Vue
import { onBeforeUnmount, onBeforeMount, ref, watch } from 'vue'
//
import { getConfig, sendToMain } from '@/utils/dataSender'
//
import { T as $T } from '@/i18n'
const list = ref<IShortKeyConfig[]>([])

View File

@ -95,12 +95,25 @@
</div>
</template>
<script lang="ts" setup>
//
import { useIPC } from '@/hooks/useIPC'
//
import { sendRPC, triggerRPC } from '@/utils/dataSender'
// Element Plus
import { ElMessageBox } from 'element-plus'
// Vue
import { computed, reactive, ref } from 'vue'
//
import { IToolboxItemType, IToolboxItemCheckStatus, IRPCActionType } from '~/universal/types/enum'
//
import { T as $T } from '@/i18n'
//
import ToolboxStatusIcon from '@/components/ToolboxStatusIcon.vue'
import ToolboxHandler from '@/components/ToolboxHandler.vue'

View File

@ -62,14 +62,31 @@
</template>
<script lang="ts" setup>
// Vue
import { reactive, ref, onBeforeUnmount, onBeforeMount } from 'vue'
// Electron
import { clipboard, ipcRenderer } from 'electron'
//
import $$db from '@/utils/db'
//
import { T as $T } from '@/i18n/index'
// Picgo Store
import { IResult } from '@picgo/store/dist/types'
//
import { OPEN_WINDOW } from '#/events/constants'
//
import { IPasteStyle, IWindowList } from '#/types/enum'
//
import { getConfig, sendToMain } from '@/utils/dataSender'
//
import { handleUrlEncode } from '#/utils/common'
const files = ref<IResult<ImgInfo>[]>([])

View File

@ -399,28 +399,49 @@
</div>
</template>
<script lang="ts" setup>
// Element Plus
import { UploadFilled, CaretBottom } from '@element-plus/icons-vue'
import {
ipcRenderer,
IpcRendererEvent
} from 'electron'
// Electron
import { ipcRenderer, IpcRendererEvent } from 'electron'
// Vue
import { ref, reactive, onBeforeMount, onBeforeUnmount, watch, toRaw } from 'vue'
//
import { T as $T } from '@/i18n'
// 线
import $bus from '@/utils/bus'
//
import {
SHOW_INPUT_BOX,
SHOW_INPUT_BOX_RESPONSE,
SHOW_UPLOAD_PAGE_MENU,
GET_PICBEDS
} from '~/universal/events/constants'
//
import {
isUrl
} from '~/universal/utils/common'
// Element Plus
import { ElMessage as $message } from 'element-plus'
//
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
//
import { IBuildInCompressOptions, IBuildInWaterMarkOptions } from 'piclist'
// Vue Router
import { useRouter } from 'vue-router'
//
import { PICBEDS_PAGE } from '@/router/config'
const $router = useRouter()
const imageProcessDialogVisible = ref(false)

View File

@ -92,15 +92,33 @@
</div>
</template>
<script lang="ts" setup>
// Element Plus
import { Edit, Delete, Plus } from '@element-plus/icons-vue'
//
import { saveConfig, triggerRPC } from '@/utils/dataSender'
//
import dayjs from 'dayjs'
//
import { IRPCActionType } from '~/universal/types/enum'
//
import { T as $T } from '@/i18n/index'
// Vue Router
import { useRouter, useRoute, onBeforeRouteUpdate } from 'vue-router'
// Vue
import { onBeforeMount, ref } from 'vue'
//
import { PICBEDS_PAGE, UPLOADER_CONFIG_PAGE } from '@/router/config'
//
import { useStore } from '@/hooks/useStore'
const $router = useRouter()
const $route = useRoute()

View File

@ -85,20 +85,40 @@
</div>
</template>
<script lang="ts" setup>
//
import { IRPCActionType } from '~/universal/types/enum'
// Vue
import { ref, onBeforeUnmount, onBeforeMount } from 'vue'
//
import { T as $T } from '@/i18n/index'
//
import { sendToMain, triggerRPC } from '@/utils/dataSender'
// Vue Router
import { useRoute, useRouter } from 'vue-router'
//
import ConfigForm from '@/components/ConfigForm.vue'
// import mixin from '@/utils/ConfirmButtonMixin'
// Electron
import {
ipcRenderer,
IpcRendererEvent
} from 'electron'
//
import { OPEN_URL } from '~/universal/events/constants'
// Element Plus
import { Link } from '@element-plus/icons-vue'
//
import dayjs from 'dayjs'
// Element Plus
import { ElDropdown } from 'element-plus'
const type = ref('')

View File

@ -1,17 +1,17 @@
export const GALLERY_PAGE = 'GalleryPage'
export const TRAY_PAGE = 'TrayPage'
export const RENAME_PAGE = 'RenamePage'
export const MINI_PAGE = 'MiniPage'
export const MAIN_PAGE = 'MainPage'
export const UPLOAD_PAGE = 'UploadPage'
export const PICBEDS_PAGE = 'PicbedsPage'
export const SETTING_PAGE = 'SettingPage'
export const PLUGIN_PAGE = 'PluginPage'
export const SHORTKEY_PAGE = 'ShortkeyPage'
export const UPLOADER_CONFIG_PAGE = 'UploaderConfigPage'
export const MANAGE_MAIN_PAGE = 'ManageMainPage'
export const MANAGE_LOGIN_PAGE = 'ManageLoginPage'
export const MANAGE_SETTING_PAGE = 'ManageSettingPage'
export const MANAGE_EMPTY_PAGE = 'ManageEmptyPage'
export const MANAGE_BUCKET_PAGE = 'ManageBucketPage'
export const MANAGE_EMPTY_PAGE = 'ManageEmptyPage'
export const MANAGE_LOGIN_PAGE = 'ManageLoginPage'
export const MANAGE_MAIN_PAGE = 'ManageMainPage'
export const MANAGE_SETTING_PAGE = 'ManageSettingPage'
export const MAIN_PAGE = 'MainPage'
export const MINI_PAGE = 'MiniPage'
export const PICBEDS_PAGE = 'PicbedsPage'
export const PLUGIN_PAGE = 'PluginPage'
export const RENAME_PAGE = 'RenamePage'
export const SETTING_PAGE = 'SettingPage'
export const SHORTKEY_PAGE = 'ShortkeyPage'
export const TOOLBOX_CONFIG_PAGE = 'ToolBoxPage'
export const TRAY_PAGE = 'TrayPage'
export const UPLOAD_PAGE = 'UploadPage'
export const UPLOADER_CONFIG_PAGE = 'UploaderConfigPage'

View File

@ -1,7 +1,16 @@
// Electron 相关
import { ipcRenderer, IpcRendererEvent } from 'electron'
// 事件常量
import { PICGO_SAVE_CONFIG, PICGO_GET_CONFIG, RPC_ACTIONS } from '#/events/constants'
// UUID
import { v4 as uuid } from 'uuid'
// 枚举类型声明
import { IRPCActionType } from '~/universal/types/enum'
// 公共工具函数
import { getRawData } from './common'
export function saveConfig (config: IObj | string, value?: any) {

View File

@ -1,6 +1,13 @@
// Picgo Store 相关类型
import { IObject, IResult, IGetResult, IFilter } from '@picgo/store/dist/types'
// Electron 相关
import { ipcRenderer, IpcRendererEvent } from 'electron'
// UUID
import { v4 as uuid } from 'uuid'
// 数据库操作常量
import {
PICGO_GET_DB,
PICGO_INSERT_DB,
@ -9,8 +16,13 @@ import {
PICGO_GET_BY_ID_DB,
PICGO_REMOVE_BY_ID_DB
} from '#/events/constants'
// 数据库类型声明
import { IGalleryDB } from '#/types/extra-vue'
// 公共工具函数
import { getRawData } from './common'
export class GalleryDB implements IGalleryDB {
async get<T> (filter?: IFilter): Promise<IGetResult<T>> {
const res = await this.msgHandler<IGetResult<T>>(PICGO_GET_DB, filter)

View File

@ -1,7 +1,15 @@
// Vue 组件选项
import { ComponentOptions } from 'vue'
// 事件常量
import { FORCE_UPDATE, GET_PICBEDS } from '~/universal/events/constants'
// 事件总线
import bus from '~/renderer/utils/bus'
// Electron 相关
import { ipcRenderer } from 'electron'
export const mainMixin: ComponentOptions = {
inject: ['forceUpdateTime'],

View File

@ -1,4 +1,5 @@
import { ComponentOptions } from 'vue'
export const dragMixin: ComponentOptions = {
mounted () {
this.disableDragEvent()

View File

@ -1,4 +1,5 @@
import { C1N } from '../events/constants'
export const CLIPBOARD_IMAGE_FOLDER = 'piclist-clipboard-images'
export const RELEASE_URL = 'https://api.github.com/repos/Kuingsmile/PicList/releases'
export const RELEASE_URL_BACKUP = 'https://release.piclist.cn'