![]()
@@ -117,6 +120,9 @@ import EdfsContextMenu from '@/components/dashboard/Edfs-context-menu/index.vue'
import markdownDrawer from './components/markdownDrawer.vue'
const dropdownMenu = computed(() => {
+ if (isRootMd.value) {
+ return fileDropdownMenu.filter(v => v.command === 'open')
+ }
return menuTarget.value
? fileDropdownMenu
: currentFolderId.value === 0
@@ -134,6 +140,10 @@ watch(
}
)
+const isRootMd = computed(
+ () => currentMenu.value?.type === floeType.file && currentFolderId.value === 0
+)
+
const dataList = ref
([])
const loading = ref(false)
async function loadData(id: number = 0) {
@@ -195,8 +205,9 @@ function onNewMarkdown() {
dataList.value.push(markdown)
onRename(markdown)
}
-
+const curCommand = ref('')
function onCommand(command: string, item: any) {
+ curCommand.value = command
switch (command) {
case 'delete':
onDelete(item)
@@ -223,6 +234,12 @@ function onVisibleChange(visible: boolean, currentElement: HTMLElement | null) {
menuTarget.value = currentElement
}
+const currentMenu = ref(null)
+
+function onBeforeContextmenu(item: any) {
+ currentMenu.value = item
+}
+
function onCrumb(item: any) {
const isLast = breadcrumbList.value[breadcrumbList.value.length - 1].id === item.id
if (isLast) return
@@ -251,19 +268,25 @@ function setInputRefs(el: any, id: number) {
const editFileName = ref('')
async function onSaveRename(item: any) {
- if (!item.isEdit) return
- item.name = editFileName.value
- await nextTick()
const find = findItem(item.id)
+ if (!find.isEdit) return
+ await nextTick()
find.isEdit = false
- await onSaveFile(item)
+ if (!editFileName.value.endsWith('.md')) {
+ editFileName.value += '.md'
+ }
+ if (find.name !== editFileName.value) {
+ find.name = editFileName.value
+ await onSaveFile(find)
+ }
+
editFileName.value = ''
}
async function onRename(item: any) {
if (!item) return
const find = findItem(item.id)
find.isEdit = true
- editFileName.value = item.name
+ editFileName.value = find.name
await nextTick()
editInputRefs.value[`editInputRef_${item.id}`].focus()
editInputRefs.value[`editInputRef_${item.id}`].select()
@@ -321,7 +344,7 @@ async function saveFile(isAdd: boolean, item: any) {
let res
if (isAdd) {
res = await createdFile({
- name: item.name + '.md',
+ name: item.name,
parentId: currentFolderId.value,
isDraft: 1,
path: getPath(),