Skip to content

Commit

Permalink
fix:修复文件列表显示的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
anguoo committed Jan 30, 2024
1 parent b8add6e commit 70c0da9
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 238 deletions.
10 changes: 5 additions & 5 deletions src/views/personal/personal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
import Nav from '@/components/navigation.vue'
import Search from '@/components/search.vue'
import Popup from '@/views/personal/popup.vue'
import { getFilesUrl } from './utils'
import { getPrivateFiles, getFatherIdFromHerf } from './utils'
import { useStore } from '@/store/index';
import type { Ref } from 'vue'
import { ref, onMounted, computed } from 'vue'
Expand All @@ -162,6 +162,7 @@ const isFilePopup = ref(false)
const isContexmenuPopup = ref(false)
const path = ref('')
const userId = ref('')
const fatherId = ref('')
const filesList = ref<any>([])
const popupLeft = ref(0)
const popupRight = ref(0)
Expand All @@ -172,14 +173,13 @@ const contentsMaginLeft = ref(140)
onMounted(() => {
userId.value = store.getUserId()
filesList.value = getFilesUrl(userId.value)
console.log(filesList.value);
fatherId.value = getFatherIdFromHerf() || userId.value
filesList.value = getPrivateFiles(fatherId.value)
})
const updateFilesList = (update: boolean) => {
if (update) {
filesList.value = getFilesUrl(userId.value)
filesList.value = getPrivateFiles(fatherId.value)
}
}
Expand Down
55 changes: 38 additions & 17 deletions src/views/personal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,50 @@ import { useStore } from '@/store/index'
import { post } from '@/utils/request'
import { ref } from 'vue'

//创建文件接口
export interface createFiles {
file: {
name: string,
type: number, //Type_null = 0; Type_audio = 1; Type_video = 2; Type_photo = 3; Type_word = 4; Type_ppt = 5; Type_zip = 6; Type_excel = 7; Type_pdf = 8; Type_folder = 9; Type_file = 10; Type_code = 11; Type_unknown = 12;
type: number, //1:音频 2:视频 3:图片 4:文档 5:幻灯片 6:压缩包 7:表格 8:pdf 9:文件夹 10:文件 11:代码 12:其他
fatherId: string,
spaceSize: number,
md5?: string, //创建文件夹时不填,创建文件时要填
isDel?: number, //(默认为1)1:未删除 2:软删除 3:彻底删除
}
}

const store = useStore()
export const getFatherIdFromHerf = () => {
if (store.fatherId === "") {
const urls = window.location.href.split('/')
const fatherId = urls[urls.length - 1]
store.setFatherId(fatherId)
return fatherId
//搜索、查询用户文件列表接口
export interface getPrivateFiles {
//搜索填
searchOptions?: {
allFieldsKey?: string,
multiFieldsKey: {
name?: string,
id?: string,
}
},
filterOptions: {
onlyFatherId: string,
onlyFileType?: number
},
paginationOptions?: {
limit?: number,
lastToken?: string,
backward?: boolean,
offset?: number,
}
}

export const getFilesUrl = (userId: string) => {
const filesList = ref<any>([])
post('/content/getFileList', {
//搜索、查询用户文件列表api
export const getPrivateFiles = (id: string) => {
const data = ref<getPrivateFiles>({
filterOptions: {
onlyUserId: userId,
onlyDocumentType: 1,
onlyFatherId: id,
},
paginationOptions: {
page: 1,
limit: 40
limit: 40,
}
})
const filesList = ref<any>([])
post('/content/getPrivateFiles', data.value)
.then((res: any) => {
for (let i = 0; i < res.files.length; i ++) {
filesList.value.push(res.files[i])
Expand All @@ -43,6 +54,16 @@ export const getFilesUrl = (userId: string) => {
return filesList.value
}

const store = useStore()
export const getFatherIdFromHerf = () => {
if (store.fatherId === "") {
const urls = window.location.href.split('/')
const fatherId = urls[urls.length - 1]
store.setFatherId(fatherId)
return fatherId
}
}

export const getTypeFromSuffix = (suffix: string) => {
const type = suffix.split('.').pop()
switch (type) {
Expand Down
Loading

0 comments on commit 70c0da9

Please sign in to comment.