|
|
@ -18,7 +18,7 @@ |
|
|
|
@visibleChange="onVisibleChange" |
|
|
|
@visibleChange="onVisibleChange" |
|
|
|
ref="contextMenuRef" |
|
|
|
ref="contextMenuRef" |
|
|
|
> |
|
|
|
> |
|
|
|
<div class="file-list" v-if="loading"> |
|
|
|
<div class="file-list"> |
|
|
|
<div v-for="item in dataList" :key="item.id" @click="onFileOpen(item)"> |
|
|
|
<div v-for="item in dataList" :key="item.id" @click="onFileOpen(item)"> |
|
|
|
<div class="item SourceClass" v-setItem="item"> |
|
|
|
<div class="item SourceClass" v-setItem="item"> |
|
|
|
<div class="file-header"> |
|
|
|
<div class="file-header"> |
|
|
@ -30,9 +30,15 @@ |
|
|
|
></Icon> |
|
|
|
></Icon> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="file-icon"> |
|
|
|
<div class="file-icon"> |
|
|
|
<!-- {{ !!item.isEdit }} --> |
|
|
|
<img |
|
|
|
|
|
|
|
:src=" |
|
|
|
<img :src="item.type === floeType.folder ? Folder : Document" /> |
|
|
|
item.type === floeType.folder |
|
|
|
|
|
|
|
? Folder |
|
|
|
|
|
|
|
: item.isDraft === 0 |
|
|
|
|
|
|
|
? Document |
|
|
|
|
|
|
|
: Document2 |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="file-name"> |
|
|
|
<div class="file-name"> |
|
|
|
<el-input |
|
|
|
<el-input |
|
|
@ -103,20 +109,29 @@ import { ArrowRight } from '@element-plus/icons-vue' |
|
|
|
import Folder from '@/assets/image/dashboard/file/folder.svg' |
|
|
|
import Folder from '@/assets/image/dashboard/file/folder.svg' |
|
|
|
import Upload from '@/assets/image/dashboard/file/upload.svg' |
|
|
|
import Upload from '@/assets/image/dashboard/file/upload.svg' |
|
|
|
import Document from '@/assets/image/dashboard/file/document.svg' |
|
|
|
import Document from '@/assets/image/dashboard/file/document.svg' |
|
|
|
|
|
|
|
import Document2 from '@/assets/image/dashboard/file/document2.svg' |
|
|
|
|
|
|
|
|
|
|
|
import { Icon } from '@/components/dashboard/Icon' |
|
|
|
import { Icon } from '@/components/dashboard/Icon' |
|
|
|
import EdfsContextMenu from '@/components/dashboard/Edfs-context-menu/index.vue' |
|
|
|
import EdfsContextMenu from '@/components/dashboard/Edfs-context-menu/index.vue' |
|
|
|
import markdownDrawer from './components/markdownDrawer.vue' |
|
|
|
import markdownDrawer from './components/markdownDrawer.vue' |
|
|
|
|
|
|
|
|
|
|
|
const dropdownMenu = computed(() => { |
|
|
|
const dropdownMenu = computed(() => { |
|
|
|
return menuTarget.value ? fileDropdownMenu : operationDropdownMenu |
|
|
|
return menuTarget.value |
|
|
|
|
|
|
|
? fileDropdownMenu |
|
|
|
|
|
|
|
: currentFolderId.value === 0 |
|
|
|
|
|
|
|
? operationDropdownMenu.filter(v => v.command === 'newFolder') |
|
|
|
|
|
|
|
: operationDropdownMenu.filter(v => v.command === 'newMarkdown') |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const message = useMessage() |
|
|
|
const message = useMessage() |
|
|
|
|
|
|
|
|
|
|
|
const currentId = ref(0) |
|
|
|
const currentFolderId = ref(0) |
|
|
|
watch(breadcrumbList.value, () => { |
|
|
|
watch( |
|
|
|
currentId.value = breadcrumbList.value[breadcrumbList.value.length - 1].id |
|
|
|
() => breadcrumbList.value.length, |
|
|
|
}) |
|
|
|
() => { |
|
|
|
|
|
|
|
currentFolderId.value = breadcrumbList.value[breadcrumbList.value.length - 1].id |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const dataList = ref<any>([]) |
|
|
|
const dataList = ref<any>([]) |
|
|
|
const loading = ref(false) |
|
|
|
const loading = ref(false) |
|
|
@ -125,17 +140,14 @@ async function loadData(id: number = 0) { |
|
|
|
const res = await getFileList({ |
|
|
|
const res = await getFileList({ |
|
|
|
parentId: id, |
|
|
|
parentId: id, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
loading.value = false |
|
|
|
if (isResError(res)) return |
|
|
|
if (isResError(res)) return |
|
|
|
dataList.value = res.data.map((item: any) => ({ |
|
|
|
dataList.value = res.data |
|
|
|
...item, |
|
|
|
|
|
|
|
isEdit: false, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
loading.value = true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function onDelete(item: any) { |
|
|
|
async function onDelete(item: any) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
let res |
|
|
|
let res: any |
|
|
|
await message.delConfirm() |
|
|
|
await message.delConfirm() |
|
|
|
switch (item.type) { |
|
|
|
switch (item.type) { |
|
|
|
case floeType.folder: |
|
|
|
case floeType.folder: |
|
|
@ -147,7 +159,7 @@ async function onDelete(item: any) { |
|
|
|
} |
|
|
|
} |
|
|
|
if (isResError(res)) return |
|
|
|
if (isResError(res)) return |
|
|
|
message.success('删除成功') |
|
|
|
message.success('删除成功') |
|
|
|
loadData(currentId.value) |
|
|
|
loadData(currentFolderId.value) |
|
|
|
} catch (error) {} |
|
|
|
} catch (error) {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -158,7 +170,7 @@ function onFile(e: any) { |
|
|
|
|
|
|
|
|
|
|
|
function onNewFolder() { |
|
|
|
function onNewFolder() { |
|
|
|
const folder = { |
|
|
|
const folder = { |
|
|
|
name: '新建文件夹', |
|
|
|
name: '未命名文件夹', |
|
|
|
type: floeType.folder, |
|
|
|
type: floeType.folder, |
|
|
|
isEdit: true, |
|
|
|
isEdit: true, |
|
|
|
} |
|
|
|
} |
|
|
@ -168,7 +180,7 @@ function onNewFolder() { |
|
|
|
|
|
|
|
|
|
|
|
function onNewMarkdown() { |
|
|
|
function onNewMarkdown() { |
|
|
|
const markdown = { |
|
|
|
const markdown = { |
|
|
|
name: '新建文档', |
|
|
|
name: '未命名文档', |
|
|
|
type: floeType.file, |
|
|
|
type: floeType.file, |
|
|
|
isEdit: true, |
|
|
|
isEdit: true, |
|
|
|
} |
|
|
|
} |
|
|
@ -234,23 +246,26 @@ async function onSaveRename(item: any) { |
|
|
|
if (!item.isEdit) return |
|
|
|
if (!item.isEdit) return |
|
|
|
item.name = editFileName.value |
|
|
|
item.name = editFileName.value |
|
|
|
await nextTick() |
|
|
|
await nextTick() |
|
|
|
item.isEdit = false |
|
|
|
const find = findItem(item.id) |
|
|
|
await nextTick() |
|
|
|
find.isEdit = false |
|
|
|
await onSaveFile(item) |
|
|
|
await onSaveFile(item) |
|
|
|
editFileName.value = '' |
|
|
|
editFileName.value = '' |
|
|
|
} |
|
|
|
} |
|
|
|
async function onRename(item: any) { |
|
|
|
async function onRename(item: any) { |
|
|
|
if (!item) return |
|
|
|
if (!item) return |
|
|
|
item.isEdit = true |
|
|
|
const find = findItem(item.id) |
|
|
|
await nextTick() |
|
|
|
find.isEdit = true |
|
|
|
editFileName.value = item.name |
|
|
|
editFileName.value = item.name |
|
|
|
await nextTick() |
|
|
|
await nextTick() |
|
|
|
editInputRefs.value[`editInputRef_${item.id}`].focus() |
|
|
|
editInputRefs.value[`editInputRef_${item.id}`].focus() |
|
|
|
editInputRefs.value[`editInputRef_${item.id}`].select() |
|
|
|
editInputRefs.value[`editInputRef_${item.id}`].select() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const findItem = (id: number) => dataList.value.find((v: any) => v.id === id) |
|
|
|
|
|
|
|
|
|
|
|
async function onSaveFile(item: any) { |
|
|
|
async function onSaveFile(item: any) { |
|
|
|
const isAdd = !item.id |
|
|
|
const isAdd = !item.id |
|
|
|
|
|
|
|
loading.value = true |
|
|
|
switch (item.type) { |
|
|
|
switch (item.type) { |
|
|
|
case floeType.folder: |
|
|
|
case floeType.folder: |
|
|
|
await saveFolder(isAdd, item) |
|
|
|
await saveFolder(isAdd, item) |
|
|
@ -260,21 +275,30 @@ async function onSaveFile(item: any) { |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
loadData(currentId.value) |
|
|
|
loadData(currentFolderId.value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getPath() { |
|
|
|
|
|
|
|
return currentFolderId.value === 0 |
|
|
|
|
|
|
|
? '' |
|
|
|
|
|
|
|
: breadcrumbList.value[breadcrumbList.value.length - 1].path |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function saveFolder(isAdd: boolean, item: any) { |
|
|
|
async function saveFolder(isAdd: boolean, item: any) { |
|
|
|
|
|
|
|
getPath() |
|
|
|
let res |
|
|
|
let res |
|
|
|
if (isAdd) { |
|
|
|
if (isAdd) { |
|
|
|
res = await createFolder({ |
|
|
|
res = await createFolder({ |
|
|
|
name: item.name, |
|
|
|
name: item.name, |
|
|
|
parentId: currentId.value, |
|
|
|
parentId: currentFolderId.value, |
|
|
|
|
|
|
|
path: getPath(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
res = await updateFolder({ |
|
|
|
res = await updateFolder({ |
|
|
|
id: item.id, |
|
|
|
id: item.id, |
|
|
|
name: item.name, |
|
|
|
name: item.name, |
|
|
|
parentId: currentId.value, |
|
|
|
parentId: currentFolderId.value, |
|
|
|
|
|
|
|
path: getPath(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
if (isResError(res)) return |
|
|
|
if (isResError(res)) return |
|
|
@ -284,34 +308,56 @@ async function saveFile(isAdd: boolean, item: any) { |
|
|
|
if (isAdd) { |
|
|
|
if (isAdd) { |
|
|
|
res = await createdFile({ |
|
|
|
res = await createdFile({ |
|
|
|
name: item.name + '.md', |
|
|
|
name: item.name + '.md', |
|
|
|
parentId: currentId.value, |
|
|
|
parentId: currentFolderId.value, |
|
|
|
|
|
|
|
isDraft: 1, |
|
|
|
|
|
|
|
path: getPath(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
res = await updateFile({ |
|
|
|
res = await updateFile({ |
|
|
|
id: item.id, |
|
|
|
id: item.id, |
|
|
|
name: item.name, |
|
|
|
name: item.name, |
|
|
|
parentId: currentId.value, |
|
|
|
parentId: currentFolderId.value, |
|
|
|
|
|
|
|
path: getPath(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
if (isResError(res)) return |
|
|
|
if (isResError(res)) return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fullscreenLoading = ref() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function openFullScreen() { |
|
|
|
|
|
|
|
fullscreenLoading.value = ElLoading.service({ |
|
|
|
|
|
|
|
lock: true, |
|
|
|
|
|
|
|
text: '数据加载中请稍等...', |
|
|
|
|
|
|
|
target: document.querySelector('.firmware-management-wrap') as HTMLElement, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
watch(loading, val => { |
|
|
|
|
|
|
|
if (val) { |
|
|
|
|
|
|
|
openFullScreen() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
fullscreenLoading.value?.close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// markdown 操作 |
|
|
|
// markdown 操作 |
|
|
|
const curMarkdown = ref() as Ref<ContentType> |
|
|
|
const curMarkdown = ref() as Ref<ContentType & { fileName: string }> |
|
|
|
|
|
|
|
const curMdId = ref() |
|
|
|
|
|
|
|
|
|
|
|
const isShowMdDrawer = ref(false) |
|
|
|
const isShowMdDrawer = ref(false) |
|
|
|
async function onOpenMarkdownDrawer(id: number) { |
|
|
|
async function onOpenMarkdownDrawer(id: number) { |
|
|
|
|
|
|
|
curMdId.value = id |
|
|
|
const res = await getMarkdown({ folderId: id }) |
|
|
|
const res = await getMarkdown({ folderId: id }) |
|
|
|
if (isResError(res)) return |
|
|
|
if (isResError(res)) return |
|
|
|
curMarkdown.value = res?.data |
|
|
|
curMarkdown.value = Object.assign({}, res.data, { fileName: findItem(id).name }) |
|
|
|
|
|
|
|
|
|
|
|
isShowMdDrawer.value = true |
|
|
|
isShowMdDrawer.value = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function onSaveMd(isDraft: 0 | 1, data: string) { |
|
|
|
async function onSaveMd(isDraft: 0 | 1, data: string) { |
|
|
|
const res = await updateMarkdown({ |
|
|
|
const res = await updateMarkdown({ |
|
|
|
content: data, |
|
|
|
content: data, |
|
|
|
folderId: currentId.value, |
|
|
|
folderId: curMdId.value, |
|
|
|
id: curMarkdown.value?.id, |
|
|
|
|
|
|
|
isDraft, |
|
|
|
isDraft, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -319,7 +365,7 @@ async function onSaveMd(isDraft: 0 | 1, data: string) { |
|
|
|
message.success(isDraft === 1 ? '保存成功' : '发布成功') |
|
|
|
message.success(isDraft === 1 ? '保存成功' : '发布成功') |
|
|
|
isShowMdDrawer.value = false |
|
|
|
isShowMdDrawer.value = false |
|
|
|
curMarkdown.value = null as any |
|
|
|
curMarkdown.value = null as any |
|
|
|
loadData(currentId.value) |
|
|
|
loadData(currentFolderId.value) |
|
|
|
} |
|
|
|
} |
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
|
loadData() |
|
|
|
loadData() |
|
|
|