mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-10 17:42:50 +08:00
fix FileManager
This commit is contained in:
19
src/App.vue
19
src/App.vue
@@ -2,7 +2,7 @@
|
||||
import { useToast } from 'vue-toast-notification'
|
||||
import { useTheme } from 'vuetify'
|
||||
import api from './api'
|
||||
import type { User } from './api/types'
|
||||
import type { Setting, User } from './api/types'
|
||||
import store from './store'
|
||||
import avatar1 from '@images/avatars/avatar-1.png'
|
||||
|
||||
@@ -47,6 +47,9 @@ const accountInfo = ref<User>({
|
||||
avatar: avatar1,
|
||||
})
|
||||
|
||||
// 环境设置信息
|
||||
const systemEnv = ref<Setting>()
|
||||
|
||||
// 调用API,加载当前用户数据
|
||||
async function loadAccountInfo() {
|
||||
try {
|
||||
@@ -61,14 +64,28 @@ async function loadAccountInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
// 调用API,加载当前系统环境设置
|
||||
async function loadSystemSettings() {
|
||||
try {
|
||||
const result: { [key: string]: any } = await api.get('system/env')
|
||||
if (result.success)
|
||||
systemEnv.value = result.data
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载时,加载当前用户数据
|
||||
onMounted(() => {
|
||||
loadAccountInfo()
|
||||
loadSystemSettings()
|
||||
startSSEMessager()
|
||||
})
|
||||
|
||||
// 提供给所有元素复用
|
||||
provide('accountInfo', accountInfo)
|
||||
provide('systemEnv', systemEnv)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -833,20 +833,8 @@ export interface NotificationSwitch {
|
||||
|
||||
// 环境设置
|
||||
export interface Setting {
|
||||
// 媒体服务器 emby/jellyfin/plex
|
||||
MEDIASERVER: string
|
||||
// EMBY服务器地址,IP:PORT
|
||||
EMBY_HOST: string
|
||||
// EMBY Api Key
|
||||
EMBY_API_KEY: string
|
||||
// Jellyfin服务器地址,IP:PORT
|
||||
JELLYFIN_HOST: string
|
||||
// Jellyfin Api Key
|
||||
JELLYFIN_API_KEY: string
|
||||
// Plex服务器地址,IP:PORT
|
||||
PLEX_HOST: string
|
||||
// Plex Token
|
||||
PLEX_TOKEN: string
|
||||
// 下载目录
|
||||
DOWNLOAD_PATH: string
|
||||
}
|
||||
|
||||
// 自定义订阅
|
||||
|
||||
@@ -117,6 +117,11 @@ function download(path: string) {
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
// 转移文件
|
||||
function transfer(item: FileItem) {
|
||||
// TODO 转移文件
|
||||
}
|
||||
|
||||
// 监听path变化
|
||||
watch(
|
||||
() => props.path,
|
||||
@@ -170,6 +175,9 @@ onMounted(() => {
|
||||
</template>
|
||||
<VListItemTitle v-text="item.name" />
|
||||
<template #append>
|
||||
<IconBtn @click.stop="transfer(item)">
|
||||
<VIcon icon="mdi-folder-arrow-right" />
|
||||
</IconBtn>
|
||||
<IconBtn @click.stop="deleteItem(item)">
|
||||
<VIcon icon="mdi-delete-outline" />
|
||||
</IconBtn>
|
||||
@@ -193,6 +201,9 @@ onMounted(() => {
|
||||
<VListItemSubtitle> {{ formatBytes(item.size) }}</VListItemSubtitle>
|
||||
|
||||
<template #append>
|
||||
<IconBtn @click.stop="transfer(item)">
|
||||
<VIcon icon="mdi-folder-arrow-right" />
|
||||
</IconBtn>
|
||||
<IconBtn @click.stop="deleteItem(item)">
|
||||
<VIcon icon="mdi-delete-outline" />
|
||||
</IconBtn>
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
<script lang="ts" setup>
|
||||
import api from '@/api'
|
||||
import type { Setting } from '@/api/types'
|
||||
import FileBrowser from '@/components/FileBrowser.vue'
|
||||
|
||||
const initPath = '/Users/jxxghp/Downloads/爱情生活 (2020)/'
|
||||
|
||||
const endpoints = {
|
||||
list: { url: '/filebrowser/list?path={path}', method: 'get' },
|
||||
mkdir: { url: '/filebrowser/mkdir?path={path}', method: 'get' },
|
||||
delete: { url: '/filebrowser/delete?path={path}', method: 'get' },
|
||||
download: { url: '/filebrowser/download?path={path}', method: 'get' },
|
||||
}
|
||||
|
||||
// 读取下载目录
|
||||
const systemEnv: Setting = inject('systemEnv') ?? {
|
||||
DOWNLOAD_PATH: '/',
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<FileBrowser storages="local" :tree="false" :path="initPath" :endpoints="endpoints" :axios="api" />
|
||||
<FileBrowser storages="local" :tree="false" :path="systemEnv.DOWNLOAD_PATH" :endpoints="endpoints" :axios="api" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user