From 14c2503b0d36bac4636af3b5261886050cc07a0c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 17 Jun 2024 19:46:21 +0800 Subject: [PATCH] add aliyun --- src/api/types.ts | 4 + src/components/FileBrowser.vue | 52 ++++++++- src/components/dialog/AliyunAuthDialog.vue | 126 +++++++++++++++++++++ src/components/filebrowser/FileList.vue | 17 ++- src/components/filebrowser/FileToolbar.vue | 48 +++----- src/views/reorganize/FileBrowserView.vue | 16 +-- 6 files changed, 209 insertions(+), 54 deletions(-) create mode 100644 src/components/dialog/AliyunAuthDialog.vue diff --git a/src/api/types.ts b/src/api/types.ts index 79d9de50..5a43aae5 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -757,6 +757,10 @@ export interface FileItem { children: FileItem[] // 文件创建时间 modify_time: number + // 文件ID + fileid: string + // 上级文件ID + parent_fileid: string } // 媒体服务器播放条目 diff --git a/src/components/FileBrowser.vue b/src/components/FileBrowser.vue index e4c7e9a3..44166d85 100644 --- a/src/components/FileBrowser.vue +++ b/src/components/FileBrowser.vue @@ -4,6 +4,9 @@ import axios from 'axios' import FileList from './filebrowser/FileList.vue' import FileToolbar from './filebrowser/FileToolbar.vue' import type { EndPoints } from '@/api/types' +import api from '@/api' +import AliyunAuthDialog from './dialog/AliyunAuthDialog.vue' +import { isNullOrEmptyObject } from '@/@core/utils' // 输入参数 const props = defineProps({ @@ -25,6 +28,11 @@ const availableStorages = [ code: 'local', icon: 'mdi-folder-multiple-outline', }, + { + name: '阿里云盘', + code: 'aliyun', + icon: 'mdi-cloud-outline', + }, ] const fileIcons = { @@ -59,6 +67,10 @@ const refreshPending = ref(false) const sort = ref('name') // axios实例 const axiosInstance = ref() +// 阿里云盘认证对话框 +const aliyunAuthDialog = ref(false) +// 阿里云盘认证参数 +const aliyunParams = ref<{ [key: string]: any }>({}) // 计算属性 const storagesArray = computed(() => { @@ -68,13 +80,31 @@ const storagesArray = computed(() => { // 方法 function loadingChanged(loading: number) { - if (loading) - loading++ - else if (loading > 0) - loading-- + if (loading) loading++ + else if (loading > 0) loading-- } -function storageChanged(storage: string) { +// 查询阿里云token +async function loadAliyunParams() { + try { + const result: { [key: string]: any } = await api.get('system/setting/UserAliyunParams') + if (result.success) { + aliyunParams.value = result.data?.value + } + } catch (error) { + console.log(error) + } +} + +// 存储切换 +async function storageChanged(storage: string) { + if (storage == 'aliyun') { + await loadAliyunParams() + if (isNullOrEmptyObject(aliyunParams.value)) { + aliyunAuthDialog.value = true + return + } + } activeStorage.value = storage } @@ -89,6 +119,12 @@ function sortChanged(s: string) { refreshPending.value = true } +// aliyun认证完成 +function aliyunAuthDone() { + aliyunAuthDialog.value = false + activeStorage.value = 'aliyun' +} + // 初始化 onMounted(() => { activeStorage.value = props.storage ?? 'local' @@ -126,4 +162,10 @@ onMounted(() => { /> + diff --git a/src/components/dialog/AliyunAuthDialog.vue b/src/components/dialog/AliyunAuthDialog.vue new file mode 100644 index 00000000..f1f5d623 --- /dev/null +++ b/src/components/dialog/AliyunAuthDialog.vue @@ -0,0 +1,126 @@ + + + - +