Feature(custom): rewrite setting page, WIP

This commit is contained in:
Kuingsmile
2025-08-06 11:19:19 +08:00
parent 32c3eaba12
commit 4b8bfded1d
182 changed files with 5536 additions and 3322 deletions

View File

@@ -2,12 +2,11 @@ import crypto from 'node:crypto'
import picgo from '@core/picgo'
import { configPaths } from '#/utils/configPaths'
import { DEFAULT_AES_PASSWORD } from '#/utils/static'
import { configPaths } from '~/utils/configPaths'
export class AESHelper {
private key: Buffer = crypto.pbkdf2Sync(
picgo.getConfig<string>(configPaths.settings.aesPassword) || DEFAULT_AES_PASSWORD,
picgo.getConfig<string>(configPaths.settings.aesPassword) || 'aesPassword',
Buffer.from('a8b3c4d2e4f5098712345678feedc0de', 'hex'),
100000,
32,

View File

@@ -5,7 +5,7 @@ import { dbPathChecker } from '@core/datastore/dbChecker'
import fs from 'fs-extra'
import yaml from 'js-yaml'
import { ILocales } from '#/types/i18n'
import type { ILocales } from '#/types/i18n'
import { i18nManager } from '~/i18n'
const configPath = dbPathChecker()

View File

@@ -6,11 +6,28 @@ import axios from 'axios'
import { clipboard, dialog, Notification, Tray } from 'electron'
import FormData from 'form-data'
import fs from 'fs-extra'
import { isReactive, isRef, toRaw, unref } from 'vue'
import { IShortUrlServer } from '#/types/enum'
import { IPrivateShowNotificationOption, IShowMessageBoxResult } from '#/types/types'
import { handleUrlEncode } from '#/utils/common'
import { configPaths } from '#/utils/configPaths'
import type { IHTTPProxy, IPrivateShowNotificationOption, IShowMessageBoxResult, IStringKeyMap } from '#/types/types'
import { configPaths } from '~/utils/configPaths'
import { IShortUrlServer } from '~/utils/enum'
/**
* get raw data from reactive or ref
*/
export const getRawData = (args: any): any => {
if (isRef(args)) return unref(args)
if (isReactive(args)) return toRaw(args)
if (Array.isArray(args)) return args.map(getRawData)
if (typeof args === 'object' && args !== null) {
const data = {} as Record<string, any>
for (const key in args) {
data[key] = getRawData(args[key])
}
return data
}
return args
}
const getExtension = (fileName: string) => path.extname(fileName).slice(1)
@@ -123,9 +140,6 @@ export const getClipboardFilePath = (): string => {
return ''
}
export const handleUrlEncodeWithSetting = (url: string) =>
db.get(configPaths.settings.encodeOutputURL) ? handleUrlEncode(url) : url
const c1nApi = 'https://c1n.cn/link/short'
const generateC1NShortUrl = async (url: string) => {
@@ -246,3 +260,76 @@ export const generateShortUrl = async (url: string) => {
return url
}
}
export const isUrl = (url: string): boolean => {
try {
return Boolean(new URL(url))
} catch {
return false
}
}
export const isUrlEncode = (url: string): boolean => {
url = url || ''
try {
return url !== decodeURI(url)
} catch {
return false
}
}
export const handleUrlEncode = (url: string): string => (isUrlEncode(url) ? url : encodeURI(url))
export const handleUrlEncodeWithSetting = (url: string) =>
db.get(configPaths.settings.encodeOutputURL) ? handleUrlEncode(url) : url
export const handleStreamlinePluginName = (name: string) => name.replace(/(@[^/]+\/)?picgo-plugin-/, '')
export const simpleClone = (obj: any) => JSON.parse(JSON.stringify(obj))
export const enforceNumber = (num: number | string) => (isNaN(+num) ? 0 : +num)
export const trimValues = <T extends IStringKeyMap>(
obj: T
): { [K in keyof T]: T[K] extends string ? string : T[K] } => {
return Object.fromEntries(
Object.entries(obj).map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value])
) as { [K in keyof T]: T[K] extends string ? string : T[K] }
}
export const formatEndpoint = (endpoint: string, sslEnabled: boolean): string => {
const hasProtocol = /^https?:\/\//.test(endpoint)
if (!hasProtocol) {
return `${sslEnabled ? 'https' : 'http'}://${endpoint}`
}
return sslEnabled ? endpoint.replace(/^http:\/\//, 'https://') : endpoint.replace(/^https:\/\//, 'http://')
}
export const formatHttpProxy = (
proxy: string | undefined,
type: 'object' | 'string'
): IHTTPProxy | undefined | string => {
if (!proxy) return undefined
if (/^https?:\/\//.test(proxy)) {
const { protocol, hostname, port } = new URL(proxy)
return type === 'string'
? `${protocol}//${hostname}:${port}`
: {
host: hostname,
port: Number(port),
protocol: protocol.slice(0, -1)
}
}
const [host, port] = proxy.split(':')
return type === 'string'
? `http://${host}:${port}`
: {
host,
port: port ? Number(port) : 80,
protocol: 'http'
}
}
export function encodeFilePath (filePath: string) {
return filePath.replace(/\\/g, '/').split('/').map(encodeURIComponent).join('/')
}
export const trimPath = (path: string) => path.replace(/^\/+|\/+$/g, '').replace(/\/+/g, '/')

View File

@@ -0,0 +1,188 @@
import type { IBuildInCompressOptions, IBuildInWaterMarkOptions } from 'piclist'
import type { IAliYunConfig, IAwsS3PListUserConfig, IGitHubConfig, IImgurConfig, ILocalConfig, ILskyConfig, IPicBedType, IQiniuConfig, IServerConfig, ISftpPlistConfig, IShortKeyConfig, ISMMSConfig, ISyncConfig, ITcYunConfig, IUploaderConfig, IUpYunConfig, IWebdavPlistConfig } from '#/types/types'
export type manualPageOpenType = 'window' | 'browser'
interface IPicGoPlugins {
[key: `picgo-plugin-${string}`]: boolean
}
export interface IConfigStruct {
picBed: {
uploader: string
current?: string
smms?: ISMMSConfig
qiniu?: IQiniuConfig
upyun?: IUpYunConfig
tcyun?: ITcYunConfig
github?: IGitHubConfig
aliyun?: IAliYunConfig
imgur?: IImgurConfig
webdavplist?: IWebdavPlistConfig
local?: ILocalConfig
sftpplist?: ISftpPlistConfig
lskyplist?: ILskyConfig
'aws-s3-plist': IAwsS3PListUserConfig
proxy?: string
transformer?: string
list: IPicBedType[]
[others: string]: any
}
settings: {
shortKey: {
[key: string]: IShortKeyConfig
}
logLevel: string[]
logPath: string
logFileSizeLimit: number
isAutoListenClipboard: boolean
isListeningClipboard: boolean
showUpdateTip: boolean
miniWindowPosition: [number, number]
miniWindowOntop: boolean
mainWindowWidth: number
mainWindowHeight: number
isHideDock: boolean
autoCloseMiniWindow: boolean
autoCloseMainWindow: boolean
isCustomMiniIcon: boolean
customMiniIcon: string
startMode: string
autoRename: boolean
deleteCloudFile: boolean
server: IServerConfig
serverKey: string
pasteStyle: string
aesPassword: string
rename: boolean
sync: ISyncConfig
tempDirPath: string
language: string
customLink: string
manualPageOpen: manualPageOpenType
encodeOutputURL: boolean
useShortUrl: boolean
shortUrlServer: string
c1nToken: string
cfWorkerHost: string
yourlsDomain: string
yourlsSignature: string
sinkDomain: string
sinkToken: string
isSilentNotice: boolean
proxy: string
registry: string
autoCopy: boolean
enableWebServer: boolean
webServerHost: string
webServerPort: number
webServerPath: string
deleteLocalFile: boolean
uploadResultNotification: boolean
uploadNotification: boolean
useBuiltinClipboard: boolean
autoStart: boolean
autoImport: boolean
autoImportPicBed: string[]
}
needReload: boolean
picgoPlugins: IPicGoPlugins
uploader: IUploaderConfig
buildIn: {
compress: IBuildInCompressOptions
watermark: IBuildInWaterMarkOptions
rename: {
enable: boolean
format: string
}
skipProcess: {
skipProcessExtList: string
}
}
debug: boolean
PICGO_ENV: string
}
export const configPaths = {
picBed: {
current: 'picBed.current',
uploader: 'picBed.uploader',
secondUploader: 'picBed.secondUploader',
secondUploaderId: 'picBed.secondUploaderId',
secondUploaderConfig: 'picBed.secondUploaderConfig',
proxy: 'picBed.proxy',
transformer: 'picBed.transformer',
list: 'picBed.list'
},
settings: {
shortKey: {
_path: 'settings.shortKey',
'picgo:upload': 'settings.shortKey[picgo:upload]'
},
logLevel: 'settings.logLevel',
logPath: 'settings.logPath',
logFileSizeLimit: 'settings.logFileSizeLimit',
isAutoListenClipboard: 'settings.isAutoListenClipboard',
isListeningClipboard: 'settings.isListeningClipboard',
showUpdateTip: 'settings.showUpdateTip',
miniWindowPosition: 'settings.miniWindowPosition',
miniWindowOntop: 'settings.miniWindowOntop',
isHideDock: 'settings.isHideDock',
mainWindowWidth: 'settings.mainWindowWidth',
mainWindowHeight: 'settings.mainWindowHeight',
autoCloseMiniWindow: 'settings.autoCloseMiniWindow',
autoCloseMainWindow: 'settings.autoCloseMainWindow',
isCustomMiniIcon: 'settings.isCustomMiniIcon',
customMiniIcon: 'settings.customMiniIcon',
startMode: 'settings.startMode',
autoRename: 'settings.autoRename',
deleteCloudFile: 'settings.deleteCloudFile',
server: 'settings.server',
serverKey: 'settings.serverKey',
pasteStyle: 'settings.pasteStyle',
aesPassword: 'settings.aesPassword',
rename: 'settings.rename',
sync: 'settings.sync',
tempDirPath: 'settings.tempDirPath',
language: 'settings.language',
customLink: 'settings.customLink',
manualPageOpen: 'settings.manualPageOpen',
encodeOutputURL: 'settings.encodeOutputURL',
useShortUrl: 'settings.useShortUrl',
shortUrlServer: 'settings.shortUrlServer',
c1nToken: 'settings.c1nToken',
cfWorkerHost: 'settings.cfWorkerHost',
yourlsDomain: 'settings.yourlsDomain',
yourlsSignature: 'settings.yourlsSignature',
sinkDomain: 'settings.sinkDomain',
sinkToken: 'settings.sinkToken',
isSilentNotice: 'settings.isSilentNotice',
proxy: 'settings.proxy',
registry: 'settings.registry',
autoCopy: 'settings.autoCopy',
enableWebServer: 'settings.enableWebServer',
webServerHost: 'settings.webServerHost',
webServerPort: 'settings.webServerPort',
webServerPath: 'settings.webServerPath',
deleteLocalFile: 'settings.deleteLocalFile',
uploadResultNotification: 'settings.uploadResultNotification',
uploadNotification: 'settings.uploadNotification',
useBuiltinClipboard: 'settings.useBuiltinClipboard',
autoStart: 'settings.autoStart',
autoImport: 'settings.autoImport',
autoImportPicBed: 'settings.autoImportPicBed',
enableSecondUploader: 'settings.enableSecondUploader'
},
needReload: 'needReload',
picgoPlugins: 'picgoPlugins',
uploader: 'uploader',
buildIn: {
compress: 'buildIn.compress',
watermark: 'buildIn.watermark',
rename: 'buildIn.rename',
skipProcess: 'buildIn.skipProcess'
},
debug: 'debug',
PICGO_ENV: 'PICGO_ENV'
}

View File

@@ -9,7 +9,7 @@ import { NodeHttpHandler } from '@smithy/node-http-handler'
import axios from 'axios'
import { ISftpPlistConfig } from 'piclist'
import { IObj, IStringKeyMap } from '#/types/types'
import type { IObj, IStringKeyMap } from '#/types/types'
import { getAgent } from '~/manage/utils/common'
import SSHClient from '~/utils/sshClient'

View File

@@ -2,7 +2,8 @@ import crypto from 'node:crypto'
import axios from 'axios'
import { IStringKeyMap } from '#/types/types'
import type { IStringKeyMap } from '#/types/types'
const AUTH_KEY_VALUE_RE = /(\w+)=["']?([^'"]{1,10000})["']?/
let NC = 0
const NC_PAD = '00000000'

242
src/main/utils/enum.ts Normal file
View File

@@ -0,0 +1,242 @@
export const ILogType = {
success: 'success',
info: 'info',
warn: 'warn',
error: 'error'
}
export const ICOREBuildInEvent = {
UPLOAD_PROGRESS: 'uploadProgress',
FAILED: 'failed',
BEFORE_TRANSFORM: 'beforeTransform',
BEFORE_UPLOAD: 'beforeUpload',
AFTER_UPLOAD: 'afterUpload',
FINISHED: 'finished',
INSTALL: 'install',
UNINSTALL: 'uninstall',
UPDATE: 'update',
NOTIFICATION: 'notification',
REMOVE: 'remove'
}
export const IPicGoHelperType = {
afterUploadPlugins: 'afterUploadPlugins',
beforeTransformPlugins: 'beforeTransformPlugins',
beforeUploadPlugins: 'beforeUploadPlugins',
uploader: 'uploader',
transformer: 'transformer'
}
export const IPasteStyle = {
MARKDOWN: 'markdown',
HTML: 'HTML',
URL: 'URL',
UBB: 'UBB',
CUSTOM: 'Custom'
}
export const IWindowList = {
SETTING_WINDOW: 'SETTING_WINDOW',
TRAY_WINDOW: 'TRAY_WINDOW',
MINI_WINDOW: 'MINI_WINDOW',
RENAME_WINDOW: 'RENAME_WINDOW',
TOOLBOX_WINDOW: 'TOOLBOX_WINDOW'
}
export const IRemoteNoticeActionType = {
OPEN_URL: 'OPEN_URL',
SHOW_NOTICE: 'SHOW_NOTICE', // notification
SHOW_DIALOG: 'SHOW_DIALOG', // dialog notice
COMMON: 'COMMON',
VOID: 'VOID', // do nothing
SHOW_MESSAGE_BOX: 'SHOW_MESSAGE_BOX'
}
export const IRemoteNoticeTriggerHook = {
APP_START: 'APP_START',
SETTING_WINDOW_OPEN: 'SETTING_WINDOW_OPEN'
}
export const IRemoteNoticeTriggerCount = {
ONCE: 'ONCE', // default
ALWAYS: 'ALWAYS'
}
export const IRPCType = {
INVOKE: 'INVOKE',
SEND: 'SEND'
}
export const IRPCActionType = {
// system rpc
RELOAD_APP: 'RELOAD_APP',
OPEN_URL: 'OPEN_URL',
OPEN_FILE: 'OPEN_FILE',
HIDE_DOCK: 'HIDE_DOCK',
SET_CURRENT_LANGUAGE: 'SET_CURRENT_LANGUAGE',
OPEN_WINDOW: 'OPEN_WINDOW',
OPEN_MINI_WINDOW: 'OPEN_MINI_WINDOW',
CLOSE_WINDOW: 'CLOSE_WINDOW',
MINIMIZE_WINDOW: 'MINIMIZE_WINDOW',
SHOW_MINI_PAGE_MENU: 'SHOW_MINI_PAGE_MENU',
SHOW_MAIN_PAGE_MENU: 'SHOW_MAIN_PAGE_MENU',
SHOW_UPLOAD_PAGE_MENU: 'SHOW_UPLOAD_PAGE_MENU',
SHOW_SECOND_UPLOADER_MENU: 'SHOW_SECOND_UPLOADER_MENU',
SHOW_PLUGIN_PAGE_MENU: 'SHOW_PLUGIN_PAGE_MENU',
SET_MINI_WINDOW_POS: 'SET_MINI_WINDOW_POS',
MINI_WINDOW_ON_TOP: 'MINI_WINDOW_ON_TOP',
MAIN_WINDOW_ON_TOP: 'MAIN_WINDOW_ON_TOP',
UPDATE_MINI_WINDOW_ICON: 'UPDATE_MINI_WINDOW_ICON',
REFRESH_SETTING_WINDOW: 'REFRESH_SETTING_WINDOW',
// picbed RPC
PICBED_GET_PICBED_CONFIG: 'PICBED_GET_PICBED_CONFIG',
PICBED_GET_CONFIG_LIST: 'PICBED_GET_CONFIG_LIST',
PICBED_DELETE_CONFIG: 'PICBED_DELETE_CONFIG',
UPLOADER_CHANGE_CURRENT: 'UPLOADER_CHANGE_CURRENT',
UPLOADER_SELECT: 'UPLOADER_SELECT',
UPLOADER_UPDATE_CONFIG: 'UPLOADER_UPDATE_CONFIG',
UPLOADER_RESET_CONFIG: 'UPLOADER_RESET_CONFIG',
DELETE_ALL_API: 'DELETE_ALL_API',
// toolbox rpc
TOOLBOX_CHECK: 'TOOLBOX_CHECK',
TOOLBOX_CHECK_RES: 'TOOLBOX_CHECK_RES',
TOOLBOX_CHECK_FIX: 'TOOLBOX_CHECK_FIX',
// main app setting rpc
PICLIST_GET_CONFIG: 'PICLIST_GET_CONFIG',
PICLIST_GET_CONFIG_SYNC: 'PICLIST_GET_CONFIG_SYNC',
PICLIST_SAVE_CONFIG: 'PICLIST_SAVE_CONFIG',
PICLIST_OPEN_FILE: 'PICLIST_OPEN_FILE',
PICLIST_OPEN_DIRECTORY: 'PICLIST_OPEN_DIRECTORY',
PICLIST_AUTO_START: 'PICLIST_AUTO_START',
// shortkey setting rpc
SHORTKEY_UPDATE: 'SHORTKEY_UPDATE',
SHORTKEY_BIND_OR_UNBIND: 'SHORTKEY_BIND_OR_UNBIND',
SHORTKEY_TOGGLE_SHORTKEY_MODIFIED_MODE: 'SHORTKEY_TOGGLE_SHORTKEY_MODIFIED_MODE',
// configuration setting rpc
CONFIGURE_MIGRATE_FROM_PICGO: 'CONFIGURE_MIGRATE_FROM_PICGO',
CONFIGURE_UPLOAD_COMMON_CONFIG: 'CONFIGURE_UPLOAD_COMMON_CONFIG',
CONFIGURE_UPLOAD_MANAGE_CONFIG: 'CONFIGURE_UPLOAD_MANAGE_CONFIG',
CONFIGURE_UPLOAD_ALL_CONFIG: 'CONFIGURE_UPLOAD_ALL_CONFIG',
CONFIGURE_DOWNLOAD_COMMON_CONFIG: 'CONFIGURE_DOWNLOAD_COMMON_CONFIG',
CONFIGURE_DOWNLOAD_MANAGE_CONFIG: 'CONFIGURE_DOWNLOAD_MANAGE_CONFIG',
CONFIGURE_DOWNLOAD_ALL_CONFIG: 'CONFIGURE_DOWNLOAD_ALL_CONFIG',
// advanced setting rpc
ADVANCED_UPDATE_SERVER: 'ADVANCED_UPDATE_SERVER',
ADVANCED_STOP_WEB_SERVER: 'ADVANCED_STOP_WEB_SERVER',
ADVANCED_RESTART_WEB_SERVER: 'ADVANCED_RESTART_WEB_SERVER',
// upload and main page rpc
MAIN_GET_PICBED: 'MAIN_GET_PICBED',
UPLOAD_CLIPBOARD_FILES_FROM_UPLOAD_PAGE: 'UPLOAD_CLIPBOARD_FILES_FROM_UPLOAD_PAGE',
UPLOAD_CHOOSED_FILES: 'UPLOAD_CHOOSED_FILES',
// gallery rpc
GALLERY_PASTE_TEXT: 'GALLERY_PASTE_TEXT',
GALLERY_REMOVE_FILES: 'GALLERY_REMOVE_FILES',
GALLERY_GET_DB: 'GALLERY_GET_DB',
GALLERY_GET_BY_ID_DB: 'GALLERY_GET_BY_ID_DB',
GALLERY_UPDATE_BY_ID_DB: 'GALLERY_UPDATE_BY_ID_DB',
GALLERY_REMOVE_BY_ID_DB: 'GALLERY_REMOVE_BY_ID_DB',
GALLERY_INSERT_DB: 'GALLERY_INSERT_DB',
GALLERY_INSERT_DB_BATCH: 'GALLERY_INSERT_DB_BATCH',
// plugin rpc
PLUGIN_GET_LIST: 'PLUGIN_GET_LIST',
PLUGIN_INSTALL: 'PLUGIN_INSTALL',
PLUGIN_IMPORT_LOCAL: 'PLUGIN_IMPORT_LOCAL',
PLUGIN_UPDATE_ALL: 'PLUGIN_UPDATE_ALL',
// tray rpc
TRAY_SET_TOOL_TIP: 'TRAY_SET_TOOL_TIP',
TRAY_GET_SHORT_URL: 'TRAY_GET_SHORT_URL',
TRAY_UPLOAD_CLIPBOARD_FILES: 'TRAY_UPLOAD_CLIPBOARD_FILES',
// manage rpc
MANAGE_GET_CONFIG: 'MANAGE_GET_CONFIG',
MANAGE_SAVE_CONFIG: 'MANAGE_SAVE_CONFIG',
MANAGE_REMOVE_CONFIG: 'MANAGE_REMOVE_CONFIG',
MANAGE_GET_BUCKET_LIST: 'MANAGE_GET_BUCKET_LIST',
MANAGE_GET_BUCKET_LIST_BACKSTAGE: 'MANAGE_GET_BUCKET_LIST_BACKSTAGE',
MANAGE_GET_BUCKET_LIST_RECURSIVELY: 'MANAGE_GET_BUCKET_LIST_RECURSIVELY',
MANAGE_CREATE_BUCKET: 'MANAGE_CREATE_BUCKET',
MANAGE_GET_BUCKET_FILE_LIST: 'MANAGE_GET_BUCKET_FILE_LIST',
MANAGE_GET_BUCKET_DOMAIN: 'MANAGE_GET_BUCKET_DOMAIN',
MANAGE_SET_BUCKET_ACL_POLICY: 'MANAGE_SET_BUCKET_ACL_POLICY',
MANAGE_RENAME_BUCKET_FILE: 'MANAGE_RENAME_BUCKET_FILE',
MANAGE_DELETE_BUCKET_FILE: 'MANAGE_DELETE_BUCKET_FILE',
MANAGE_DELETE_BUCKET_FOLDER: 'MANAGE_DELETE_BUCKET_FOLDER',
MANAGE_GET_PRE_SIGNED_URL: 'MANAGE_GET_PRE_SIGNED_URL',
MANAGE_UPLOAD_BUCKET_FILE: 'MANAGE_UPLOAD_BUCKET_FILE',
MANAGE_DOWNLOAD_BUCKET_FILE: 'MANAGE_DOWNLOAD_BUCKET_FILE',
MANAGE_CREATE_BUCKET_FOLDER: 'MANAGE_CREATE_BUCKET_FOLDER',
MANAGE_OPEN_FILE_SELECT_DIALOG: 'MANAGE_OPEN_FILE_SELECT_DIALOG',
MANAGE_GET_UPLOAD_TASK_LIST: 'MANAGE_GET_UPLOAD_TASK_LIST',
MANAGE_GET_DOWNLOAD_TASK_LIST: 'MANAGE_GET_DOWNLOAD_TASK_LIST',
MANAGE_DELETE_UPLOADED_TASK: 'MANAGE_DELETE_UPLOADED_TASK',
MANAGE_DELETE_ALL_UPLOADED_TASK: 'MANAGE_DELETE_ALL_UPLOADED_TASK',
MANAGE_DELETE_DOWNLOADED_TASK: 'MANAGE_DELETE_DOWNLOADED_TASK',
MANAGE_DELETE_ALL_DOWNLOADED_TASK: 'MANAGE_DELETE_ALL_DOWNLOADED_TASK',
MANAGE_SELECT_DOWNLOAD_FOLDER: 'MANAGE_SELECT_DOWNLOAD_FOLDER',
MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER: 'MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER',
MANAGE_OPEN_DOWNLOADED_FOLDER: 'MANAGE_OPEN_DOWNLOADED_FOLDER',
MANAGE_OPEN_LOCAL_FILE: 'MANAGE_OPEN_LOCAL_FILE',
MANAGE_DOWNLOAD_FILE_FROM_URL: 'MANAGE_DOWNLOAD_FILE_FROM_URL',
MANAGE_CONVERT_PATH_TO_BASE64: 'MANAGE_CONVERT_PATH_TO_BASE64'
}
export const IToolboxItemType = {
IS_CONFIG_FILE_BROKEN: 'IS_CONFIG_FILE_BROKEN',
IS_GALLERY_FILE_BROKEN: 'IS_GALLERY_FILE_BROKEN',
HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD: 'HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD',
HAS_PROBLEM_WITH_PROXY: 'HAS_PROBLEM_WITH_PROXY'
}
export const IToolboxItemCheckStatus = {
INIT: 'init',
LOADING: 'loading',
SUCCESS: 'success',
ERROR: 'error'
}
export const ISartMode = {
QUIET: 'quiet',
MINI: 'mini',
MAIN: 'main',
NO_TRAY: 'no-tray'
}
export const II18nLanguage = {
ZH_CN: 'zh-CN',
ZH_TW: 'zh-TW',
EN: 'en'
}
export const IShortUrlServer = {
C1N: 'c1n',
YOURLS: 'yourls',
CFWORKER: 'cf_worker',
SINK: 'sink'
}
export const commonTaskStatus = {
queuing: 'queuing',
failed: 'failed',
canceled: 'canceled',
paused: 'paused'
}
// manage task status
export const uploadTaskSpecialStatus = {
uploading: 'uploading',
uploaded: 'uploaded'
}
export const downloadTaskSpecialStatus = {
downloading: 'downloading',
downloaded: 'downloaded'
}

View File

@@ -1,7 +1,7 @@
import picgo from '@core/picgo'
import { IPicBedType } from '#/types/types'
import { configPaths } from '#/utils/configPaths'
import type { IPicBedType } from '#/types/types'
import { configPaths } from '~/utils/configPaths'
const getPicBeds = () => {
const picBedTypes = picgo.helper.uploader.getIdList()

View File

@@ -3,7 +3,7 @@ import path from 'node:path'
import fs from 'fs-extra'
import { Logger } from 'piclist'
import { isUrl } from '#/utils/common'
import { isUrl } from '~/utils/common'
interface IResultFileObject {
path: string

View File

@@ -1,8 +1,8 @@
import db from '@core/datastore'
import { II18nLanguage } from '#/types/enum'
import { configPaths } from '#/utils/configPaths'
import { i18nManager } from '~/i18n'
import { configPaths } from '~/utils/configPaths'
import { II18nLanguage } from '~/utils/enum'
export const initI18n = () => {
const currentLanguage = db.get(configPaths.settings.language) || II18nLanguage.ZH_CN

View File

@@ -1,10 +1,9 @@
import picgo from '@core/picgo'
import { v4 as uuid } from 'uuid'
import { IPicGoPluginConfig, IPicGoPluginOriginConfig, IStringKeyMap, IUploaderConfigItem, IUploaderConfigListItem } from '#/types/types'
import { trimValues } from '#/utils/common'
import { configPaths } from '#/utils/configPaths'
import { setTrayToolTip } from '~/utils/common'
import type { IPicGoPluginConfig, IPicGoPluginOriginConfig, IStringKeyMap, IUploaderConfigItem, IUploaderConfigListItem } from '#/types/types'
import { setTrayToolTip, trimValues } from '~/utils/common'
import { configPaths } from '~/utils/configPaths'
export const handleConfigWithFunction = (config: IPicGoPluginOriginConfig[]): IPicGoPluginConfig[] => {
for (const i in config) {

View File

@@ -0,0 +1,3 @@
import type { IAppNotification } from '#/types/types'
export const notificationList: IAppNotification[] = []

View File

@@ -1,9 +1,8 @@
import db from '@core/datastore'
import { IPasteStyle } from '#/types/enum'
import { ImgInfo } from '#/types/types'
import { configPaths } from '#/utils/configPaths'
import type { ImgInfo } from '#/types/types'
import { generateShortUrl, handleUrlEncodeWithSetting } from '~/utils/common'
import { configPaths } from '~/utils/configPaths'
export const formatCustomLink = (customLink: string, item: ImgInfo) => {
const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
@@ -24,7 +23,7 @@ export const formatCustomLink = (customLink: string, item: ImgInfo) => {
return customLink
}
export default async (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) => {
export default async (style: string, item: ImgInfo, customLink: string | undefined) => {
let url = item.url || item.imgUrl
if (item.type === 'aws-s3' || item.type === 'aws-s3-plist') {
url = item.imgUrl || item.url || ''
@@ -35,7 +34,7 @@ export default async (style: IPasteStyle, item: ImgInfo, customLink: string | un
url = item.shortUrl && item.shortUrl !== url ? item.shortUrl : await generateShortUrl(url)
}
const _customLink = customLink || '![$fileName]($url)'
const tpl = {
const tpl: Record<string, string> = {
markdown: `![](${url})`,
HTML: `<img src="${url}"/>`,
URL: url,

25
src/main/utils/static.ts Normal file
View File

@@ -0,0 +1,25 @@
export const CLIPBOARD_IMAGE_FOLDER = 'piclist-clipboard-images'
export const cancelDownloadLoadingFileList = 'cancelDownloadLoadingFileList'
export const refreshDownloadFileTransferList = 'refreshDownloadFileTransferList'
export const picBedsCanbeDeleted = [
'aliyun',
'alist',
'alistplist',
'aws-s3',
'aws-s3-plist',
'dogecloud',
'github',
'huaweicloud-uploader',
'imgur',
'local',
'lskyplist',
'piclist',
'qiniu',
'sftpplist',
'smms',
'tcyun',
'upyun',
'webdavplist'
]

View File

@@ -9,9 +9,9 @@ import fs from 'fs-extra'
import { HttpsProxyAgent } from 'hpagent'
import { AuthType, createClient, WebDAVClientOptions } from 'webdav'
import { ISyncConfig } from '#/types/types'
import { formatEndpoint } from '#/utils/common'
import { configPaths } from '#/utils/configPaths'
import type { ISyncConfig } from '#/types/types'
import { formatEndpoint } from '~/utils/common'
import { configPaths } from '~/utils/configPaths'
const STORE_PATH = app.getPath('userData')

View File

@@ -1,7 +1,7 @@
import db from '@core/datastore'
import updater from 'electron-updater'
import { configPaths } from '#/utils/configPaths'
import { configPaths } from '~/utils/configPaths'
const updateChecker = async () => {
let showTip = db.get(configPaths.settings.showUpdateTip)

View File

@@ -2,8 +2,8 @@ import db from '@core/datastore'
import windowManager from 'apis/app/window/windowManager'
import { screen } from 'electron'
import { IWindowList } from '#/types/enum'
import { configPaths } from '#/utils/configPaths'
import { configPaths } from '~/utils/configPaths'
import { IWindowList } from '~/utils/enum'
export function openMiniWindow (hideSettingWindow: boolean = true) {
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!