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

View File

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

View File

@ -8,12 +8,12 @@ import {
webContents webContents
} from 'electron' } from 'electron'
import db from '#/datastore' import db from '#/datastore'
import uploader from './uploader' import uploader from '../uploader'
import pasteTemplate from '#/utils/pasteTemplate' import pasteTemplate from '#/utils/pasteTemplate'
import { import {
getWindowId, getWindowId,
getSettingWindowId getSettingWindowId
} from '~/main/utils/busApi' } from '~/main/apis/bus'
class GuiApi implements IGuiApi { class GuiApi implements IGuiApi {
private windowId: number = -1 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 PicGoCore from '~/universal/types/picgo'
import path from 'path' import path from 'path'
import { import {
@ -6,11 +6,11 @@ import {
globalShortcut, globalShortcut,
BrowserWindow BrowserWindow
} from 'electron' } from 'electron'
import logger from './logger' import logger from '../../utils/logger'
import GuiApi from './guiApi' import GuiApi from '../gui'
import db from '#/datastore' import db from '#/datastore'
import shortKeyService from './shortKeyService' import shortKeyService from './shortKeyService'
import picgo from './picgo' import picgo from '../picgo'
class ShortKeyHandler { class ShortKeyHandler {
private isInModifiedMode: boolean = false private isInModifiedMode: boolean = false

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

View File

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