fix FileManager

This commit is contained in:
jxxghp
2023-08-26 14:50:35 +08:00
parent e3df4000bb
commit f2b51107fa
4 changed files with 38 additions and 18 deletions
+18 -1
View File
@@ -2,7 +2,7 @@
import { useToast } from 'vue-toast-notification' import { useToast } from 'vue-toast-notification'
import { useTheme } from 'vuetify' import { useTheme } from 'vuetify'
import api from './api' import api from './api'
import type { User } from './api/types' import type { Setting, User } from './api/types'
import store from './store' import store from './store'
import avatar1 from '@images/avatars/avatar-1.png' import avatar1 from '@images/avatars/avatar-1.png'
@@ -47,6 +47,9 @@ const accountInfo = ref<User>({
avatar: avatar1, avatar: avatar1,
}) })
// 环境设置信息
const systemEnv = ref<Setting>()
// 调用API,加载当前用户数据 // 调用API,加载当前用户数据
async function loadAccountInfo() { async function loadAccountInfo() {
try { 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(() => { onMounted(() => {
loadAccountInfo() loadAccountInfo()
loadSystemSettings()
startSSEMessager() startSSEMessager()
}) })
// 提供给所有元素复用 // 提供给所有元素复用
provide('accountInfo', accountInfo) provide('accountInfo', accountInfo)
provide('systemEnv', systemEnv)
</script> </script>
<template> <template>
+2 -14
View File
@@ -833,20 +833,8 @@ export interface NotificationSwitch {
// 环境设置 // 环境设置
export interface Setting { export interface Setting {
// 媒体服务器 emby/jellyfin/plex // 下载目录
MEDIASERVER: string DOWNLOAD_PATH: 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
} }
// 自定义订阅 // 自定义订阅
+11
View File
@@ -117,6 +117,11 @@ function download(path: string) {
window.open(url, '_blank') window.open(url, '_blank')
} }
// 转移文件
function transfer(item: FileItem) {
// TODO 转移文件
}
// 监听path变化 // 监听path变化
watch( watch(
() => props.path, () => props.path,
@@ -170,6 +175,9 @@ onMounted(() => {
</template> </template>
<VListItemTitle v-text="item.name" /> <VListItemTitle v-text="item.name" />
<template #append> <template #append>
<IconBtn @click.stop="transfer(item)">
<VIcon icon="mdi-folder-arrow-right" />
</IconBtn>
<IconBtn @click.stop="deleteItem(item)"> <IconBtn @click.stop="deleteItem(item)">
<VIcon icon="mdi-delete-outline" /> <VIcon icon="mdi-delete-outline" />
</IconBtn> </IconBtn>
@@ -193,6 +201,9 @@ onMounted(() => {
<VListItemSubtitle> {{ formatBytes(item.size) }}</VListItemSubtitle> <VListItemSubtitle> {{ formatBytes(item.size) }}</VListItemSubtitle>
<template #append> <template #append>
<IconBtn @click.stop="transfer(item)">
<VIcon icon="mdi-folder-arrow-right" />
</IconBtn>
<IconBtn @click.stop="deleteItem(item)"> <IconBtn @click.stop="deleteItem(item)">
<VIcon icon="mdi-delete-outline" /> <VIcon icon="mdi-delete-outline" />
</IconBtn> </IconBtn>
+7 -3
View File
@@ -1,19 +1,23 @@
<script lang="ts" setup> <script lang="ts" setup>
import api from '@/api' import api from '@/api'
import type { Setting } from '@/api/types'
import FileBrowser from '@/components/FileBrowser.vue' import FileBrowser from '@/components/FileBrowser.vue'
const initPath = '/Users/jxxghp/Downloads/爱情生活 (2020)/'
const endpoints = { const endpoints = {
list: { url: '/filebrowser/list?path={path}', method: 'get' }, list: { url: '/filebrowser/list?path={path}', method: 'get' },
mkdir: { url: '/filebrowser/mkdir?path={path}', method: 'get' }, mkdir: { url: '/filebrowser/mkdir?path={path}', method: 'get' },
delete: { url: '/filebrowser/delete?path={path}', method: 'get' }, delete: { url: '/filebrowser/delete?path={path}', method: 'get' },
download: { url: '/filebrowser/download?path={path}', method: 'get' }, download: { url: '/filebrowser/download?path={path}', method: 'get' },
} }
// 读取下载目录
const systemEnv: Setting = inject('systemEnv') ?? {
DOWNLOAD_PATH: '/',
}
</script> </script>
<template> <template>
<div> <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> </div>
</template> </template>