feat: 添加一个复制文件链接到剪切板的插件

This commit is contained in:
539943419 committed 2024-09-08 05:57:13 +08:00
1 parent 0e631a6f34
commit ff7d0d8d51
17 files changed
+142 -15

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
import { VirtualFile } from "@/class/VirtualDirectory"
import config from "@/config"
import { usePluginHooksType } from "@/types/type"
import copy2Clipboard from 'copy-to-clipboard'
const copy = (__: any, vFiles: VirtualFile[], hooks: usePluginHooksType) => {
const { globalAlertTip } = hooks
const vFile = vFiles[0]
console.log(vFile.url)
copy2Clipboard(`${config.baseUrl}${vFile.url}`)
globalAlertTip(`${vFile.name}的链接已复制至剪切板`, {
type: 'info',
timeout: 2000
})
}
export default copy
@@ -0,0 +1,26 @@
import { Plugin, PluginGroup } from "@/class/PluginCenter";
import Copy from "./copy";
import { CopyOutline } from "@vicons/ionicons5";
import { PluginExportType } from "@/types/type";
import { shallowRef } from "vue";
const pluginConfig: Plugin = {
name: "复制链接",
icon: shallowRef(CopyOutline),
filter: (vDirs, vFiles) => {
if (vDirs.length !== 0) {
return false;
}
if (vFiles.length !== 1) {
return false;
}
return true;
},
disable: false,
group: [PluginGroup.default],
func: Copy
};
export default pluginConfig;
export const type = PluginExportType.default;
+3
View File
@@ -1,5 +1,6 @@
import { registerComponentOption } from '@/class/PluginCenter'
import { CodeOutline } from '@vicons/ionicons5'
import { PluginExportType } from '@/types/type'
const pluginConfig: registerComponentOption = {
key: 'miaoCodeMirror',
@@ -40,3 +41,5 @@ const pluginConfig: registerComponentOption = {
}
export default pluginConfig
export const type = PluginExportType.component
+4
View File
@@ -1,5 +1,6 @@
// @ts-nocheck
import { registerComponentOption } from '@/class/PluginCenter'
import { PluginExportType } from '@/types/type'
const pluginConfig: registerComponentOption = {
key: 'miaoCrypto',
@@ -16,6 +17,9 @@ const pluginConfig: registerComponentOption = {
}
return vFiles[0].name.endsWith('txt')
},
disable: true,
}
export default pluginConfig
export const type = PluginExportType.component
+15 -6
View File
@@ -2,6 +2,7 @@
<miao-drop-handler @on-virtual-files="handleDropVirtualFiles">
<div class="miaoCrypto-container">
<div class="miaoCrypto-container-encrypt miaoCrypto-container-item">
<n-scrollbar style="max-height: 100%">
<div v-for="item of workItemList" :key="item.id" class="miaoCrypto-container-item-item">
<div class="miaoCrypto-container-item-percentBar" :style="{
@@ -18,7 +19,7 @@
</div>
</n-scrollbar>
</div>
<div class="miaoCrypto-container-decrypt miaoCrypto-container-item"></div>
<!-- <div class="miaoCrypto-container-decrypt miaoCrypto-container-item"></div> -->
</div>
</miao-drop-handler>
</template>
@@ -38,7 +39,7 @@ const miaoFetchApi = useMiaoFetchApi()
interface workItem {
id: number
status: 'wait' | 'process' | 'finish'
status: 'wait' | 'process' | 'finish' | 'error'
buffer?: Uint8Array
getBuffer: () => Promise<Uint8Array>
getBufferProgress: number
@@ -68,8 +69,12 @@ class Work {
return
}
currentItem.status = 'process'
currentItem.buffer = await this.func(key.value, currentItem.buffer)
currentItem.status = 'finish'
try {
currentItem.buffer = await this.func(key.value, currentItem.buffer)
currentItem.status = 'finish'
} catch (e) {
currentItem.status = 'error'
}
this.funcLoop()
}
async getBufferLoop() {
@@ -81,7 +86,11 @@ class Work {
}
const item = _list[0]
item.isGettingBuffer = true
item.buffer = await item.getBuffer()
try {
item.buffer = await item.getBuffer()
} catch(e) {
item.status = 'error'
}
item.isGettingBuffer = false
this.funcLoop()
this.getBufferLoop()
@@ -139,7 +148,7 @@ onMounted(() => {
onUnmounted(() => {
encryptWork.abortLoop = true
encryptWork.queue.forEach(item=>{
encryptWork.queue.forEach(item => {
item.getBufferAbort && item.getBufferAbort()
})
})
+4
View File
@@ -17,3 +17,7 @@ const pluginConfig: registerComponentOption = {
}
export default pluginConfig
import { PluginExportType } from '@/types/type'
export const type = PluginExportType.component
+5 -1
View File
@@ -18,4 +18,8 @@ const pluginConfig: registerComponentOption = {
}
}
export default pluginConfig
export default pluginConfig
import { PluginExportType } from '@/types/type'
export const type = PluginExportType.component
+4
View File
@@ -43,3 +43,7 @@ const pluginConfig: registerComponentOption = {
}
export default pluginConfig
import { PluginExportType } from '@/types/type'
export const type = PluginExportType.component
+4
View File
@@ -19,3 +19,7 @@ const pluginConfig: registerComponentOption = {
}
export default pluginConfig
import { PluginExportType } from '@/types/type'
export const type = PluginExportType.component
+4
View File
@@ -19,3 +19,7 @@ const pluginConfig: registerComponentOption = {
}
export default pluginConfig
import { PluginExportType } from '@/types/type'
export const type = PluginExportType.component
@@ -20,3 +20,7 @@ const pluginConfig: registerComponentOption = {
}
export default pluginConfig
import { PluginExportType } from '@/types/type'
export const type = PluginExportType.component
+4
View File
@@ -26,3 +26,7 @@ const pluginConfig: registerComponentOption = {
}
export default pluginConfig
import { PluginExportType } from '@/types/type'
export const type = PluginExportType.component