refactor(project): re-adjust the overall folder

This commit is contained in:
vince
2024-07-23 00:03:59 +08:00
parent a1a566cb2f
commit 14538f7ed5
281 changed files with 1365 additions and 1659 deletions

View File

@@ -6,13 +6,12 @@
"repository": {
"type": "git",
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
"directory": "packages/@vben-core/shared/hooks"
"directory": "packages/@core/hooks"
},
"license": "MIT",
"type": "module",
"scripts": {
"build": "pnpm unbuild",
"stub": "pnpm unbuild --stub"
"build": "pnpm unbuild"
},
"files": [
"dist"
@@ -37,14 +36,11 @@
},
"dependencies": {
"@vben-core/constants": "workspace:*",
"@vben-core/preferences": "workspace:*",
"@vben-core/stores": "workspace:*",
"@vben-core/toolkit": "workspace:*",
"@vueuse/core": "^10.11.0",
"radix-vue": "^1.9.2",
"sortablejs": "^1.15.2",
"vue": "^3.4.33",
"vue-router": "^4.4.0"
"vue": "^3.4.33"
},
"devDependencies": {
"@types/sortablejs": "^1.15.8"

View File

@@ -1,9 +1,6 @@
export * from './use-content-height';
export * from './use-content-maximize';
export * from './use-namespace';
export * from './use-refresh';
export * from './use-sortable';
export * from './use-tabs';
export {
useEmitAsProps,
useForwardExpose,

View File

@@ -1,24 +0,0 @@
import { updatePreferences, usePreferences } from '@vben-core/preferences';
/**
* 主体区域最大化
*/
export function useContentMaximize() {
const { contentIsMaximize } = usePreferences();
function toggleMaximize() {
const isMaximize = contentIsMaximize.value;
updatePreferences({
header: {
hidden: !isMaximize,
},
sidebar: {
hidden: !isMaximize,
},
});
}
return {
contentIsMaximize,
toggleMaximize,
};
}

View File

@@ -1,16 +0,0 @@
import { useRouter } from 'vue-router';
import { useCoreTabbarStore } from '@vben-core/stores';
export function useRefresh() {
const router = useRouter();
const coreTabbarStore = useCoreTabbarStore();
function refresh() {
coreTabbarStore.refresh(router);
}
return {
refresh,
};
}

View File

@@ -1,113 +0,0 @@
import { type RouteLocationNormalized, useRoute, useRouter } from 'vue-router';
import { useCoreTabbarStore } from '@vben-core/stores';
export function useTabs() {
const router = useRouter();
const route = useRoute();
const coreTabbarStore = useCoreTabbarStore();
async function closeLeftTabs(tab?: RouteLocationNormalized) {
await coreTabbarStore.closeLeftTabs(tab || route);
}
async function closeAllTabs() {
await coreTabbarStore.closeAllTabs(router);
}
async function closeRightTabs(tab?: RouteLocationNormalized) {
await coreTabbarStore.closeRightTabs(tab || route);
}
async function closeOtherTabs(tab?: RouteLocationNormalized) {
await coreTabbarStore.closeOtherTabs(tab || route);
}
async function closeCurrentTab(tab?: RouteLocationNormalized) {
await coreTabbarStore.closeTab(tab || route, router);
}
async function pinTab(tab?: RouteLocationNormalized) {
await coreTabbarStore.pinTab(tab || route);
}
async function unpinTab(tab?: RouteLocationNormalized) {
await coreTabbarStore.unpinTab(tab || route);
}
async function toggleTabPin(tab?: RouteLocationNormalized) {
await coreTabbarStore.toggleTabPin(tab || route);
}
async function refreshTab() {
await coreTabbarStore.refresh(router);
}
async function openTabInNewWindow(tab?: RouteLocationNormalized) {
coreTabbarStore.openTabInNewWindow(tab || route);
}
async function closeTabByKey(key: string) {
await coreTabbarStore.closeTabByKey(key, router);
}
async function setTabTitle(title: string) {
coreTabbarStore.setUpdateTime();
await coreTabbarStore.setTabTitle(route, title);
}
async function resetTabTitle() {
coreTabbarStore.setUpdateTime();
await coreTabbarStore.resetTabTitle(route);
}
/**
* 获取操作是否禁用
* @param tab
*/
function getTabDisableState(tab: RouteLocationNormalized = route) {
const tabs = coreTabbarStore.getTabs;
const affixTabs = coreTabbarStore.affixTabs;
const index = tabs.findIndex((item) => item.path === tab.path);
const disabled = tabs.length <= 1;
const { meta } = tab;
const affixTab = meta?.affixTab ?? false;
const isCurrentTab = route.path === tab.path;
// 当前处于最左侧或者减去固定标签页的数量等于0
const disabledCloseLeft =
index === 0 || index - affixTabs.length <= 0 || !isCurrentTab;
const disabledCloseRight = !isCurrentTab || index === tabs.length - 1;
const disabledCloseOther =
disabled || !isCurrentTab || tabs.length - affixTabs.length <= 1;
return {
disabledCloseAll: disabled,
disabledCloseCurrent: !!affixTab || disabled,
disabledCloseLeft,
disabledCloseOther,
disabledCloseRight,
disabledRefresh: !isCurrentTab,
};
}
return {
closeAllTabs,
closeCurrentTab,
closeLeftTabs,
closeOtherTabs,
closeRightTabs,
closeTabByKey,
getTabDisableState,
openTabInNewWindow,
pinTab,
refreshTab,
resetTabTitle,
setTabTitle,
toggleTabPin,
unpinTab,
};
}