🔨 Refactor: move some utils to apis

This commit is contained in:
Molunerfinn 2020-01-08 19:26:25 +08:00
parent 73870a5326
commit 762dc9b2cc
15 changed files with 24 additions and 26 deletions

View File

@ -20,12 +20,12 @@ import {
installVueDevtools
} from 'vue-cli-plugin-electron-builder/lib'
import db from '#/datastore'
import picgo from '~/main/utils/picgo'
import uploader from '~/main/utils/uploader'
import picgo from '~/main/apis/picgo'
import uploader from '~/main/apis/uploader'
import beforeOpen from '~/main/utils/beforeOpen'
import pasteTemplate from '#/utils/pasteTemplate'
import updateChecker from '~/main/utils/updateChecker'
import { getPicBeds } from '~/main/utils/getPicBeds'
import getPicBeds from '~/main/utils/getPicBeds'
import pkg from 'root/package.json'
import picgoCoreIPC from '~/main/utils/picgoCoreIPC'
import fixPath from 'fix-path'
@ -33,8 +33,8 @@ import { getUploadFiles } from '~/main/utils/handleArgv'
import bus from '~/main/utils/eventBus'
import {
updateShortKeyFromVersion212
} from '~/main/migrate/shortKeyUpdateHelper'
import shortKeyHandler from '~/main/utils/shortKeyHandler'
} from '~/main/migrate'
import shortKeyHandler from '~/main/apis/shortKey/shortKeyHandler'
import logger from '~/main/utils/logger'
import {
UPLOAD_WITH_FILES,
@ -46,7 +46,7 @@ import {
GET_SETTING_WINDOW_ID,
GET_SETTING_WINDOW_ID_RESPONSE,
CREATE_APP_MENU
} from '~/main/utils/busApi/constants'
} from '~/main/apis/bus/constants'
import server from '~/main/server/index'
import { IWindowList } from '~/main/apis/window/constants'
import windowManager from '~/main/apis/window/windowManager'

View File

@ -1,4 +1,4 @@
import bus from '../eventBus'
import bus from '../../utils/eventBus'
import {
UPLOAD_WITH_FILES,
UPLOAD_WITH_FILES_RESPONSE,

View File

@ -8,12 +8,12 @@ import {
webContents
} from 'electron'
import db from '#/datastore'
import uploader from './uploader'
import uploader from '../uploader'
import pasteTemplate from '#/utils/pasteTemplate'
import {
getWindowId,
getSettingWindowId
} from '~/main/utils/busApi'
} from '~/main/apis/bus'
class GuiApi implements IGuiApi {
private windowId: number = -1

View File

@ -1,4 +1,4 @@
import bus from './eventBus'
import bus from '../../utils/eventBus'
import PicGoCore from '~/universal/types/picgo'
import path from 'path'
import {
@ -6,11 +6,11 @@ import {
globalShortcut,
BrowserWindow
} from 'electron'
import logger from './logger'
import GuiApi from './guiApi'
import logger from '../../utils/logger'
import GuiApi from '../gui'
import db from '#/datastore'
import shortKeyService from './shortKeyService'
import picgo from './picgo'
import picgo from '../picgo'
class ShortKeyHandler {
private isInModifiedMode: boolean = false

View File

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

View File

@ -6,7 +6,7 @@ import {
WebContents
} from 'electron'
import dayjs from 'dayjs'
import picgo from '~/main/utils/picgo'
import picgo from '~/main/apis/picgo'
import db from '#/datastore'
import windowManager from '~/main/apis/window/windowManager'
import { IWindowList } from '~/main/apis/window/constants'

View File

@ -10,9 +10,9 @@ import {
import { IWindowListItem } from '#/types/electron'
import bus from '~/main/utils/eventBus'
import db from '#/datastore'
import { getWindowId } from '~/main/utils/busApi'
import { getWindowId } from '~/main/apis/bus'
import { BrowserWindow, app } from 'electron'
import { CREATE_APP_MENU } from '~/main/utils/busApi/constants'
import { CREATE_APP_MENU } from '~/main/apis/bus/constants'
const windowList = new Map<IWindowList, IWindowListItem>()

View File

@ -3,7 +3,7 @@ import routers from './routerManager'
import {
handleResponse
} from './utils'
import picgo from '~/main/utils/picgo'
import picgo from '~/main/apis/picgo'
import logger from '~/main/utils/logger'
class Server {

View File

@ -2,7 +2,7 @@ import router from './router'
import {
uploadWithClipboardFiles,
uploadWithFiles
} from '~/main/utils/busApi/index'
} from '~/main/apis/bus/index'
import {
handleResponse
} from './utils'

View File

@ -1,4 +1,4 @@
import picgo from './picgo'
import picgo from '../apis/picgo'
const getPicBeds = () => {
const picBedTypes = picgo.helper.uploader.getIdList()
@ -14,6 +14,4 @@ const getPicBeds = () => {
return picBeds
}
export {
getPicBeds
}
export default getPicBeds

View File

View File

@ -1,5 +1,5 @@
import path from 'path'
import GuiApi from './guiApi'
import GuiApi from '../apis/gui'
import {
dialog,
shell,
@ -11,8 +11,8 @@ import {
} from 'electron'
import PicGoCore from '~/universal/types/picgo'
import { IPicGoHelperType } from '#/types/enum'
import shortKeyHandler from './shortKeyHandler'
import picgo from '~/main/utils/picgo'
import shortKeyHandler from '../apis/shortKey/shortKeyHandler'
import picgo from '~/main/apis/picgo'
// eslint-disable-next-line
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require