add DirectoryTreeInput

This commit is contained in:
jxxghp
2024-05-31 15:06:58 +08:00
parent 9dab691649
commit 9335f79c30
5 changed files with 79 additions and 24 deletions
+19 -18
View File
@@ -8,32 +8,33 @@ const api = axios.create({
}) })
// 添加请求拦截器 // 添加请求拦截器
api.interceptors.request.use((config) => { api.interceptors.request.use(config => {
// 在请求头中添加token // 在请求头中添加token
const token = store.state.auth.token const token = store.state.auth.token
if (token) if (token) config.headers.Authorization = `Bearer ${token}`
config.headers.Authorization = `Bearer ${token}`
return config return config
}) })
// 添加响应拦截器 // 添加响应拦截器
api.interceptors.response.use((response) => { api.interceptors.response.use(
return response.data response => {
}, (error) => { return response.data
if (!error.response) { },
// 请求超时 error => {
return Promise.reject(error) if (!error.response) {
} // 请求超时
else if (error.response.status === 403) { return Promise.reject(new Error(error))
// 清除登录状态信息 } else if (error.response.status === 403) {
store.dispatch('auth/clearToken') // 清除登录状态信息
store.dispatch('auth/clearToken')
// token验证失败,跳转到登录页面 // token验证失败,跳转到登录页面
router.push('/login') router.push('/login')
} }
return Promise.reject(error) return Promise.reject(new Error(error))
}) },
)
export default api export default api
+1 -1
View File
@@ -736,7 +736,7 @@ export interface EndPoints {
// 文件浏览项目 // 文件浏览项目
export interface FileItem { export interface FileItem {
// 类型 // 类型 dir/file
type: string type: string
// 文件名 // 文件名
name: string name: string
@@ -0,0 +1,57 @@
<script setup lang="ts">
import api from '@/api'
import { VTreeview } from 'vuetify/labs/VTreeview'
// 激活的目录
const activedDirs = ref<string[]>([])
// 打开的目录
const openedDirs = ref<string[]>([])
// 目录列表
const items = ref([
{
name: '/',
path: '/',
children: [],
},
])
const itemList = computed(() => {
return [
{
name: '/',
path: '/',
children: items.value,
},
]
})
// 拉取子目录
async function fetchDirs(item: any) {
return api
.get('/filebrowser/listdir?path=' + item.path)
.then(res => res)
.then((data: any) => {
item.children.push(...data)
})
.catch(err => console.warn(err))
}
</script>
<template>
<VTreeview
v-model:activated="activedDirs"
v-model:opened="openedDirs"
:items="items"
:load-children="fetchDirs"
density="compact"
item-key="path"
item-title="name"
item-value="path"
activatable
open-on-click
transition
>
</VTreeview>
</template>
+2
View File
@@ -17,6 +17,7 @@ import '@styles/styles.scss'
import 'vue-toast-notification/dist/theme-bootstrap.css' import 'vue-toast-notification/dist/theme-bootstrap.css'
import { PerfectScrollbarPlugin } from 'vue3-perfect-scrollbar' import { PerfectScrollbarPlugin } from 'vue3-perfect-scrollbar'
import 'vue3-perfect-scrollbar/style.css' import 'vue3-perfect-scrollbar/style.css'
import { VTreeview } from 'vuetify/labs/VTreeview'
import DialogCloseBtn from '@/@core/components/DialogCloseBtn.vue' import DialogCloseBtn from '@/@core/components/DialogCloseBtn.vue'
import MediaCard from './components/cards/MediaCard.vue' import MediaCard from './components/cards/MediaCard.vue'
import PosterCard from './components/cards/PosterCard.vue' import PosterCard from './components/cards/PosterCard.vue'
@@ -48,6 +49,7 @@ app
.component('VMediaInfoCard', MediaInfoCard) .component('VMediaInfoCard', MediaInfoCard)
.component('VTorrentCard', TorrentCard) .component('VTorrentCard', TorrentCard)
.component('VMediaIdSelector', MediaIdSelector) .component('VMediaIdSelector', MediaIdSelector)
.component('VTreeview', VTreeview)
// 注册插件 // 注册插件
app app
-5
View File
@@ -5853,11 +5853,6 @@ psl@^1.1.28:
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==
pull-refresh-vue3@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/pull-refresh-vue3/-/pull-refresh-vue3-0.3.1.tgz#e75ffad5d71e30a85b5338f2beca9fc8a1e01432"
integrity sha512-DTcosG4LT3dGF/amzMP3YOwQ11x1taxQU3ChGx2SDCT5LMmyNpUD7pb2FAZkB/QEHVSpUTIfCcanfXANkYOXjw==
pump@^3.0.0: pump@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"