<template>
    <div>
        <div class="flex items-center">
            <div class="flex-shrink-0 flex items-center mr-4">
                <el-button :icon="Back" @click="back" circle :disabled="paths.length == 0" />
                <el-button :icon="Refresh" circle @click="search" />
            </div>
            <div
                v-show="!searchableStatus"
                tabindex="0"
                @click="searchableStatus = true"
                :class="globalStore.$state.themeConfig.theme === 'light' && 'bg-white'"
                class="address-bar shadow-md rounded-md px-4 py-2 flex items-center flex-grow"
            >
                <div ref="pathRef" class="w-full">
                    <span ref="breadCrumbRef" class="w-full flex items-center">
                        <span class="root mr-2">
                            <el-link @click.stop="jump('/')">
                                <el-icon :size="20"><HomeFilled /></el-icon>
                            </el-link>
                        </span>
                        <span v-for="path in paths" :key="path.url" class="inline-flex items-center">
                            <span class="mr-2 arrow">></span>
                            <el-link class="path-segment cursor-pointer mr-2 pathname" @click.stop="jump(path.url)">
                                {{ path.name }}
                            </el-link>
                        </span>
                    </span>
                </div>
            </div>
            <el-input
                ref="searchableInputRef"
                v-show="searchableStatus"
                v-model="searchablePath"
                @blur="searchableInputBlur"
                class="px-4 py-2 border rounded-md shadow-md"
                @keyup.enter="
                    jump(searchablePath);
                    searchableStatus = false;
                "
            />
        </div>
        <LayoutContent :title="$t('file.file')" v-loading="loading">
            <template #prompt>
                <el-alert type="info" :closable="false">
                    <template #default>
                        <span><span v-html="$t('file.fileHeper')"></span></span>
                    </template>
                </el-alert>
            </template>
            <template #toolbar>
                <div class="btn-container">
                    <div class="left-section">
                        <el-dropdown @command="handleCreate">
                            <el-button type="primary">
                                {{ $t('commons.button.create') }}
                                <el-icon><arrow-down /></el-icon>
                            </el-button>
                            <template #dropdown>
                                <el-dropdown-menu>
                                    <el-dropdown-item command="dir">
                                        <svg-icon iconName="p-file-folder"></svg-icon>
                                        {{ $t('file.dir') }}
                                    </el-dropdown-item>
                                    <el-dropdown-item command="file">
                                        <svg-icon iconName="p-file-normal"></svg-icon>
                                        {{ $t('file.file') }}
                                    </el-dropdown-item>
                                </el-dropdown-menu>
                            </template>
                        </el-dropdown>
                        <el-button-group>
                            <el-button plain @click="openUpload">{{ $t('file.upload') }}</el-button>
                            <el-button plain @click="openWget">{{ $t('file.remoteFile') }}</el-button>
                            <el-button plain @click="openMove('copy')" :disabled="selects.length === 0">
                                {{ $t('file.copy') }}
                            </el-button>
                            <el-button plain @click="openMove('cut')" :disabled="selects.length === 0">
                                {{ $t('file.move') }}
                            </el-button>
                            <el-button plain @click="openCompress(selects)" :disabled="selects.length === 0">
                                {{ $t('file.compress') }}
                            </el-button>
                            <el-button plain @click="openBatchRole(selects)" :disabled="selects.length === 0">
                                {{ $t('file.role') }}
                            </el-button>
                            <el-button plain @click="batchDelFiles" :disabled="selects.length === 0">
                                {{ $t('commons.button.delete') }}
                            </el-button>
                        </el-button-group>

                        <el-button class="btn" @click="toTerminal">
                            {{ $t('menu.terminal') }}
                        </el-button>

                        <el-button-group class="copy-button" v-if="moveOpen">
                            <el-tooltip class="box-item" effect="dark" :content="$t('file.paste')" placement="bottom">
                                <el-button plain @click="openPaste">
                                    {{ $t('file.paste') }}({{ fileMove.count }})
                                </el-button>
                            </el-tooltip>
                            <el-tooltip class="box-item" effect="dark" :content="$t('file.cancel')" placement="bottom">
                                <el-button plain class="close" @click="closeMove">
                                    <el-icon class="close-icon"><Close /></el-icon>
                                </el-button>
                            </el-tooltip>
                        </el-button-group>
                    </div>

                    <div class="right-section">
                        <el-popover placement="bottom" :width="200" trigger="hover" @before-enter="getFavoriates">
                            <template #reference>
                                <el-button @click="openFavorite">
                                    {{ $t('file.favorite') }}
                                </el-button>
                            </template>
                            <div class="favorite-item">
                                <el-table :data="favorites">
                                    <el-table-column prop="name">
                                        <template #default="{ row }">
                                            <span
                                                class="table-link text-ellipsis"
                                                @click="toFavorite(row)"
                                                type="primary"
                                            >
                                                <svg-icon
                                                    v-if="row.isDir"
                                                    className="table-icon"
                                                    iconName="p-file-folder"
                                                ></svg-icon>
                                                <svg-icon
                                                    v-else
                                                    className="table-icon"
                                                    iconName="p-file-normal"
                                                ></svg-icon>
                                                {{ row.name }}
                                            </span>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </el-popover>

                        <el-button class="btn" @click="openRecycleBin">
                            {{ $t('file.recycleBin') }}
                        </el-button>
                        <div class="search-button">
                            <el-input
                                v-model="req.search"
                                clearable
                                @clear="search()"
                                @keydown.enter="search()"
                                :placeholder="$t('file.search')"
                            >
                                <template #prepend>
                                    <el-checkbox v-model="req.containSub">
                                        {{ $t('file.sub') }}
                                    </el-checkbox>
                                </template>
                                <template #append>
                                    <el-button icon="Search" @click="search" round />
                                </template>
                            </el-input>
                        </div>
                    </div>
                </div>
            </template>
            <template #main>
                <ComplexTable
                    :pagination-config="paginationConfig"
                    v-model:selects="selects"
                    ref="tableRef"
                    :data="data"
                    @search="search"
                    @sort-change="changeSort"
                >
                    <el-table-column type="selection" width="30" />
                    <el-table-column
                        :label="$t('commons.table.name')"
                        min-width="250"
                        fix
                        show-overflow-tooltip
                        sortable
                        prop="name"
                    >
                        <template #default="{ row, $index }">
                            <div class="file-row" @mouseenter="showFavorite($index)" @mouseleave="hideFavorite">
                                <div>
                                    <svg-icon
                                        v-if="row.isDir"
                                        className="table-icon"
                                        iconName="p-file-folder"
                                    ></svg-icon>
                                    <svg-icon
                                        v-else
                                        className="table-icon"
                                        :iconName="getIconName(row.extension)"
                                    ></svg-icon>
                                </div>
                                <div class="file-name">
                                    <span class="table-link" @click="open(row)" type="primary">{{ row.name }}</span>
                                    <span v-if="row.isSymlink">-> {{ row.linkPath }}</span>
                                </div>
                                <div>
                                    <el-button
                                        v-if="row.favoriteID > 0"
                                        link
                                        type="warning"
                                        size="large"
                                        :icon="StarFilled"
                                        @click="removeFavorite(row.favoriteID)"
                                    ></el-button>
                                    <div v-else>
                                        <el-button
                                            v-if="hoveredRowIndex === $index"
                                            link
                                            :icon="Star"
                                            @click="addFavorite(row)"
                                        ></el-button>
                                    </div>
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column :label="$t('file.mode')" prop="mode" max-width="50">
                        <template #default="{ row }">
                            <el-link :underline="false" @click="openMode(row)" type="primary">{{ row.mode }}</el-link>
                        </template>
                    </el-table-column>
                    <el-table-column :label="$t('commons.table.user')" prop="user" show-overflow-tooltip>
                        <template #default="{ row }">
                            <el-link :underline="false" @click="openChown(row)" type="primary">
                                {{ row.user ? row.user : '-' }} ({{ row.uid }})
                            </el-link>
                        </template>
                    </el-table-column>
                    <el-table-column :label="$t('file.group')" prop="group">
                        <template #default="{ row }">
                            <el-link :underline="false" @click="openChown(row)" type="primary">
                                {{ row.group ? row.group : '-' }} ({{ row.gid }})
                            </el-link>
                        </template>
                    </el-table-column>
                    <el-table-column :label="$t('file.size')" prop="size" max-width="50" sortable>
                        <template #default="{ row, $index }">
                            <span v-if="row.isDir">
                                <el-button type="primary" link small @click="getDirSize(row, $index)">
                                    <span v-if="row.dirSize == undefined">
                                        {{ $t('file.calculate') }}
                                    </span>
                                    <span v-else>{{ getFileSize(row.dirSize) }}</span>
                                </el-button>
                            </span>
                            <span v-else>{{ getFileSize(row.size) }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :label="$t('file.updateTime')"
                        prop="modTime"
                        width="180"
                        :formatter="dateFormat"
                        show-overflow-tooltip
                        sortable
                    ></el-table-column>
                    <fu-table-operations
                        :ellipsis="mobile ? 0 : 3"
                        :buttons="buttons"
                        :label="$t('commons.table.operate')"
                        :min-width="mobile ? 'auto' : 200"
                        :fixed="mobile ? false : 'right'"
                        fix
                    />
                </ComplexTable>
            </template>

            <CreateFile ref="createRef" @close="search" />
            <ChangeRole ref="roleRef" @close="search" />
            <Compress ref="compressRef" @close="search" />
            <Decompress ref="deCompressRef" @close="search" />
            <CodeEditor ref="codeEditorRef" @close="search" />
            <FileRename ref="renameRef" @close="search" />
            <Upload ref="uploadRef" @close="search" />
            <Wget ref="wgetRef" @close="closeWget" />
            <Move ref="moveRef" @close="closeMovePage" />
            <Download ref="downloadRef" @close="search" />
            <Process :open="processPage.open" @close="closeProcess" />
            <Owner ref="chownRef" @close="search"></Owner>
            <Detail ref="detailRef" />
            <DeleteFile ref="deleteRef" @close="search" />
            <RecycleBin ref="recycleBinRef" @close="search" />
            <Favorite ref="favoriteRef" @close="search" />
            <BatchRole ref="batchRoleRef" @close="search" />
        </LayoutContent>
    </div>
</template>

<script setup lang="ts">
import { nextTick, onMounted, reactive, ref, computed } from '@vue/runtime-core';
import {
    GetFilesList,
    GetFileContent,
    ComputeDirSize,
    AddFavorite,
    RemoveFavorite,
    SearchFavorite,
} from '@/api/modules/files';
import { computeSize, copyText, dateFormat, downloadFile, getIcon, getRandomStr } from '@/utils/util';
import { StarFilled, Star } from '@element-plus/icons-vue';
import { File } from '@/api/interface/file';
import { Mimetypes, Languages } from '@/global/mimetype';
import { useRouter } from 'vue-router';
import { Back, Refresh } from '@element-plus/icons-vue';
import { MsgWarning } from '@/utils/message';
import { useSearchable } from './hooks/searchable';
import { ResultData } from '@/api/interface';
import { GlobalStore } from '@/store';

import i18n from '@/lang';
import CreateFile from './create/index.vue';
import ChangeRole from './change-role/index.vue';
import Compress from './compress/index.vue';
import Decompress from './decompress/index.vue';
import Upload from './upload/index.vue';
import FileRename from './rename/index.vue';
import CodeEditor from './code-editor/index.vue';
import Wget from './wget/index.vue';
import Move from './move/index.vue';
import Download from './download/index.vue';
import Owner from './chown/index.vue';
import DeleteFile from './delete/index.vue';
import Process from './process/index.vue';
import Detail from './detail/index.vue';
import RecycleBin from './recycle-bin/index.vue';
import Favorite from './favorite/index.vue';
import BatchRole from './batch-role/index.vue';

const globalStore = GlobalStore();

interface FilePaths {
    url: string;
    name: string;
}

const router = useRouter();
const data = ref();
const tableRef = ref();
let selects = ref<any>([]);

// origin data
const initData = () => ({
    path: '/',
    expand: true,
    showHidden: true,
    page: 1,
    pageSize: 100,
    search: '',
    containSub: false,
    sortBy: 'name',
    sortOrder: 'ascending',
});
let req = reactive(initData());
let loading = ref(false);
const paths = ref<FilePaths[]>([]);
let pathWidth = ref(0);

const fileCreate = reactive({ path: '/', isDir: false, mode: 0o755 });
const fileCompress = reactive({ files: [''], name: '', dst: '', operate: 'compress' });
const fileDeCompress = reactive({ path: '', name: '', dst: '', mimeType: '' });
const fileEdit = reactive({ content: '', path: '', name: '', language: 'plaintext' });
const codeReq = reactive({ path: '', expand: false, page: 1, pageSize: 100 });
const fileUpload = reactive({ path: '' });
const fileRename = reactive({ path: '', oldName: '' });
const fileWget = reactive({ path: '' });
const fileMove = reactive({ oldPaths: [''], type: '', path: '', name: '', count: 0 });
const processPage = reactive({ open: false });

const createRef = ref();
const roleRef = ref();
const detailRef = ref();
const compressRef = ref();
const deCompressRef = ref();
const codeEditorRef = ref();
const renameRef = ref();
const uploadRef = ref();
const wgetRef = ref();
const moveRef = ref();
const downloadRef = ref();
const pathRef = ref();
const breadCrumbRef = ref();
const chownRef = ref();
const moveOpen = ref(false);
const deleteRef = ref();
const recycleBinRef = ref();
const favoriteRef = ref();
const hoveredRowIndex = ref(-1);
const favorites = ref([]);
const batchRoleRef = ref();

// editablePath
const { searchableStatus, searchablePath, searchableInputRef, searchableInputBlur } = useSearchable(paths);

const paginationConfig = reactive({
    cacheSizeKey: 'file-page-size',
    currentPage: 1,
    pageSize: 100,
    total: 0,
});

const mobile = computed(() => {
    return globalStore.isMobile();
});

const search = async () => {
    loading.value = true;
    if (req.search != '') {
        req.sortBy = 'name';
        req.sortOrder = 'ascending';
        tableRef.value.clearSort();
    }

    req.page = paginationConfig.currentPage;
    req.pageSize = paginationConfig.pageSize;
    await GetFilesList(req)
        .then((res) => {
            handleSearchResult(res);
        })
        .finally(() => {
            loading.value = false;
        });
};

/** just search, no handleSearchResult */
const searchFile = async () => {
    loading.value = true;
    try {
        return await GetFilesList(req);
    } finally {
        loading.value = false;
    }
};

const handleSearchResult = (res: ResultData<File.File>) => {
    paginationConfig.total = res.data.itemTotal;
    data.value = res.data.items;
    req.path = res.data.path;
};

const open = async (row: File.File) => {
    if (row.isDir) {
        const name = row.name;
        if (req.path.endsWith('/')) {
            req.path = req.path + name;
        } else {
            req.path = req.path + '/' + name;
        }
        paths.value.push({
            url: req.path,
            name: name,
        });

        jump(req.path);
    } else {
        openCodeEditor(row.path, row.extension);
    }
};

const copyDir = (row: File.File) => {
    if (row?.path) {
        copyText(row?.path);
    }
};

const handlePath = () => {
    const breadcrumbElement = breadCrumbRef.value as any;
    const pathNodes = breadcrumbElement.querySelectorAll('.pathname');

    let totalpathWidth = 0;
    pathNodes.forEach((node) => {
        totalpathWidth += node.offsetWidth;
    });
    if (totalpathWidth > pathWidth.value) {
        paths.value.splice(0, 1);
        paths.value[0].name = '..';
        nextTick(function () {
            handlePath();
        });
    }
};

const back = () => {
    if (paths.value.length > 0) {
        let url = '/';
        if (paths.value.length >= 2) {
            url = paths.value[paths.value.length - 2].url;
        }
        jump(url);
    }
};

const jump = async (url: string) => {
    const oldUrl = req.path;
    // reset search params before exec jump
    Object.assign(req, initData());
    req.path = url;
    req.containSub = false;
    req.search = '';
    let searchResult = await searchFile();

    globalStore.setLastFilePath(req.path);
    // check search result,the file is exists?
    if (!searchResult.data.path) {
        req.path = oldUrl;
        MsgWarning(i18n.global.t('commons.res.notFound'));
        return;
    }
    handleSearchResult(searchResult);
    getPaths(req.path);
    nextTick(function () {
        handlePath();
    });
};

const getPaths = (reqPath: string) => {
    const pathArray = reqPath.split('/');
    paths.value = [];
    let base = '/';
    for (const p of pathArray) {
        if (p != '') {
            if (base.endsWith('/')) {
                base = base + p;
            } else {
                base = base + '/' + p;
            }
            paths.value.push({
                url: base,
                name: p,
            });
        }
    }
};

const handleCreate = (commnad: string) => {
    fileCreate.path = req.path;
    fileCreate.isDir = false;
    if (commnad === 'dir') {
        fileCreate.isDir = true;
    }
    createRef.value.acceptParams(fileCreate);
};

const delFile = async (row: File.File | null) => {
    deleteRef.value.acceptParams([row]);
};

const batchDelFiles = () => {
    deleteRef.value.acceptParams(selects.value);
};

const getFileSize = (size: number) => {
    return computeSize(size);
};

const getDirSize = async (row: any, index: number) => {
    const req = {
        path: row.path,
    };
    loading.value = true;
    await ComputeDirSize(req)
        .then(async (res) => {
            let newData = [...data.value];
            newData[index].dirSize = res.data.size;
            data.value = newData;
        })
        .finally(() => {
            loading.value = false;
        });
};

const getIconName = (extension: string) => {
    return getIcon(extension);
};

const openMode = (item: File.File) => {
    roleRef.value.acceptParams(item);
};

const openChown = (item: File.File) => {
    chownRef.value.acceptParams(item);
};

const openCompress = (items: File.File[]) => {
    const paths = [];
    for (const item of items) {
        paths.push(item.path);
    }
    fileCompress.files = paths;
    if (paths.length === 1) {
        fileCompress.name = items[0].name;
    } else {
        fileCompress.name = getRandomStr(6);
    }
    fileCompress.dst = req.path;

    compressRef.value.acceptParams(fileCompress);
};

const openDeCompress = (item: File.File) => {
    if (Mimetypes.get(item.mimeType) == undefined) {
        MsgWarning(i18n.global.t('file.canNotDeCompress'));
        return;
    }

    fileDeCompress.name = item.name;
    fileDeCompress.path = item.path;
    fileDeCompress.dst = req.path;
    fileDeCompress.mimeType = item.mimeType;

    deCompressRef.value.acceptParams(fileDeCompress);
};

const openCodeEditor = (path: string, extension: string) => {
    codeReq.path = path;
    codeReq.expand = true;

    if (extension != '') {
        Languages.forEach((language) => {
            const ext = extension.substring(1);
            if (language.value.indexOf(ext) > -1) {
                fileEdit.language = language.label;
            }
        });
    }

    GetFileContent(codeReq)
        .then((res) => {
            fileEdit.content = res.data.content;
            fileEdit.path = res.data.path;
            fileEdit.name = res.data.name;

            codeEditorRef.value.acceptParams(fileEdit);
        })
        .catch(() => {});
};

const openUpload = () => {
    fileUpload.path = req.path;
    uploadRef.value.acceptParams(fileUpload);
};

const openWget = () => {
    fileWget.path = req.path;
    wgetRef.value.acceptParams(fileWget);
};

const openBatchRole = (items: File.File[]) => {
    batchRoleRef.value.acceptParams({ files: items });
};

const closeWget = (submit: Boolean) => {
    search();
    if (submit) {
        openProcess();
    }
};

const closeMovePage = (submit: Boolean) => {
    if (submit) {
        search();
        closeMove();
    }
};

const openProcess = () => {
    processPage.open = true;
};

const closeProcess = () => {
    processPage.open = false;
};

const openRename = (item: File.File) => {
    fileRename.path = req.path;
    fileRename.oldName = item.name;
    renameRef.value.acceptParams(fileRename);
};

const openMove = (type: string) => {
    fileMove.type = type;
    fileMove.name = '';
    const oldpaths = [];
    for (const s of selects.value) {
        oldpaths.push(s['path']);
    }
    fileMove.count = selects.value.length;
    fileMove.oldPaths = oldpaths;
    if (selects.value.length == 1) {
        fileMove.name = selects.value[0].name;
    }
    moveOpen.value = true;
};

const closeMove = () => {
    selects.value = [];
    tableRef.value.clearSelects();
    fileMove.oldPaths = [];
    fileMove.name = '';
    fileMove.count = 0;
    moveOpen.value = false;
};

const openPaste = () => {
    fileMove.path = req.path;
    moveRef.value.acceptParams(fileMove);
};

const openDownload = (file: File.File) => {
    downloadFile(file.path);
};

const openDetail = (row: File.File) => {
    detailRef.value.acceptParams({ path: row.path });
};

const openRecycleBin = () => {
    recycleBinRef.value.acceptParams();
};

const openFavorite = () => {
    favoriteRef.value.acceptParams();
};

const changeSort = ({ prop, order }) => {
    req.sortBy = prop;
    req.sortOrder = order;
    req.search = '';
    req.page = 1;
    req.pageSize = paginationConfig.pageSize;
    req.containSub = false;
    search();
};

const showFavorite = (index: any) => {
    hoveredRowIndex.value = index;
};

const hideFavorite = () => {
    hoveredRowIndex.value = -1;
};

const addFavorite = async (row: File.File) => {
    try {
        await AddFavorite(row.path);
        search();
    } catch (error) {}
};

const removeFavorite = async (id: number) => {
    ElMessageBox.confirm(i18n.global.t('file.removeFavorite'), i18n.global.t('commons.msg.remove'), {
        confirmButtonText: i18n.global.t('commons.button.confirm'),
        cancelButtonText: i18n.global.t('commons.button.cancel'),
    }).then(async () => {
        try {
            await RemoveFavorite(id);
            search();
        } catch (error) {}
    });
};

const getFavoriates = async () => {
    try {
        const res = await SearchFavorite(req);
        favorites.value = res.data.items;
    } catch (error) {}
};

const toFavorite = (row: File.Favorite) => {
    if (row.isDir) {
        jump(row.path);
    } else if (row.isTxt) {
        openCodeEditor(row.path, '.' + row.name.split('.').pop());
    } else {
        jump(row.path.substring(0, row.path.lastIndexOf('/')));
    }
};

const toTerminal = () => {
    router.push({ path: '/hosts/terminal', query: { path: req.path } });
};

const buttons = [
    {
        label: i18n.global.t('file.open'),
        click: open,
    },
    {
        label: i18n.global.t('file.download'),
        click: (row: File.File) => {
            openDownload(row);
        },
        disabled: (row: File.File) => {
            return row.isDir;
        },
    },
    {
        label: i18n.global.t('file.deCompress'),
        click: openDeCompress,
        disabled: (row: File.File) => {
            return row.isDir;
        },
    },
    {
        label: i18n.global.t('file.mode'),
        click: openMode,
    },
    {
        label: i18n.global.t('file.compress'),
        click: (row: File.File) => {
            openCompress([row]);
        },
    },
    {
        label: i18n.global.t('file.rename'),
        click: openRename,
    },
    {
        label: i18n.global.t('file.copyDir'),
        click: copyDir,
    },
    {
        label: i18n.global.t('commons.button.delete'),
        click: delFile,
    },
    {
        label: i18n.global.t('file.info'),
        click: openDetail,
    },
];

onMounted(() => {
    if (router.currentRoute.value.query.path) {
        req.path = String(router.currentRoute.value.query.path);
        getPaths(req.path);
        globalStore.setLastFilePath(req.path);
    } else {
        if (globalStore.lastFilePath && globalStore.lastFilePath != '') {
            req.path = globalStore.lastFilePath;
            getPaths(req.path);
        }
    }
    pathWidth.value = pathRef.value.offsetWidth;
    search();

    nextTick(function () {
        handlePath();
    });
});
</script>

<style scoped lang="scss">
.path {
    display: flex;
    align-items: center;
    border: 1px solid #ebeef5;
    background-color: var(--panel-path-bg);
    height: 30px;
    border-radius: 2px !important;
    &:hover {
        cursor: text;
        box-shadow: var(--el-box-shadow);
    }

    .root {
        vertical-align: middle;
        margin-left: 10px;
    }
    .other {
        vertical-align: middle;
    }
    .split {
        margin-left: 5px;
        margin-right: 5px;
    }
}

.copy-button {
    margin-left: 10px;
    .close {
        width: 10px;
        .close-icon {
            color: red;
        }
    }
}

.btn-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.left-section,
.right-section {
    display: flex;
    align-items: center;
}

.left-section > *:not(:first-child) {
    margin-left: 5px;
}

.right-section {
    .btn {
        margin-right: 10px;
    }
}
.favorite-item {
    max-height: 650px;
    overflow: auto;
}

.file-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.file-name {
    flex-grow: 1;
    margin-left: 1px;
    width: 95%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.address-bar {
    border: var(--el-border);
    .arrow {
        color: #726e6e;
    }
}
</style>
