添加miaoContextMenu用于自定义右键菜单
This commit is contained in:
1 parent
ed364f6343
commit
60477a9112
8 files changed
+237
-111
No files matched your search
+10
-4
@@ -42,14 +42,18 @@ const rootDirectory = reactive(
|
|||||||
// component就是一个vue组件,类似于miaoDirectory
|
// component就是一个vue组件,类似于miaoDirectory
|
||||||
const createView = (
|
const createView = (
|
||||||
component: any,
|
component: any,
|
||||||
currentObjects: (VirtualDirectory | VirtualFile)[],
|
currentDirectorys?: VirtualDirectory[],
|
||||||
|
currentFiles?: VirtualFile[],
|
||||||
index?: number
|
index?: number
|
||||||
) => {
|
) => {
|
||||||
index ?? (index = views.length)
|
index ?? (index = views.length)
|
||||||
views.splice(
|
views.splice(
|
||||||
index,
|
index,
|
||||||
0,
|
0,
|
||||||
reactive<VirtualPage>(new VirtualPage(component, [...currentObjects]))
|
reactive<VirtualPage>(new VirtualPage(component, {
|
||||||
|
directorys: [...(currentDirectorys ?? [])],
|
||||||
|
files: [...(currentFiles ?? [])]
|
||||||
|
}))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +149,8 @@ onMounted(() => {
|
|||||||
@click="
|
@click="
|
||||||
createView(
|
createView(
|
||||||
view.component,
|
view.component,
|
||||||
view.currentObjects,
|
view.currentDirectorys,
|
||||||
|
view.currentFiles,
|
||||||
index + 1
|
index + 1
|
||||||
)
|
)
|
||||||
">
|
">
|
||||||
@@ -183,7 +188,7 @@ onMounted(() => {
|
|||||||
:key="view.uid">
|
:key="view.uid">
|
||||||
<component
|
<component
|
||||||
:is="view.component"
|
:is="view.component"
|
||||||
v-model:current-objects="view.currentObjects"
|
v-model:current-objects="view.currentDirectorys"
|
||||||
:id="view.uid"
|
:id="view.uid"
|
||||||
:color="view.color"
|
:color="view.color"
|
||||||
@exit="deleteView(index)"></component>
|
@exit="deleteView(index)"></component>
|
||||||
@@ -194,6 +199,7 @@ onMounted(() => {
|
|||||||
<!-- 模态框展示,用来显示分享二维码,设置菜单之类的东西 -->
|
<!-- 模态框展示,用来显示分享二维码,设置菜单之类的东西 -->
|
||||||
<MiaoMask v-model:show="showModal" @click="showModal = false">
|
<MiaoMask v-model:show="showModal" @click="showModal = false">
|
||||||
<component
|
<component
|
||||||
|
@click="(e:any) => e.stopPropagation()"
|
||||||
:is="modalData?.component"
|
:is="modalData?.component"
|
||||||
v-bind="modalData?.props"></component>
|
v-bind="modalData?.props"></component>
|
||||||
</MiaoMask>
|
</MiaoMask>
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ class VirtualDirectory {
|
|||||||
* @param {number} layer 需要跳转的层数
|
* @param {number} layer 需要跳转的层数
|
||||||
* @returns {VirtualDirectory}
|
* @returns {VirtualDirectory}
|
||||||
*/
|
*/
|
||||||
getParent(layer: number): VirtualDirectory {
|
getParents(layer: number): VirtualDirectory {
|
||||||
if (layer <= 0 || !this.parent) {
|
if (layer <= 0 || !this.parent) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return this.parent.getParent(layer - 1);
|
return this.parent.getParents(layer - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateContent(content: (file | directory)[]) {
|
updateContent(content: (file | directory)[]) {
|
||||||
|
|||||||
@@ -13,20 +13,23 @@ const getRandomWebSafeColor = (() => {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
export default class VirtualPage {
|
export default class VirtualPage {
|
||||||
constructor(component: any, initObjects: (VirtualDirectory | VirtualFile)[]) {
|
constructor(component: any, initObjects?:{ directorys?: VirtualDirectory[], files?: VirtualFile[]}) {
|
||||||
this.component = shallowRef(component);
|
this.component = shallowRef(component);
|
||||||
this.currentObjects = initObjects;
|
this.currentDirectorys = initObjects?.directorys ?? [];
|
||||||
|
this.currentFiles = initObjects?.files ?? [];
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.uid = generateId();
|
this.uid = generateId();
|
||||||
this.refreshKey = Math.random();
|
this.refreshKey = Math.random();
|
||||||
this.color = getRandomWebSafeColor();
|
this.color = getRandomWebSafeColor();
|
||||||
}
|
}
|
||||||
|
// 页面使用的组件
|
||||||
component: any;
|
component: any;
|
||||||
// 是否可见
|
// 是否可见
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
// 当前正在使用的文件或是文件夹
|
// 当前正在使用的文件夹
|
||||||
currentObjects: (VirtualDirectory | VirtualFile)[];
|
currentDirectorys: VirtualDirectory[];
|
||||||
|
// 当前正在使用的文件
|
||||||
|
currentFiles: VirtualFile[];
|
||||||
// 区分每一个页面的唯一id
|
// 区分每一个页面的唯一id
|
||||||
uid: number;
|
uid: number;
|
||||||
// 当refreshKey改变时需要刷新页面,目前还没接入刷新
|
// 当refreshKey改变时需要刷新页面,目前还没接入刷新
|
||||||
@@ -40,7 +43,7 @@ export default class VirtualPage {
|
|||||||
if (this._title) {
|
if (this._title) {
|
||||||
return this._title;
|
return this._title;
|
||||||
}
|
}
|
||||||
return this.currentObjects[0].name;
|
return this.currentDirectorys[0].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(title: string) {
|
setTitle(title: string) {
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<!-- 基于naiveui的下拉菜单实现的自定义下拉菜单 -->
|
||||||
|
<!-- 支持长按和右键呼出下拉菜单 -->
|
||||||
|
<template>
|
||||||
|
<div class="main" @contextmenu="handleContextMenu" @mouseleave="handleMainMouseLeave" @touchstart="handleTouchStart"
|
||||||
|
@touchend="handleTouchEnd">
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
<n-dropdown placement="bottom-start" trigger="manual" :x="x" :y="y" :options="props.options"
|
||||||
|
:show="showContextMenu > 0" :on-clickoutside="onClickoutside" @select="handleSelect" @mouseleave="
|
||||||
|
showContextMenu -= 1" @mouseenter="showContextMenu += 1" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { NDropdown } from 'naive-ui/es/dropdown';
|
||||||
|
import { DropdownOption } from 'naive-ui/es/dropdown';
|
||||||
|
import { nextTick, ref } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
options: DropdownOption[]
|
||||||
|
// 长按呼出右键菜单的时延,undefined时不生效
|
||||||
|
touchTimeOut?: number
|
||||||
|
}>()
|
||||||
|
const emit = defineEmits<{
|
||||||
|
select: [key: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const x = ref(0)
|
||||||
|
const y = ref(0)
|
||||||
|
const showContextMenu = ref(0)
|
||||||
|
// 长按计时器
|
||||||
|
let timer_touch: string | number | NodeJS.Timeout | undefined
|
||||||
|
|
||||||
|
const onClickoutside = async () => {
|
||||||
|
showContextMenu.value = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleMainMouseLeave = async () => {
|
||||||
|
// setTimeout(() => {
|
||||||
|
// showContextMenu.value -= 1
|
||||||
|
// }, 200)
|
||||||
|
nextTick(()=>{
|
||||||
|
showContextMenu.value -= 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSelect = async (key: string) => {
|
||||||
|
emit('select', key)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleContextMenu = (e: MouseEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
showContextMenu.value = 0
|
||||||
|
nextTick().then(() => {
|
||||||
|
showContextMenu.value += 1
|
||||||
|
x.value = e.clientX
|
||||||
|
y.value = e.clientY
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleTouchStart = (e: TouchEvent) => {
|
||||||
|
if(props.touchTimeOut === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
timer_touch ?? clearTimeout(timer_touch)
|
||||||
|
timer_touch = setTimeout(() => {
|
||||||
|
showContextMenu.value = 1
|
||||||
|
x.value = e.targetTouches[0].clientX
|
||||||
|
y.value = e.targetTouches[0].clientY
|
||||||
|
}, props.touchTimeOut)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleTouchEnd = () => {
|
||||||
|
if(timer_touch) {
|
||||||
|
clearTimeout(timer_touch)
|
||||||
|
timer_touch = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.main {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,13 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div class="miao-item" draggable="true" ref="itemRef" @dragstart="handleDragStart">
|
||||||
class="miao-item"
|
<miaoContextMenu :options="dropDownOptions" :touch-time-out="500" @select="handleDropdownSelect">
|
||||||
draggable="true"
|
|
||||||
ref="itemRef"
|
|
||||||
@dragstart="handleDragStart">
|
|
||||||
<div class="item-main">
|
<div class="item-main">
|
||||||
<div
|
<div class="item-main-front" :style="{ backgroundColor: props.color }"></div>
|
||||||
class="item-main-front"
|
|
||||||
:style="{ backgroundColor: props.color }"></div>
|
|
||||||
<Icon class="item-main-icon"></Icon>
|
<Icon class="item-main-icon"></Icon>
|
||||||
<div class="item-main-info">
|
<div class="item-main-info">
|
||||||
<div class="item-main-info-name">
|
<div class="item-main-info-name">
|
||||||
@@ -17,22 +12,20 @@
|
|||||||
{{ time }}
|
{{ time }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<n-dropdown
|
<!-- 菜单现在通过右键/长按呼出 -->
|
||||||
trigger="click"
|
<!-- <n-dropdown trigger="click" :options="dropDownOptions" @select="handleDropdownSelect">
|
||||||
:options="dropDownOptions"
|
<div class="item-main-option" @click="(e) => e.stopPropagation()">
|
||||||
@select="handleDropdownSelect">
|
|
||||||
<div
|
|
||||||
class="item-main-option"
|
|
||||||
@click="(e) => e.stopPropagation()">
|
|
||||||
<EllipsisVertical class="item-main-option-icon" />
|
<EllipsisVertical class="item-main-option-icon" />
|
||||||
</div>
|
</div>
|
||||||
</n-dropdown>
|
</n-dropdown> -->
|
||||||
</div>
|
</div>
|
||||||
|
</miaoContextMenu>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import VirtualDirectory, { VirtualFile } from '@/class/VirtualDirectory'
|
import VirtualDirectory, { VirtualFile } from '@/class/VirtualDirectory'
|
||||||
|
import miaoContextMenu from '../miaoContextMenu.vue'
|
||||||
import {
|
import {
|
||||||
DocumentText,
|
DocumentText,
|
||||||
FileTray,
|
FileTray,
|
||||||
@@ -43,15 +36,10 @@ import {
|
|||||||
LogoJavascript,
|
LogoJavascript,
|
||||||
LogoVue,
|
LogoVue,
|
||||||
PlayCircle,
|
PlayCircle,
|
||||||
EllipsisVertical,
|
|
||||||
Disc
|
Disc
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import dateFormatter from '@/hooks/dateFormatter'
|
import dateFormatter from '@/hooks/dateFormatter'
|
||||||
// import useDataBus from '@/hooks/useDataBus'
|
|
||||||
import { NDropdown } from 'naive-ui'
|
|
||||||
|
|
||||||
// const dataBus = useDataBus()
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
item: VirtualDirectory | VirtualFile
|
item: VirtualDirectory | VirtualFile
|
||||||
@@ -96,7 +84,7 @@ const dropDownOptions = computed(() => {
|
|||||||
return options
|
return options
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleDropdownSelect = (key: 'download' | 'delete') => {
|
const handleDropdownSelect = (key: string) => {
|
||||||
if (key === 'download') {
|
if (key === 'download') {
|
||||||
emit('download')
|
emit('download')
|
||||||
} else if (key === 'delete') {
|
} else if (key === 'delete') {
|
||||||
@@ -179,6 +167,7 @@ const handleDragStart = (event: DragEvent) => {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 10px 10px;
|
margin: 10px 10px;
|
||||||
|
|
||||||
.item-main {
|
.item-main {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -188,30 +177,36 @@ const handleDragStart = (event: DragEvent) => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
|
|
||||||
.item-main-front {
|
.item-main-front {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 10px;
|
width: 10px;
|
||||||
border-radius: 7px 0 0 7px;
|
border-radius: 7px 0 0 7px;
|
||||||
background-color: rgb(0, 0, 0);
|
background-color: rgb(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-main-icon {
|
.item-main-icon {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
height: 80%;
|
height: 80%;
|
||||||
color: #00403e;
|
color: #00403e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-main-info {
|
.item-main-info {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
&-name {
|
&-name {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-date {
|
&-date {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-main-option {
|
.item-main-option {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
@@ -225,18 +220,22 @@ const handleDragStart = (event: DragEvent) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
|
|
||||||
.item-main-option-icon {
|
.item-main-option-icon {
|
||||||
color: #000;
|
color: #000;
|
||||||
transition: color 0.15s;
|
transition: color 0.15s;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:active {
|
&:active {
|
||||||
background-color: #8b8b8b;
|
background-color: #8b8b8b;
|
||||||
|
|
||||||
.item-main-option-icon {
|
.item-main-option-icon {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:active {
|
&:active {
|
||||||
background-color: #d2d2d2;
|
background-color: #d2d2d2;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="transition">
|
<transition name="transition">
|
||||||
<div class="mask-body" ref="maskBodyRef" v-show="showMask">
|
<div class="mask-body" ref="maskBodyRef" v-show="showMask">
|
||||||
<div @click="e=>e.stopPropagation()">
|
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
@@ -27,17 +25,24 @@ const showMask = defineModel<boolean | number>('show', { default: false, require
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: rgba(0, 0, 0, 0.3);
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
z-index: 7058214053994319;
|
z-index: 7058214053994319;
|
||||||
|
|
||||||
|
// &-container {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
&-show {
|
&-show {
|
||||||
display: flex;
|
display: flex;
|
||||||
transition: opacity 0.3s 0.01s;
|
transition: opacity 0.3s 0.01s;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-hide {
|
&-hide {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: display 0.01s 0.3s;
|
transition: display 0.01s 0.3s;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.transition-enter-active,
|
.transition-enter-active,
|
||||||
.transition-leave-active {
|
.transition-leave-active {
|
||||||
transition: opacity 0.3s ease;
|
transition: opacity 0.3s ease;
|
||||||
|
|||||||
@@ -1,43 +1,79 @@
|
|||||||
<template>
|
<template>
|
||||||
<miao-mask v-model:show="showMask">
|
<miao-mask v-model:show="showMask">
|
||||||
<n-card title="">
|
<n-card class="popup-card" :title="popupConfig?.title" size="medium">
|
||||||
<n-input v-model:value="inputValue" type="text" placeholder="基本的 Input" />
|
{{ popupConfig?.content }}
|
||||||
<n-button @click="_resolve && _resolve(inputValue)">确认</n-button>
|
<n-input class="popup-input" v-model:value="inputValue" type="text" v-bind="popupConfig?.inputProps"
|
||||||
|
v-if="popupConfig?.inputProps" />
|
||||||
|
<div class="popup-button-container">
|
||||||
|
<n-button class="popup-button-container-button" v-for="option in popupConfig?.options" :key="option.label"
|
||||||
|
:type="option.type" @click="_resolve && _resolve(option.key)">{{ option.label }}</n-button>
|
||||||
|
</div>
|
||||||
</n-card>
|
</n-card>
|
||||||
</miao-mask>
|
</miao-mask>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref } from "vue";
|
import { ref, nextTick } from "vue";
|
||||||
import { NCard, NInput, NButton } from "naive-ui";
|
import { NCard, NInput, NButton } from "naive-ui";
|
||||||
import miaoMask from "./miaoMask.vue";
|
import miaoMask from "./miaoMask.vue";
|
||||||
|
import { InputProps } from "naive-ui";
|
||||||
|
|
||||||
const showMask = ref(true);
|
const showMask = ref(false);
|
||||||
const inputValue = ref<string>("");
|
const inputValue = ref<string>("");
|
||||||
const _resolve = ref<(text: string) => void>()
|
const _resolve = ref()
|
||||||
|
|
||||||
type popupConfig = {
|
type popupConfigType = {
|
||||||
title: string
|
title: string
|
||||||
placeholder: string
|
content?: string
|
||||||
|
inputProps?: InputProps
|
||||||
options: {
|
options: {
|
||||||
label
|
label: string
|
||||||
}
|
key: unknown
|
||||||
|
type: 'default' | 'tertiary' | 'primary' | 'success' | 'info' | 'warning' | 'error'
|
||||||
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _config = reactive<popupConfig>({
|
const popupConfig = ref<popupConfigType>()
|
||||||
title: '',
|
|
||||||
placeholder: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
|
const popup = async (config: popupConfigType) => {
|
||||||
const popup = () => {
|
popupConfig.value = config
|
||||||
showMask.value = true
|
showMask.value = true
|
||||||
return new Promise((resolve: (text: string) => void) => { _resolve.value = resolve }).then((text: string) => {
|
const key = await new Promise((resolve: (key: unknown) => unknown) => {
|
||||||
showMask.value = false
|
_resolve.value = resolve
|
||||||
return text;
|
})
|
||||||
});
|
const text = inputValue.value
|
||||||
|
showMask.value = false;
|
||||||
|
nextTick(() => {
|
||||||
|
inputValue.value = ''
|
||||||
|
_resolve.value = undefined
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
text,
|
||||||
|
key
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defineExpose({ popup });
|
defineExpose({ popup });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
.popup-card {
|
||||||
|
width: 80%;
|
||||||
|
|
||||||
|
.popup-input {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-button-container {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
.popup-button-container-button {
|
||||||
|
&:not(:last-child) {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+43
-54
@@ -1,15 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<miao-drop-handler @on-virtual-directory="handleDropVDirectory" @on-files="handleDropFiles">
|
<miao-drop-handler @on-virtual-directory="handleDropVDirectory" @on-files="handleDropFiles">
|
||||||
<div class="miao-directory-item-container" ref="rootDomRef">
|
<div class="miao-directory-item-container" ref="rootDomRef">
|
||||||
<div
|
<div class="container-top" :style="{
|
||||||
class="container-top"
|
|
||||||
:style="{
|
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
index % 2 === 0 ? '#f8f8f8' : 'rgb(240 240 240)'
|
index % 2 === 0 ? '#f8f8f8' : 'rgb(240 240 240)'
|
||||||
}">
|
}">
|
||||||
<div
|
<div class="container-top-colorfulBar" :style="{ backgroundColor: props.color }"></div>
|
||||||
class="container-top-colorfulBar"
|
|
||||||
:style="{ backgroundColor: props.color }"></div>
|
|
||||||
<div class="container-top-breadcrumb">
|
<div class="container-top-breadcrumb">
|
||||||
<!-- <n-scrollbar x-scrollable> -->
|
<!-- <n-scrollbar x-scrollable> -->
|
||||||
<div class="container-top-breadcrumb-container">
|
<div class="container-top-breadcrumb-container">
|
||||||
@@ -19,10 +15,8 @@
|
|||||||
<CloudOutline />
|
<CloudOutline />
|
||||||
</n-icon>
|
</n-icon>
|
||||||
</n-breadcrumb-item>
|
</n-breadcrumb-item>
|
||||||
<n-breadcrumb-item
|
<n-breadcrumb-item v-for="dir in currentDirectory?.directoryArray"
|
||||||
v-for="dir in currentDirectory?.directoryArray"
|
@click="setCurrentDirectory(dir)" :clickable="true">
|
||||||
@click="setCurrentDirectory(dir)"
|
|
||||||
:clickable="true">
|
|
||||||
<div>{{ dir.name }}</div>
|
<div>{{ dir.name }}</div>
|
||||||
</n-breadcrumb-item>
|
</n-breadcrumb-item>
|
||||||
</n-breadcrumb>
|
</n-breadcrumb>
|
||||||
@@ -30,69 +24,44 @@
|
|||||||
<!-- </n-scrollbar> -->
|
<!-- </n-scrollbar> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="container-top-tools">
|
<div class="container-top-tools">
|
||||||
<n-icon
|
<n-icon class="container-top-tools-item" size="15" @click="handleBack">
|
||||||
class="container-top-tools-item"
|
|
||||||
size="15"
|
|
||||||
@click="handleBack">
|
|
||||||
<ChevronBackOutline />
|
<ChevronBackOutline />
|
||||||
</n-icon>
|
</n-icon>
|
||||||
<n-icon
|
<n-icon class="container-top-tools-item" size="14" @click="handleReload">
|
||||||
class="container-top-tools-item"
|
<ReloadOutline class="container-top-tools-item-reload" />
|
||||||
size="14"
|
|
||||||
@click="handleReload">
|
|
||||||
<ReloadOutline
|
|
||||||
class="container-top-tools-item-reload" />
|
|
||||||
</n-icon>
|
</n-icon>
|
||||||
<n-icon
|
<n-icon class="container-top-tools-item" size="20" @click="emit('exit')">
|
||||||
class="container-top-tools-item"
|
|
||||||
size="20"
|
|
||||||
@click="emit('exit')">
|
|
||||||
<CloseOutline />
|
<CloseOutline />
|
||||||
</n-icon>
|
</n-icon>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="container-items" :style="{
|
||||||
class="container-items"
|
|
||||||
:style="{
|
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
index % 2 === 0 ? '#f8f8f8' : 'rgb(240 240 240)'
|
index % 2 === 0 ? '#f8f8f8' : 'rgb(240 240 240)'
|
||||||
}">
|
}">
|
||||||
<n-scrollbar>
|
<n-scrollbar>
|
||||||
<transition-group name="dirItem">
|
<transition-group name="dirItem">
|
||||||
<miaoDirectoryItem
|
<miaoDirectoryItem v-for="dir in showData_directory" @click="setCurrentDirectory(dir)"
|
||||||
v-for="dir in showData_directory"
|
:item="dir" :key="dir.uid" :color="props.color" @delete="handleItemDelete(dir)"
|
||||||
@click="setCurrentDirectory(dir)"
|
|
||||||
:item="dir"
|
|
||||||
:key="dir.uid"
|
|
||||||
:color="props.color"
|
|
||||||
@delete="handleItemDelete(dir)"
|
|
||||||
@drag-start="handleItemDragStart" />
|
@drag-start="handleItemDragStart" />
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<transition-group name="dirItem">
|
<transition-group name="dirItem">
|
||||||
<miaoDirectoryItem
|
<miaoDirectoryItem v-for="file in showData_files" :item="file" :key="file.uid"
|
||||||
v-for="file in showData_files"
|
@click="openUrl(`${baseUrl}${api.get}${file.path}`)" @download="
|
||||||
:item="file"
|
|
||||||
:key="file.uid"
|
|
||||||
@click="openUrl(`${baseUrl}${api.get}${file.path}`)"
|
|
||||||
@download="
|
|
||||||
openUrl(`${baseUrl}${api.get}${file.path}`, {
|
openUrl(`${baseUrl}${api.get}${file.path}`, {
|
||||||
download: file.name
|
download: file.name
|
||||||
})
|
})
|
||||||
"
|
" @delete="handleItemDelete(file)" @drag-start="handleItemDragStart"
|
||||||
@delete="handleItemDelete(file)"
|
|
||||||
@drag-start="handleItemDragStart"
|
|
||||||
:color="props.color" />
|
:color="props.color" />
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</n-scrollbar>
|
</n-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="container-bottom" :style="{
|
||||||
class="container-bottom"
|
|
||||||
:style="{
|
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
index % 2 === 1 ? 'rgb(61 61 61)' : 'rgb(162 162 162)'
|
index % 2 === 1 ? 'rgb(61 61 61)' : 'rgb(162 162 162)'
|
||||||
}"></div>
|
}"></div>
|
||||||
<miao-mask v-model:show="showModel"></miao-mask>
|
<miao-mask v-model:show="showModel"></miao-mask>
|
||||||
<!-- <miao-popup-input ref="popupInput"></miao-popup-input> -->
|
<miao-popup-input ref="popupInput"></miao-popup-input>
|
||||||
</div>
|
</div>
|
||||||
</miao-drop-handler>
|
</miao-drop-handler>
|
||||||
</template>
|
</template>
|
||||||
@@ -105,7 +74,7 @@ import { computed, onMounted, ref } from 'vue'
|
|||||||
import Config from '@/config'
|
import Config from '@/config'
|
||||||
import miaoMask from '@/components/miaoMask.vue'
|
import miaoMask from '@/components/miaoMask.vue'
|
||||||
import miaoDirectoryItem from '@/components/miaoDirectory/miaoDirectoryItem.vue'
|
import miaoDirectoryItem from '@/components/miaoDirectory/miaoDirectoryItem.vue'
|
||||||
// import miaoPopupInput from "@/components/miaoPopupInput.vue";
|
import miaoPopupInput from "@/components/miaoPopupInput.vue";
|
||||||
import miaoDropHandler from '@/components/miaoDropHandler.vue'
|
import miaoDropHandler from '@/components/miaoDropHandler.vue'
|
||||||
import useMiaoFetchApi from '@/hooks/useMiaoFetchApi'
|
import useMiaoFetchApi from '@/hooks/useMiaoFetchApi'
|
||||||
import useDataBus from '@/hooks/useDataBus'
|
import useDataBus from '@/hooks/useDataBus'
|
||||||
@@ -146,6 +115,7 @@ const currentDirectory = computed(() => {
|
|||||||
return currentObjects.value[0]
|
return currentObjects.value[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 当前组件在views中的序号
|
||||||
const index = computed(() => {
|
const index = computed(() => {
|
||||||
for (let i in views) {
|
for (let i in views) {
|
||||||
if (views[i].uid === props.id) {
|
if (views[i].uid === props.id) {
|
||||||
@@ -249,10 +219,6 @@ const handleItemDragStart = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDropVDirectory = async (vDirs: VirtualDirectory[]) => {
|
|
||||||
setCurrentDirectory(vDirs[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDropFiles = async (files: File[]) => {
|
const handleDropFiles = async (files: File[]) => {
|
||||||
currentDirectory.value &&
|
currentDirectory.value &&
|
||||||
uploadQueue.push(files, currentDirectory.value, {
|
uploadQueue.push(files, currentDirectory.value, {
|
||||||
@@ -262,6 +228,30 @@ const handleDropFiles = async (files: File[]) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleDropVDirectory = async (vDirs: VirtualDirectory[]) => {
|
||||||
|
if (vDirs[0].parent === currentDirectory.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const popupRes = await popupInput.value.popup({
|
||||||
|
title: '重命名',
|
||||||
|
showInput: true,
|
||||||
|
inputProps: {
|
||||||
|
placeholder: '',
|
||||||
|
},
|
||||||
|
options: [{
|
||||||
|
label: '取消',
|
||||||
|
key: false,
|
||||||
|
type: 'error'
|
||||||
|
}, {
|
||||||
|
label: '确认',
|
||||||
|
key: true,
|
||||||
|
type: 'success'
|
||||||
|
},]
|
||||||
|
})
|
||||||
|
console.log({ popupRes })
|
||||||
|
// setCurrentDirectory(vDirs[0])
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await setCurrentDirectory(currentDirectory.value)
|
await setCurrentDirectory(currentDirectory.value)
|
||||||
})
|
})
|
||||||
@@ -404,5 +394,4 @@ $bottom-bar-height: 60px;
|
|||||||
// position: absolute;
|
// position: absolute;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }</style>
|
||||||
</style>
|
|
||||||
Reference in new issue
Block a user