This commit is contained in:
jxxghp
2024-06-19 13:02:24 +08:00
parent 8d064a2165
commit f793654bd8
7 changed files with 159 additions and 27 deletions
+33 -1
View File
@@ -5,6 +5,7 @@ import FileToolbar from './filebrowser/FileToolbar.vue'
import type { EndPoints, FileItem } from '@/api/types'
import api from '@/api'
import AliyunAuthDialog from './dialog/AliyunAuthDialog.vue'
import U115AuthDialog from './dialog/U115AuthDialog.vue'
import { isNullOrEmptyObject } from '@/@core/utils'
// 输入参数
@@ -12,6 +13,7 @@ const props = defineProps({
storages: String,
path: String,
fileid: String,
pickcode: String,
fileidstack: Array as PropType<string[]>,
tree: Boolean,
endpoints: Object as PropType<EndPoints>,
@@ -77,6 +79,10 @@ const sort = ref('name')
const aliyunAuthDialog = ref(false)
// 阿里云盘用户信息
const aliyunUserInfo = ref<{ [key: string]: any }>({})
// 115网盘认证对话框
const u115AuthDialog = ref(false)
// 115网盘用户信息
const u115UserInfo = ref<{ [key: string]: any }>({})
// 计算属性
const storagesArray = computed(() => {
@@ -90,7 +96,7 @@ function loadingChanged(loading: number) {
else if (loading > 0) loading--
}
// 查询阿里云token
// 查询阿里云
async function loadAliyunUserInfo() {
try {
const result: { [key: string]: any } = await api.get('aliyun/userinfo')
@@ -102,6 +108,18 @@ async function loadAliyunUserInfo() {
}
}
// 查询115
async function loadU115UserInfo() {
try {
const result: { [key: string]: any } = await api.get('u115/storage')
if (result.success) {
u115UserInfo.value = result
}
} catch (error) {
console.log(error)
}
}
// 存储切换
async function storageChanged(storage: string) {
if (storage == 'aliyun') {
@@ -110,6 +128,12 @@ async function storageChanged(storage: string) {
aliyunAuthDialog.value = true
return
}
} else if (storage == 'u115') {
await loadU115UserInfo()
if (isNullOrEmptyObject(u115UserInfo.value)) {
u115AuthDialog.value = true
return
}
}
activeStorage.value = storage
emit('pathchanged', { path: '/', fileid: 'root' })
@@ -131,6 +155,12 @@ function aliyunAuthDone() {
aliyunAuthDialog.value = false
activeStorage.value = 'aliyun'
}
// u115认证完成
function u115AuthDone() {
u115AuthDialog.value = false
activeStorage.value = 'u115'
}
</script>
<template>
@@ -152,6 +182,7 @@ function aliyunAuthDone() {
<FileList
:path="path"
:fileid="fileid"
:pickcode="pickcode"
:storage="activeStorage"
:icons="fileIcons"
:endpoints="endpoints"
@@ -172,4 +203,5 @@ function aliyunAuthDone() {
@close="aliyunAuthDialog = false"
@done="aliyunAuthDone"
/>
<U115AuthDialog v-if="u115AuthDialog" v-model="u115AuthDialog" @close="u115AuthDialog = false" @done="u115AuthDone" />
</template>