🔨 Refactor(custom): refactored all imports

This commit is contained in:
Kuingsmile
2024-06-09 11:53:07 +08:00
parent 8a565c1333
commit e87e3999b4
138 changed files with 947 additions and 1333 deletions
+15 -57
View File
@@ -1438,37 +1438,8 @@ 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, UploadFilled, 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 { ipcRenderer, clipboard, IpcRendererEvent } from 'electron'
import {
ElMessage, ElMessageBox, ElNotification,
ElButton,
@@ -1485,44 +1456,31 @@ 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 { InfoFilled, Grid, Fold, Close, Folder, FolderAdd, Upload, CircleClose, Loading, CopyDocument, Edit, UploadFilled, Link, Refresh, ArrowRight, HomeFilled, Document, Coin, Download, DeleteFilled, Sort, FolderOpened } from '@element-plus/icons-vue'
import fs from 'fs-extra'
// 数据发送工具函数
import { getConfig, saveConfig } from '../utils/dataSender'
// Markdown 解析库
import { marked } from 'marked'
import path from 'path'
import { v4 as uuidv4 } from 'uuid'
import { ref, reactive, watch, onBeforeMount, computed, onBeforeUnmount } from 'vue'
import { useRoute } from 'vue-router'
// 文本文件扩展名列表
import { textFileExt } from '../utils/textfile'
import { fileCacheDbInstance } from '@/manage/store/bucketFileDb'
import { useFileTransferStore, useDownloadFileTransferStore, useManageStore } from '@/manage/store/manageStore'
import { customRenameFormatTable, customStrMatch, customStrReplace, renameFile, formatLink, formatFileName, getFileIconPath, formatFileSize, getExtension, isValidUrl, svg } from '@/manage/utils/common'
import { getConfig, saveConfig } from '@/manage/utils/dataSender'
import { cancelDownloadLoadingFileList, refreshDownloadFileTransferList } from '@/manage/utils/static'
import { textFileExt } from '@/manage/utils/textfile'
import { videoExt } from '@/manage/utils/videofile'
// 视频文件扩展名列表
import { videoExt } from '../utils/videofile'
// 组件
import ImageWebdav from '@/components/ImageWebdav.vue'
import ImageLocal from '@/components/ImageLocal.vue'
import ImageWebdavTsx from '@/components/ImageWebdavTsx'
// 国际化函数
import { T as $T } from '@/i18n'
import { IUploadTask, IDownloadTask } from '~/main/manage/datastore/upDownTaskQueue'
import { IUploadTask, IDownloadTask } from '~/manage/datastore/upDownTaskQueue'
import { trimPath } from '~/manage/utils/common'
/*
configMap:{
prefix: string, -> baseDir
+10 -30
View File
@@ -267,43 +267,23 @@
</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, ElMessageBox, ElNotification } from 'element-plus'
// 数据发送工具函数
import { getConfig, saveConfig, removeConfig } from '../utils/dataSender'
// Electron 相关
import { shell } from 'electron'
// Vue Router 相关
import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'
import { Delete, Edit, Pointer, InfoFilled } from '@element-plus/icons-vue'
import { reactive, ref, onMounted, computed } from 'vue'
import { useRouter } from 'vue-router'
// 状态管理相关
import { useManageStore } from '../store/manageStore'
import { useManageStore } from '@/manage/store/manageStore'
import { supportedPicBedList } from '@/manage/utils/constants'
import { getConfig, saveConfig, removeConfig } from '@/manage/utils/dataSender'
import { formObjToTableData, svg } from '@/manage/utils/common'
// 工具函数
import { formObjToTableData, svg } from '../utils/common'
// 数据发送工具函数
import { getConfig as getPicBedsConfig } from '@/utils/dataSender'
// 端点地址格式化
import { formatEndpoint } from '~/main/manage/utils/common'
import { isNeedToShorten, safeSliceF } from '#/utils/common'
// 国际化函数
import { T as $T } from '@/i18n'
import { formatEndpoint } from '~/manage/utils/common'
import { isNeedToShorten, safeSliceF } from '#/utils/common'
const manageStore = useManageStore()
const router = useRouter()
+7 -24
View File
@@ -279,36 +279,19 @@
</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 { ElNotification } from 'element-plus'
import { CirclePlus, SuccessFilled, Folder, Switch, Tools, ChromeFilled, HomeFilled, FolderOpened } from '@element-plus/icons-vue'
// Vue Router 相关
import path from 'path'
import { ref, reactive, computed, onBeforeMount, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
// Element Plus 通知组件
import { ElNotification } from 'element-plus'
import { supportedPicBedList } from '@/manage/utils/constants'
import { invokeToMain } from '@/manage/utils/dataSender'
import { useManageStore } from '@/manage/store/manageStore'
import { newBucketConfig } from '@/manage/utils/newBucketConfig'
// 数据发送工具函数
import { invokeToMain } from '../utils/dataSender'
// 新建图床配置
import { newBucketConfig } from '../utils/newBucketConfig'
// 状态管理相关
import { useManageStore } from '../store/manageStore'
// 国际化函数
import { T as $T } from '@/i18n'
import path from 'path'
const manageStore = useManageStore() as any
const route = useRoute()
+8 -6
View File
@@ -241,15 +241,17 @@
</template>
<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { InfoFilled, Folder } from '@element-plus/icons-vue'
import { ref, onBeforeMount, watch } from 'vue'
import { getConfig, saveConfig, invokeToMain } from '../utils/dataSender'
import { ElMessage } from 'element-plus'
import { fileCacheDbInstance } from '../store/bucketFileDb'
import { formatFileSize, customRenameFormatTable } from '../utils/common'
import DynamicSwitch from '@/manage/components/DynamicSwitch.vue'
import { fileCacheDbInstance } from '@/manage/store/bucketFileDb'
import { formatFileSize, customRenameFormatTable } from '@/manage/utils/common'
import { getConfig, saveConfig, invokeToMain } from '@/manage/utils/dataSender'
import { selectDownloadFolder } from '@/manage/utils/static'
import { T as $T } from '@/i18n'
import { selectDownloadFolder } from '../utils/static'
import DynamicSwitch from '../components/DynamicSwitch.vue'
const form = ref<IStringKeyMap>({
timestampRename: false,
+2 -1
View File
@@ -1,5 +1,6 @@
import { defineStore } from 'pinia'
import { getConfig } from '../utils/dataSender'
import { getConfig } from '@/manage/utils/dataSender'
export const useManageStore = defineStore('manageConfig', {
state: () => {
+5 -14
View File
@@ -1,20 +1,11 @@
// UUID
import crypto from 'crypto'
import path from 'path'
import { v4 as uuidv4 } from 'uuid'
// 路径处理库
import path from 'path'
import { availableIconList } from '@/manage/utils/icon'
import { getConfig } from '@/manage/utils/dataSender'
// 加密库
import crypto from 'crypto'
// 可用图标列表
import { availableIconList } from './icon'
// 数据发送工具函数
import { getConfig } from './dataSender'
// 工具函数
import { handleUrlEncode, safeSliceF, isNeedToShorten } from '~/universal/utils/common'
import { handleUrlEncode, safeSliceF, isNeedToShorten } from '#/utils/common'
export function randomStringGenerator (length: number): string {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
+5 -3
View File
@@ -1,12 +1,14 @@
import { ipcRenderer, IpcRendererEvent } from 'electron'
import { PICLIST_MANAGE_GET_CONFIG, PICLIST_MANAGE_SAVE_CONFIG, PICLIST_MANAGE_REMOVE_CONFIG } from '~/main/manage/events/constants'
import { v4 as uuid } from 'uuid'
import { getRawData } from '~/renderer/utils/common'
import { getRawData } from '@/utils/common'
import { PICLIST_MANAGE_GET_CONFIG, PICLIST_MANAGE_SAVE_CONFIG, PICLIST_MANAGE_REMOVE_CONFIG } from '~/manage/events/constants'
export function getConfig<T> (key?: string): Promise<T | undefined> {
return new Promise((resolve) => {
const callbackId = uuid()
const callback = (event: IpcRendererEvent, config: T | undefined, returnCallbackId: string) => {
const callback = (_: IpcRendererEvent, config: T | undefined, returnCallbackId: string) => {
if (returnCallbackId === callbackId) {
resolve(config)
ipcRenderer.removeListener(PICLIST_MANAGE_GET_CONFIG, callback)
+1 -1
View File
@@ -1,4 +1,4 @@
import { AliyunAreaCodeName, QiniuAreaCodeName, TencentAreaCodeName } from '~/main/manage/utils/constants'
import { AliyunAreaCodeName, QiniuAreaCodeName, TencentAreaCodeName } from '~/manage/utils/constants'
import { T as $T } from '@/i18n'
export const newBucketConfig:IStringKeyMap = {