diff --git a/.ls-lint.yml b/.ls-lint.yml
index 3c3d9903..d8bc94fa 100644
--- a/.ls-lint.yml
+++ b/.ls-lint.yml
@@ -3,6 +3,7 @@ ls:
.js: kebab-case | PascalCase
.vue: PascalCase | regex:^index
.ts: camelCase | PascalCase
+ .tsx: camelCase | PascalCase
.d.ts: kebab-case
.mock.ts: kebab-case
.data.ts: camelCase | kebab-case
diff --git a/src/App.vue b/src/App.vue
index 3f1afebf..c54e55d2 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -4,7 +4,9 @@
:locale="antConfigLocale"
:transform-cell-text="transformCellText"
>
-
+
+
+
@@ -17,9 +19,11 @@
import { useLockPage } from '/@/hooks/web/useLockPage';
import { useLocale } from '/@/hooks/web/useLocale';
+ import { AppProvider } from '/@/components/Application';
+
export default defineComponent({
name: 'App',
- components: { ConfigProvider },
+ components: { ConfigProvider, AppProvider },
setup() {
// Initialize vuex internal system configuration
initAppConfigStore();
diff --git a/src/components/Application/index.ts b/src/components/Application/index.ts
index 252d1e8c..f2599900 100644
--- a/src/components/Application/index.ts
+++ b/src/components/Application/index.ts
@@ -1,6 +1,10 @@
-import AppLocalePickerLib from './src/AppLocalePicker.vue';
-import AppLogoLib from './src/AppLogo.vue';
+import AppLocalePicker from './src/AppLocalePicker.vue';
+import AppLogo from './src/AppLogo.vue';
+import AppProvider from './src/AppProvider.vue';
import { withInstall } from '../util';
-export const AppLocalePicker = withInstall(AppLocalePickerLib);
-export const AppLogo = withInstall(AppLogoLib);
+withInstall(AppLocalePicker, AppLogo, AppProvider);
+
+export { useAppProviderContext } from './src/useAppContext';
+
+export { AppLocalePicker, AppLogo, AppProvider };
diff --git a/src/components/Application/src/AppLocalePicker.vue b/src/components/Application/src/AppLocalePicker.vue
index 5ef9e78a..3ea924f1 100644
--- a/src/components/Application/src/AppLocalePicker.vue
+++ b/src/components/Application/src/AppLocalePicker.vue
@@ -69,8 +69,8 @@
});
-
diff --git a/src/components/Menu/src/hooks/useSearchInput.ts b/src/components/Menu/src/hooks/useSearchInput.ts
deleted file mode 100644
index 461130de..00000000
--- a/src/components/Menu/src/hooks/useSearchInput.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import type { Menu as MenuType } from '/@/router/types';
-import type { MenuState } from '../types';
-import type { Ref } from 'vue';
-
-import { isString } from '/@/utils/is';
-import { unref } from 'vue';
-import { es6Unique } from '/@/utils';
-import { getAllParentPath } from '/@/router/helper/menuHelper';
-
-interface UseSearchInputOptions {
- menuState: MenuState;
- flatMenusRef: Ref;
- emit: EmitType;
- handleMenuChange: Fn;
-}
-export function useSearchInput({
- menuState,
- flatMenusRef,
- handleMenuChange,
- emit,
-}: UseSearchInputOptions) {
- /**
- * @description: 输入框搜索
- */
- function handleInputChange(value?: string): void {
- if (!isString(value)) {
- value = (value as any).target.value;
- }
- if (!value) {
- handleMenuChange && handleMenuChange();
- }
-
- menuState.searchValue = value || '';
- if (!value) {
- menuState.openKeys = [];
- return;
- }
-
- const flatMenus = unref(flatMenusRef);
- let openKeys: string[] = [];
- for (const menu of flatMenus) {
- const { name, path } = menu;
- if (!name.includes(value)) {
- continue;
- }
- openKeys = openKeys.concat(getAllParentPath(flatMenus, path));
- }
- openKeys = es6Unique(openKeys);
- menuState.openKeys = openKeys;
- }
-
- // 搜索框点击
- function handleInputClick(e: any): void {
- emit('clickSearchInput', e);
- }
-
- return { handleInputChange, handleInputClick };
-}
diff --git a/src/components/Menu/src/props.ts b/src/components/Menu/src/props.ts
index 4df32818..af488cd8 100644
--- a/src/components/Menu/src/props.ts
+++ b/src/components/Menu/src/props.ts
@@ -20,11 +20,7 @@ export const basicProps = {
type: Boolean as PropType,
default: false,
},
- // 是否显示搜索框
- search: {
- type: Boolean as PropType,
- default: true,
- },
+
// 最好是4 倍数
inlineIndent: {
type: Number as PropType,
@@ -51,10 +47,7 @@ export const basicProps = {
type: Boolean as PropType,
default: false,
},
- isAppMenu: {
- type: Boolean as PropType,
- default: true,
- },
+
isHorizontal: {
type: Boolean as PropType,
default: false,
diff --git a/src/components/Menu/src/types.ts b/src/components/Menu/src/types.ts
index 997120ff..2415d39c 100644
--- a/src/components/Menu/src/types.ts
+++ b/src/components/Menu/src/types.ts
@@ -17,9 +17,6 @@ export interface MenuState {
// 展开数组
openKeys: string[];
- // 搜索值
- searchValue: string;
-
// 当前选中的菜单项 key 数组
selectedKeys: string[];
diff --git a/src/components/Menu/src/hooks/useOpenKeys.ts b/src/components/Menu/src/useOpenKeys.ts
similarity index 91%
rename from src/components/Menu/src/hooks/useOpenKeys.ts
rename to src/components/Menu/src/useOpenKeys.ts
index cc78cc60..eaa28db6 100644
--- a/src/components/Menu/src/hooks/useOpenKeys.ts
+++ b/src/components/Menu/src/useOpenKeys.ts
@@ -1,6 +1,6 @@
import { MenuModeEnum } from '/@/enums/menuEnum';
import type { Menu as MenuType } from '/@/router/types';
-import type { MenuState } from '../types';
+import type { MenuState } from './types';
import type { Ref } from 'vue';
import { unref } from 'vue';
@@ -12,14 +12,11 @@ export function useOpenKeys(
menuState: MenuState,
menus: Ref,
flatMenusRef: Ref,
- isAppMenu: Ref,
mode: Ref,
accordion: Ref
) {
const { getCollapsed } = useMenuSetting();
- /**
- * @description:设置展开
- */
+
function setOpenKeys(menu: MenuType) {
const flatMenus = unref(flatMenusRef);
if (!unref(accordion)) {
@@ -50,7 +47,7 @@ export function useOpenKeys(
rootSubMenuKeys.push(path);
}
}
- if (!unref(getCollapsed) || !unref(isAppMenu)) {
+ if (!unref(getCollapsed)) {
const latestOpenKey = openKeys.find((key) => menuState.openKeys.indexOf(key) === -1);
if (rootSubMenuKeys.indexOf(latestOpenKey as string) === -1) {
menuState.openKeys = openKeys;
diff --git a/src/components/Modal/index.ts b/src/components/Modal/index.ts
index aecdf901..10b26ef4 100644
--- a/src/components/Modal/index.ts
+++ b/src/components/Modal/index.ts
@@ -1,8 +1,10 @@
import './src/index.less';
-import BasicModalLib from './src/BasicModal';
+import BasicModal from './src/BasicModal';
import { withInstall } from '../util';
+withInstall(BasicModal);
+
export { useModalContext } from './src/useModalContext';
export { useModal, useModalInner } from './src/useModal';
export * from './src/types';
-export const BasicModal = withInstall(BasicModalLib);
+export { BasicModal };
diff --git a/src/components/Page/index.ts b/src/components/Page/index.ts
index 3a3a1e0d..c46b7eea 100644
--- a/src/components/Page/index.ts
+++ b/src/components/Page/index.ts
@@ -1,4 +1,5 @@
-import PageFooterLib from './src/PageFooter.vue';
+import PageFooter from './src/PageFooter.vue';
import { withInstall } from '../util';
-export const PageFooter = withInstall(PageFooterLib);
+withInstall(PageFooter);
+export { PageFooter };
diff --git a/src/components/StrengthMeter/index.tsx b/src/components/StrengthMeter/index.tsx
index 93703be4..80f7a33f 100644
--- a/src/components/StrengthMeter/index.tsx
+++ b/src/components/StrengthMeter/index.tsx
@@ -1,4 +1,5 @@
-import StrengthMeterLib from './src/index';
+import StrengthMeter from './src/index';
import { withInstall } from '../util';
-export const StrengthMeter = withInstall(StrengthMeterLib);
+withInstall(StrengthMeter);
+export { StrengthMeter };
diff --git a/src/components/Tinymce/index.ts b/src/components/Tinymce/index.ts
index 110cc60e..3dd4e2b4 100644
--- a/src/components/Tinymce/index.ts
+++ b/src/components/Tinymce/index.ts
@@ -1,4 +1,5 @@
-import TinymceLib from './src/Editor.vue';
+import Tinymce from './src/Editor.vue';
import { withInstall } from '../util';
-export const Tinymce = withInstall(TinymceLib);
+withInstall(Tinymce);
+export { Tinymce };
diff --git a/src/components/Upload/index.ts b/src/components/Upload/index.ts
index 24feb311..8d7d8045 100644
--- a/src/components/Upload/index.ts
+++ b/src/components/Upload/index.ts
@@ -1,8 +1,5 @@
-import type { App } from 'vue';
import BasicUpload from './src/BasicUpload.vue';
+import { withInstall } from '../util';
-export default (app: App): void => {
- app.component(BasicUpload.name, BasicUpload);
-};
-
+withInstall(BasicUpload);
export { BasicUpload };
diff --git a/src/components/Verify/index.ts b/src/components/Verify/index.ts
index 8a46c57a..cc7008cf 100644
--- a/src/components/Verify/index.ts
+++ b/src/components/Verify/index.ts
@@ -1,8 +1,9 @@
-import BasicDragVerifyLib from './src/DragVerify';
-import RotateDragVerifyLib from './src/ImgRotate';
+import BasicDragVerify from './src/DragVerify';
+import RotateDragVerify from './src/ImgRotate';
import { withInstall } from '../util';
+withInstall(BasicDragVerify, RotateDragVerify);
+
export * from './src/types';
-export const RotateDragVerify = withInstall(RotateDragVerifyLib);
-export const BasicDragVerify = withInstall(BasicDragVerifyLib);
+export { BasicDragVerify, RotateDragVerify };
diff --git a/src/components/VirtualScroll/index.ts b/src/components/VirtualScroll/index.ts
index 0ab61fd2..a712e2b3 100644
--- a/src/components/VirtualScroll/index.ts
+++ b/src/components/VirtualScroll/index.ts
@@ -1,4 +1,5 @@
-import VirtualScrollLib from './src/index';
+import VirtualScroll from './src/index';
import { withInstall } from '../util';
-export const VirtualScroll = withInstall(VirtualScrollLib);
+withInstall(VirtualScroll);
+export { VirtualScroll };
diff --git a/src/components/util.ts b/src/components/util.ts
index 1cd5aeb1..c1d7a3c1 100644
--- a/src/components/util.ts
+++ b/src/components/util.ts
@@ -1,12 +1,12 @@
-import type { VNodeChild, Plugin } from 'vue';
+import type { VNodeChild } from 'vue';
import type { App } from 'vue';
-export function withInstall(component: T) {
- const comp = component as any;
- comp.install = (app: App) => {
- app.component(comp.displayName || comp.name, comp);
- };
- return comp as T & Plugin;
+export function withInstall(...components: any[]) {
+ components.forEach((comp) => {
+ comp.install = (app: App) => {
+ app.component(comp.displayName || comp.name, comp);
+ };
+ });
}
export function convertToUnit(
diff --git a/src/design/var/index.less b/src/design/var/index.less
index 20d21b9f..0f656eec 100644
--- a/src/design/var/index.less
+++ b/src/design/var/index.less
@@ -2,6 +2,8 @@
@import 'easing';
@import 'breakpoint';
+@namespace: vben;
+
// tabs
@multiple-height: 30px;
diff --git a/src/hooks/core/useContext.ts b/src/hooks/core/useContext.ts
index 6edfba94..d2d8ce67 100644
--- a/src/hooks/core/useContext.ts
+++ b/src/hooks/core/useContext.ts
@@ -1,21 +1,54 @@
-import { InjectionKey, provide, inject, reactive, readonly } from 'vue';
+import {
+ InjectionKey,
+ provide,
+ inject,
+ reactive,
+ readonly as defineReadonly,
+ defineComponent,
+ UnwrapRef,
+} from 'vue';
-export const createContext = (
- context: any,
- contextInjectKey: InjectionKey = Symbol(),
- _readonly = true
-) => {
- const state = reactive({ ...context });
+export interface CreateContextOptions {
+ readonly?: boolean;
+ createProvider?: boolean;
+}
- const provideData = _readonly ? readonly(state) : state;
- provide(contextInjectKey, provideData);
+type ShallowUnwrap = {
+ [P in keyof T]: UnwrapRef;
};
+export function createContext(
+ context: any,
+ key: InjectionKey = Symbol(),
+ options: CreateContextOptions = {}
+) {
+ const { readonly = true, createProvider = false } = options;
+
+ const state = reactive(context);
+
+ const provideData = readonly ? defineReadonly(state) : state;
+ !createProvider && provide(key, provideData);
+
+ const Provider = createProvider
+ ? defineComponent({
+ name: 'Provider',
+ inheritAttrs: false,
+ setup(_, { slots }) {
+ provide(key, provideData);
+ return () => slots.default?.();
+ },
+ })
+ : null;
+
+ return { Provider, state };
+}
+
export const useContext = (
- contextInjectKey: InjectionKey = Symbol(),
+ key: InjectionKey = Symbol(),
defaultValue?: any,
- _readonly = true
-): T => {
- const state = inject(contextInjectKey, defaultValue || {});
- return _readonly ? readonly(state) : state;
+ readonly = false
+): ShallowUnwrap => {
+ const state = inject(key, defaultValue || {});
+
+ return readonly ? defineReadonly(state) : state;
};
diff --git a/src/hooks/setting/useMenuSetting.ts b/src/hooks/setting/useMenuSetting.ts
index f66ef8a3..4b18a867 100644
--- a/src/hooks/setting/useMenuSetting.ts
+++ b/src/hooks/setting/useMenuSetting.ts
@@ -39,8 +39,6 @@ export function useMenuSetting() {
const getCollapsedShowTitle = computed(() => unref(getMenuSetting).collapsedShowTitle);
- const getCollapsedShowSearch = computed(() => unref(getMenuSetting).collapsedShowSearch);
-
const getTopMenuAlign = computed(() => unref(getMenuSetting).topMenuAlign);
const getIsSidebarType = computed(() => unref(getMenuType) === MenuTypeEnum.SIDEBAR);
@@ -63,13 +61,6 @@ export function useMenuSetting() {
return unref(getTrigger) === TriggerEnum.HEADER;
});
- const getShowSearch = computed(() => {
- return (
- unref(getMenuSetting).showSearch &&
- !(unref(getMenuType) === MenuTypeEnum.MIX && unref(getMenuMode) === MenuModeEnum.HORIZONTAL)
- );
- });
-
const getIsHorizontal = computed(() => {
return unref(getMenuMode) === MenuModeEnum.HORIZONTAL;
});
@@ -119,9 +110,7 @@ export function useMenuSetting() {
getMenuTheme,
getCanDrag,
getIsHorizontal,
- getShowSearch,
getCollapsedShowTitle,
- getCollapsedShowSearch,
getIsSidebarType,
getAccordion,
getShowTopMenu,
diff --git a/src/hooks/web/useDesign.ts b/src/hooks/web/useDesign.ts
new file mode 100644
index 00000000..c0131246
--- /dev/null
+++ b/src/hooks/web/useDesign.ts
@@ -0,0 +1,19 @@
+import { useAppProviderContext } from '/@/components/Application';
+import { computed } from 'vue';
+// import { useCssModule, reactive } from 'vue';
+export function useDesign(scope: string) {
+ const values = useAppProviderContext();
+ // const style = cssModule ? useCssModule() : {};
+
+ // if (cssModule) {
+ // Object.keys(style).forEach((key) => {
+ // const moduleCls = style[key];
+ // style[key] = `${cls}-${moduleCls}`;
+ // });
+ // }
+ return {
+ prefixCls: computed(() => `${values.prefixCls}-${scope}`),
+ prefixVar: values.prefixCls,
+ // style,
+ };
+}
diff --git a/src/hooks/web/useLocale.ts b/src/hooks/web/useLocale.ts
index 29d23762..ceba9add 100644
--- a/src/hooks/web/useLocale.ts
+++ b/src/hooks/web/useLocale.ts
@@ -27,7 +27,6 @@ export function useLocale() {
setLocalSetting({ lang });
// i18n.global.setLocaleMessage(locale, messages);
- antConfigLocaleRef.value = { a: 1 };
switch (lang) {
// Simplified Chinese
case 'zh_CN':
diff --git a/src/layouts/default/header/LayoutHeader.tsx b/src/layouts/default/header/LayoutHeader.tsx
index 85863924..2a5c4c3e 100644
--- a/src/layouts/default/header/LayoutHeader.tsx
+++ b/src/layouts/default/header/LayoutHeader.tsx
@@ -188,7 +188,6 @@ export default defineComponent({
theme={unref(getHeaderTheme)}
splitType={unref(getSplitType)}
menuMode={unref(getMenuMode)}
- showSearch={false}
/>
)}
diff --git a/src/layouts/default/menu/index.tsx b/src/layouts/default/menu/index.tsx
index dd0612f7..17e27938 100644
--- a/src/layouts/default/menu/index.tsx
+++ b/src/layouts/default/menu/index.tsx
@@ -27,9 +27,6 @@ export default defineComponent({
default: MenuSplitTyeEnum.NONE,
},
- // Whether to show search box
- showSearch: propTypes.bool.def(true),
-
isHorizontal: propTypes.bool,
// menu Mode
menuMode: {
@@ -42,11 +39,9 @@ export default defineComponent({
const {
setMenuSetting,
- getShowSearch,
getMenuMode,
getMenuType,
getCollapsedShowTitle,
- getCollapsedShowSearch,
getIsSidebarType,
getMenuTheme,
getCollapsed,
@@ -65,14 +60,6 @@ export default defineComponent({
const appendClass = computed(() => props.splitType === MenuSplitTyeEnum.TOP);
- const showSearch = computed(() => {
- return (
- unref(getShowSearch) &&
- props.showSearch &&
- (unref(getCollapsedShowSearch) ? true : !unref(getCollapsed))
- );
- });
-
/**
* click menu
* @param menu
@@ -122,7 +109,6 @@ export default defineComponent({
collapsedShowTitle={unref(getCollapsedShowTitle)}
theme={unref(getComputedMenuTheme)}
showLogo={unref(showLogo)}
- search={unref(showSearch)}
items={unref(menusRef)}
flatItems={unref(flatMenusRef)}
accordion={unref(getAccordion)}
diff --git a/src/layouts/default/setting/enum.ts b/src/layouts/default/setting/enum.ts
index 4159e8c7..87f52da4 100644
--- a/src/layouts/default/setting/enum.ts
+++ b/src/layouts/default/setting/enum.ts
@@ -21,7 +21,6 @@ export enum HandlerEnum {
MENU_SHOW_SIDEBAR,
MENU_THEME,
MENU_SPLIT,
- MENU_SHOW_SEARCH,
MENU_FIXED,
// header
diff --git a/src/layouts/default/setting/handler.ts b/src/layouts/default/setting/handler.ts
index 637ef2b5..877b05a7 100644
--- a/src/layouts/default/setting/handler.ts
+++ b/src/layouts/default/setting/handler.ts
@@ -63,9 +63,6 @@ export function handler(event: HandlerEnum, value: any): DeepPartial {
export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = {
path: '/:path(.*)*',
name: 'ErrorPage',
- redirect: '/error/404',
component: LAYOUT,
meta: {
title: 'ErrorPage',
@@ -33,7 +32,7 @@ export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = {
},
children: [
{
- path: '/error/404',
+ path: '/:path(.*)*',
name: 'ErrorPage',
component: EXCEPTION_COMPONENT,
meta: {
diff --git a/src/router/menus/index.ts b/src/router/menus/index.ts
index a305b0d3..295bc408 100644
--- a/src/router/menus/index.ts
+++ b/src/router/menus/index.ts
@@ -21,6 +21,9 @@ Object.keys(modules).forEach((key) => {
// ===========================
// ==========Helper===========
// ===========================
+const isBackMode = () => {
+ return appStore.getProjectConfig.permissionMode === PermissionModeEnum.BACK;
+};
const staticMenus: Menu[] = [];
(() => {
@@ -33,10 +36,6 @@ const staticMenus: Menu[] = [];
}
})();
-const isBackMode = () => {
- return appStore.getProjectConfig.permissionMode === PermissionModeEnum.BACK;
-};
-
async function getAsyncMenus() {
// 前端角色控制菜单 直接取菜单文件
if (!isBackMode()) {
diff --git a/src/settings/colorSetting.ts b/src/settings/colorSetting.ts
index d2a92d8c..1f573e35 100644
--- a/src/settings/colorSetting.ts
+++ b/src/settings/colorSetting.ts
@@ -17,9 +17,11 @@ export const HEADER_PRESET_BG_COLOR_LIST: string[] = [
export const SIDE_BAR_BG_COLOR_LIST: string[] = [
'#273352',
'#ffffff',
+ '#191b24',
'#191a23',
'#001529',
'#304156',
+ '#001628',
'#28333E',
'#344058',
];
diff --git a/src/settings/projectSetting.ts b/src/settings/projectSetting.ts
index 65c5c2d4..0eea034b 100644
--- a/src/settings/projectSetting.ts
+++ b/src/settings/projectSetting.ts
@@ -89,8 +89,6 @@ const setting: ProjectConfig = {
show: true,
// Whether to show dom
hidden: true,
- // Whether to show search box
- showSearch: true,
// Menu width
menuWidth: 210,
// Menu mode
diff --git a/src/types/config.d.ts b/src/types/config.d.ts
index da6e0982..99e20806 100644
--- a/src/types/config.d.ts
+++ b/src/types/config.d.ts
@@ -9,7 +9,6 @@ export interface MenuSetting {
collapsed: boolean;
collapsedShowTitle: boolean;
canDrag: boolean;
- showSearch: boolean;
show: boolean;
hidden: boolean;
split: boolean;