refactor: Improve optimize code (#8581)

This commit is contained in:
2025-05-09 15:57:48 +08:00 committed by GitHub
parent e1635aa39d
commit 3afef6fa99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 94 additions and 61 deletions

View file

@ -39,7 +39,7 @@
"crypto-js": "^4.2.0",
"echarts": "^5.5.0",
"element-plus": "^2.9.7",
"fit2cloud-ui-plus": "^1.2.0",
"fit2cloud-ui-plus": "^1.2.2",
"highlight.js": "^11.9.0",
"js-base64": "^3.7.7",
"jsencrypt": "^3.3.2",

View file

@ -1420,7 +1420,7 @@ const message = {
clearRecycleBinHelper: 'Do you want to clear the Recycle Bin?',
favorite: 'Favorites',
removeFavorite: 'Remove from Favorites?',
addFavorite: 'Add to Davorites',
addFavorite: 'Add/Remove to Favorites',
clearList: 'Clear list',
deleteRecycleHelper: 'Are you sure you want to permanently delete the following files?',
typeErrOrEmpty: '[{0}] file type is wrong or empty folder',

View file

@ -1361,7 +1361,7 @@ const message = {
clearRecycleBinHelper: 'リサイクルビンを掃除しますか',
favorite: 'お気に入り',
removeFavorite: 'お気に入りから取り外しますか',
addFavorite: 'お気に入りに追加します',
addFavorite: 'お気に入りの追加/削除',
clearList: 'クリーンリスト',
deleteRecycleHelper: '次のファイルを永続的に削除する必要がありますか',
typeErrOrEmpty: '[{0}]ファイルタイプは間違っているか空のフォルダーです',

View file

@ -1348,7 +1348,7 @@ const message = {
clearRecycleBinHelper: '휴지통을 정리하시겠습니까?',
favorite: '즐겨찾기',
removeFavorite: '즐겨찾기에서 제거하시겠습니까?',
addFavorite: '즐겨찾기 추가',
addFavorite: '즐겨찾기 추가 / 제거',
clearList: '목록 정리',
deleteRecycleHelper: '다음 파일을 영구적으로 삭제하시겠습니까?',
typeErrOrEmpty: '[{0}] 파일 유형이 잘못되었거나 폴더입니다.',

View file

@ -1406,7 +1406,7 @@ const message = {
clearRecycleBinHelper: 'Adakah anda mahu membersihkan tong kitar semula?',
favorite: 'Kegemaran',
removeFavorite: 'Buang daripada kegemaran?',
addFavorite: 'Tambah ke Kegemaran',
addFavorite: 'Tambah/Buang ke Kegemaran',
clearList: 'Bersihkan senarai',
deleteRecycleHelper: 'Adakah anda pasti mahu memadam fail berikut secara kekal?',
typeErrOrEmpty: '[{0}] jenis fail salah atau folder kosong',

View file

@ -1390,7 +1390,7 @@ const message = {
clearRecycleBinHelper: 'Você deseja limpar a lixeira?',
favorite: 'Favoritos',
removeFavorite: 'Remover dos favoritos?',
addFavorite: 'Adicionar aos favoritos',
addFavorite: 'Adicionar/Remover aos favoritos',
clearList: 'Limpar lista',
deleteRecycleHelper: 'Tem certeza de que deseja excluir permanentemente os seguintes arquivos?',
typeErrOrEmpty: '[{0}] tipo de arquivo errado ou pasta vazia',

View file

@ -1395,7 +1395,7 @@ const message = {
clearRecycleBinHelper: 'Вы хотите очистить корзину?',
favorite: 'Избранное',
removeFavorite: 'Удалить из избранного?',
addFavorite: 'Добавить в избранное',
addFavorite: 'Добавить/Удалить в избранное',
clearList: 'Очистить список',
deleteRecycleHelper: 'Вы уверены, что хотите навсегда удалить следующие файлы?',
typeErrOrEmpty: '[{0}] неверный тип файла или пустая папка',

View file

@ -1348,7 +1348,7 @@ const message = {
clearRecycleBinHelper: '是否清空回收站',
favorite: '收藏夾',
removeFavorite: '是否從收藏夾移出',
addFavorite: '加入收藏夾',
addFavorite: '添加/移出收藏夾',
clearList: '清空列表',
deleteRecycleHelper: '確定永久刪除以下文件',
typeErrOrEmpty: '{0} 檔案類型錯誤或為空資料夾',

View file

@ -1344,7 +1344,7 @@ const message = {
clearRecycleBinHelper: '是否清空回收站',
favorite: '收藏夹',
removeFavorite: '是否从收藏夹移出',
addFavorite: '加入收藏夹子',
addFavorite: '添加/移出收藏夹',
clearList: '清空列表',
deleteRecycleHelper: '确定永久删除以下文件',
typeErrOrEmpty: '{0} 文件类型错误或为空文件夹',

View file

@ -1,21 +1,25 @@
<template>
<div :class="classObj" class="app-wrapper" v-loading="loading" :element-loading-text="loadingText" fullscreen>
<div
:class="classObj"
class="app-wrapper relative"
v-loading="loading"
:element-loading-text="loadingText"
fullscreen
>
<div v-if="classObj.mobile && classObj.openSidebar" class="drawer-bg" @click="handleClickOutside" />
<el-affix :offset="classObj.openMenuTabs ? 8 : 15" class="affix">
<el-tooltip :content="menuStore.isCollapse ? $t('commons.button.expand') : $t('commons.button.collapse')">
<el-button
size="small"
circle
:style="{ 'margin-left': menuStore.isCollapse ? '63px' : '168px', position: 'absolute' }"
:icon="menuStore.isCollapse ? 'ArrowRight' : 'ArrowLeft'"
plain
@click="handleCollapse()"
></el-button>
</el-tooltip>
</el-affix>
<div class="app-sidebar" v-if="!globalStore.isFullScreen">
<el-affix :offset="15" class="affix">
<el-tooltip
:content="menuStore.isCollapse ? $t('commons.button.expand') : $t('commons.button.collapse')"
>
<el-button
size="small"
circle
:style="{ 'margin-left': menuStore.isCollapse ? '60px' : '165px', position: 'absolute' }"
:icon="menuStore.isCollapse ? 'ArrowRight' : 'ArrowLeft'"
plain
@click="handleCollapse()"
></el-button>
</el-tooltip>
</el-affix>
<Sidebar @menu-click="handleMenuClick" :menu-router="!classObj.openMenuTabs" @open-task="openTask" />
</div>

View file

@ -188,7 +188,7 @@
<el-button class="btn" @click="toTerminal">
{{ $t('menu.terminal') }}
</el-button>
<el-popover placement="bottom" :width="200" trigger="hover" @before-enter="getFavoriates">
<el-popover placement="bottom" :width="200" trigger="hover" @before-enter="getFavorites">
<template #reference>
<el-button @click="openFavorite">
{{ $t('file.favorite') }}
@ -453,12 +453,12 @@
sortable
></el-table-column>
<fu-table-operations
:ellipsis="mobile ? 0 : 3"
:ellipsis="mobile ? 0 : 2"
:buttons="buttons"
:label="$t('commons.table.operate')"
:min-width="mobile ? 'auto' : 200"
:fixed="mobile ? false : 'right'"
width="300"
width="270"
fix
/>
</ComplexTable>
@ -850,10 +850,7 @@ const getPaths = (reqPath: string) => {
const handleCreate = (command: string) => {
fileCreate.path = req.path;
fileCreate.isDir = false;
if (command === 'dir') {
fileCreate.isDir = true;
}
fileCreate.isDir = command === 'dir';
createRef.value.acceptParams(fileCreate);
};
@ -1063,6 +1060,12 @@ const openMove = (type: string) => {
moveOpen.value = true;
};
const openMoveBtn = (type: string, item: File.File) => {
selects.value = [];
selects.value.push(item);
openMove(type);
};
const closeMove = () => {
selects.value = [];
tableRef.value.clearSelects();
@ -1078,6 +1081,13 @@ const openPaste = () => {
moveRef.value.acceptParams(fileMove);
};
const openPasteBtn = (file: File.File) => {
if (file.isDir) {
fileMove.path = file.path;
}
moveRef.value.acceptParams(fileMove);
};
const openDownload = (file: File.File) => {
downloadFile(file.path, globalStore.currentNode);
};
@ -1131,7 +1141,7 @@ const remove = async (id: number) => {
});
};
const getFavoriates = async () => {
const getFavorites = async () => {
try {
const res = await searchFavorite(req);
favorites.value = res.data.items;
@ -1172,6 +1182,29 @@ const buttons = [
return row.isDir;
},
},
{
label: i18n.global.t('commons.button.copy'),
click: (row: File.File) => openMoveBtn('copy', row),
},
{
label: i18n.global.t('file.move'),
click: (row: File.File) => openMoveBtn('cut', row),
},
{
label: i18n.global.t('file.paste'),
click: (row: File.File) => {
openPasteBtn(row);
},
disabled: () => {
return !moveOpen.value;
},
},
{
label: i18n.global.t('file.compress'),
click: (row: File.File) => {
openCompress([row]);
},
},
{
label: i18n.global.t('file.deCompress'),
click: openDeCompress,
@ -1185,34 +1218,40 @@ const buttons = [
openBatchRole([row]);
},
},
{
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('file.openWithVscode'),
click: openWithVSCode,
},
{
label: i18n.global.t('commons.button.delete'),
disabled: (row: File.File) => {
return row.name == '.1panel_clash';
},
click: delFile,
divided: true,
},
{
label: i18n.global.t('file.copyDir'),
click: copyDir,
},
{
label: i18n.global.t('file.addFavorite'),
click: (row: File.File) => {
if (row.favoriteID > 0) {
remove(row.favoriteID);
} else {
addToFavorite(row);
}
},
},
{
label: i18n.global.t('file.openWithVscode'),
click: openWithVSCode,
},
{
label: i18n.global.t('file.info'),
click: openDetail,
divided: true,
},
];
@ -1245,11 +1284,9 @@ onMounted(() => {
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);
}
} else if (globalStore.lastFilePath && globalStore.lastFilePath != '') {
req.path = globalStore.lastFilePath;
getPaths(req.path);
}
pathWidth.value = pathRef.value.offsetWidth;
search();
@ -1310,7 +1347,7 @@ onBeforeUnmount(() => {
}
.favorite-item {
height: 50vh;
height: 30vh;
overflow: auto;
}

View file

@ -269,8 +269,6 @@ const form = reactive({
proxyPasswd: '',
proxyPasswdKeep: '',
proxyDocker: '',
proxyDockerSyncToNode: '',
proxyDockerSyncNodes: '',
apiInterfaceStatus: 'Disable',
apiKey: '',
@ -346,8 +344,6 @@ const search = async () => {
: '{"light":"#005eeb","dark":"#F0BE96"}';
globalStore.themeConfig.theme = form.theme;
form.proxyDocker = xpackRes.data.proxyDocker;
form.proxyDockerSyncToNode = xpackRes.data.proxyDockerSyncToNode;
form.proxyDockerSyncNodes = xpackRes.data.proxyDockerSyncNodes;
}
} else {
globalStore.themeConfig.theme = form.theme;
@ -378,8 +374,6 @@ const onChangeProxy = () => {
passwd: form.proxyPasswd,
passwdKeep: form.proxyPasswdKeep,
proxyDocker: form.proxyDocker,
proxyDockerSyncToNode: form.proxyDockerSyncToNode,
proxyDockerSyncNodes: form.proxyDockerSyncNodes,
});
};

View file

@ -54,9 +54,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
host: '0.0.0.0',
proxy: {
'/api/v2': {
target: 'http://192.168.1.2:9999',
// target: 'http://172.16.10.123:9999',
// target: 'http://192.168.31.219:9999/',
target: 'http://localhost:9999/',
changeOrigin: true,
ws: true,
},