fix: 修正复制链接插件和复制插件冲突的问题
This commit is contained in:
1 parent
5d0abf5ac9
commit
6f42c634ff
3 files changed
+68
-4
No files matched your search
@@ -14,7 +14,7 @@ const initPlugin = async (globalAlertTip: alertTipType) => {
|
|||||||
type: PluginExportType
|
type: PluginExportType
|
||||||
key?: string
|
key?: string
|
||||||
}
|
}
|
||||||
const { type, key } = _config
|
const { type, key = `${Math.random()}` } = _config
|
||||||
if (type === PluginExportType.component) {
|
if (type === PluginExportType.component) {
|
||||||
pluginCenter.registerComponent(
|
pluginCenter.registerComponent(
|
||||||
_config.default as registerComponentOption
|
_config.default as registerComponentOption
|
||||||
|
|||||||
@@ -19,11 +19,9 @@ const pluginConfig: Plugin = {
|
|||||||
disable: false,
|
disable: false,
|
||||||
group: [PluginGroup.default],
|
group: [PluginGroup.default],
|
||||||
func: Copy,
|
func: Copy,
|
||||||
priority: -1
|
priority: -100
|
||||||
}
|
}
|
||||||
|
|
||||||
export default pluginConfig
|
export default pluginConfig
|
||||||
|
|
||||||
export const type = PluginExportType.default
|
export const type = PluginExportType.default
|
||||||
|
|
||||||
export const key = 'miaoCopy'
|
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { PluginGroup, registerComponentOption } from "@/class/PluginCenter"
|
||||||
|
import VirtualDirectory, { VirtualFile } from "@/class/VirtualDirectory"
|
||||||
|
import VirtualPage from "@/class/VirtualPage"
|
||||||
|
import usePluginCenter from "@/hooks/usePluginCenter"
|
||||||
|
import useVirtualPages from "@/hooks/useVirtualPages"
|
||||||
|
|
||||||
|
export const componentOption2pluginOption = (option: registerComponentOption) => {
|
||||||
|
const {
|
||||||
|
key,
|
||||||
|
name,
|
||||||
|
getComponent,
|
||||||
|
icon,
|
||||||
|
filter,
|
||||||
|
group = [PluginGroup.default],
|
||||||
|
disable = false,
|
||||||
|
exitConfirm = false,
|
||||||
|
single = false,
|
||||||
|
priority = 0
|
||||||
|
} = option
|
||||||
|
let _component: any
|
||||||
|
const views = useVirtualPages()
|
||||||
|
const pluginCenter = usePluginCenter()
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
filter,
|
||||||
|
icon: shallowRef(icon),
|
||||||
|
group,
|
||||||
|
disable,
|
||||||
|
priority,
|
||||||
|
func: async (
|
||||||
|
VDirectories: VirtualDirectory[],
|
||||||
|
VFiles: VirtualFile[]
|
||||||
|
) => {
|
||||||
|
if (filter(VDirectories, VFiles) === false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_component === undefined) {
|
||||||
|
const setAlertTip = pluginCenter.globalAlertTip(`加载 ${name} 插件中`)
|
||||||
|
_component = await getComponent()
|
||||||
|
setAlertTip &&
|
||||||
|
setAlertTip(`加载 ${name} 插件完成`, {
|
||||||
|
type: 'success',
|
||||||
|
timeout: 2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const _findRes = views.find(_component) as VirtualPage[]
|
||||||
|
if (single && _findRes.length !== 0) {
|
||||||
|
const view = _findRes[0]
|
||||||
|
view.currentFiles = [...view.currentFiles, ...VFiles]
|
||||||
|
view.currentDirectories = [
|
||||||
|
...view.currentDirectories,
|
||||||
|
...VDirectories
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
views.push(_component, key, VDirectories, VFiles, {
|
||||||
|
VirtualPageOption: {
|
||||||
|
exitConfirm,
|
||||||
|
allowCopy: single === false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user