feat: add @vben/hooks and @vben-core/constants
parent
daa31f7156
commit
5e0b01c725
|
@ -12,8 +12,7 @@ import { getAllMenus } from '#/apis';
|
||||||
import { BasicLayout, IFrameView } from '#/layouts';
|
import { BasicLayout, IFrameView } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
const forbiddenComponent = () =>
|
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
|
||||||
import('#/views/_essential/fallback/forbidden.vue');
|
|
||||||
|
|
||||||
async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||||
const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
|
const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { useTitle } from '@vueuse/core';
|
||||||
|
|
||||||
import { generateAccess } from '#/forward';
|
import { generateAccess } from '#/forward';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { dynamicRoutes, essentialsRouteNames } from '#/router/routes';
|
import { coreRouteNames, dynamicRoutes } from '#/router/routes';
|
||||||
import { useAccessStore } from '#/store';
|
import { useAccessStore } from '#/store';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +63,7 @@ function setupAccessGuard(router: Router) {
|
||||||
if (!accessToken) {
|
if (!accessToken) {
|
||||||
if (
|
if (
|
||||||
// 基本路由,这些路由不需要进入权限拦截
|
// 基本路由,这些路由不需要进入权限拦截
|
||||||
essentialsRouteNames.includes(to.name as string) ||
|
coreRouteNames.includes(to.name as string) ||
|
||||||
// 明确声明忽略权限访问权限,则可以访问
|
// 明确声明忽略权限访问权限,则可以访问
|
||||||
to.meta.ignoreAccess
|
to.meta.ignoreAccess
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -4,11 +4,11 @@ import { DEFAULT_HOME_PATH } from '@vben/constants';
|
||||||
|
|
||||||
import { AuthPageLayout } from '#/layouts';
|
import { AuthPageLayout } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import Login from '#/views/_essential/authentication/login.vue';
|
import Login from '#/views/_core/authentication/login.vue';
|
||||||
|
|
||||||
/** 全局404页面 */
|
/** 全局404页面 */
|
||||||
const fallbackNotFoundRoute: RouteRecordRaw = {
|
const fallbackNotFoundRoute: RouteRecordRaw = {
|
||||||
component: () => import('#/views/_essential/fallback/not-found.vue'),
|
component: () => import('#/views/_core/fallback/not-found.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
hideInBreadcrumb: true,
|
hideInBreadcrumb: true,
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
|
@ -20,7 +20,7 @@ const fallbackNotFoundRoute: RouteRecordRaw = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 基本路由,这些路由是必须存在的 */
|
/** 基本路由,这些路由是必须存在的 */
|
||||||
const essentialsRoutes: RouteRecordRaw[] = [
|
const coreRoutes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
meta: {
|
meta: {
|
||||||
title: 'Root',
|
title: 'Root',
|
||||||
|
@ -42,47 +42,45 @@ const essentialsRoutes: RouteRecordRaw[] = [
|
||||||
path: 'login',
|
path: 'login',
|
||||||
component: Login,
|
component: Login,
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.essentials.login'),
|
title: $t('page.core.login'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'CodeLogin',
|
name: 'CodeLogin',
|
||||||
path: 'code-login',
|
path: 'code-login',
|
||||||
component: () =>
|
component: () => import('#/views/_core/authentication/code-login.vue'),
|
||||||
import('#/views/_essential/authentication/code-login.vue'),
|
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.essentials.codeLogin'),
|
title: $t('page.core.codeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'QrCodeLogin',
|
name: 'QrCodeLogin',
|
||||||
path: 'qrcode-login',
|
path: 'qrcode-login',
|
||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_essential/authentication/qrcode-login.vue'),
|
import('#/views/_core/authentication/qrcode-login.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.essentials.qrcodeLogin'),
|
title: $t('page.core.qrcodeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ForgetPassword',
|
name: 'ForgetPassword',
|
||||||
path: 'forget-password',
|
path: 'forget-password',
|
||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_essential/authentication/forget-password.vue'),
|
import('#/views/_core/authentication/forget-password.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.essentials.forgetPassword'),
|
title: $t('page.core.forgetPassword'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Register',
|
name: 'Register',
|
||||||
path: 'register',
|
path: 'register',
|
||||||
component: () =>
|
component: () => import('#/views/_core/authentication/register.vue'),
|
||||||
import('#/views/_essential/authentication/register.vue'),
|
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.essentials.register'),
|
title: $t('page.core.register'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export { essentialsRoutes, fallbackNotFoundRoute };
|
export { coreRoutes, fallbackNotFoundRoute };
|
|
@ -3,7 +3,7 @@ import type { RouteRecordRaw } from 'vue-router';
|
||||||
import { traverseTreeValues } from '@vben/utils';
|
import { traverseTreeValues } from '@vben/utils';
|
||||||
import { mergeRouteModules } from '@vben-core/helpers';
|
import { mergeRouteModules } from '@vben-core/helpers';
|
||||||
|
|
||||||
import { essentialsRoutes, fallbackNotFoundRoute } from './_essentials';
|
import { coreRoutes, fallbackNotFoundRoute } from './core';
|
||||||
|
|
||||||
const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
|
const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
|
||||||
eager: true,
|
eager: true,
|
||||||
|
@ -21,15 +21,12 @@ const staticRoutes: RouteRecordRaw[] = [];
|
||||||
|
|
||||||
/** 路由列表,由基本路由+静态路由组成 */
|
/** 路由列表,由基本路由+静态路由组成 */
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
...essentialsRoutes,
|
...coreRoutes,
|
||||||
...staticRoutes,
|
...staticRoutes,
|
||||||
fallbackNotFoundRoute,
|
fallbackNotFoundRoute,
|
||||||
];
|
];
|
||||||
|
|
||||||
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
||||||
const essentialsRouteNames = traverseTreeValues(
|
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
||||||
essentialsRoutes,
|
|
||||||
(route) => route.name,
|
|
||||||
);
|
|
||||||
|
|
||||||
export { dynamicRoutes, essentialsRouteNames, routes };
|
export { coreRouteNames, dynamicRoutes, routes };
|
||||||
|
|
|
@ -141,8 +141,7 @@ const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
name: 'Fallback403',
|
name: 'Fallback403',
|
||||||
path: '403',
|
path: '403',
|
||||||
component: () =>
|
component: () => import('#/views/_core/fallback/forbidden.vue'),
|
||||||
import('#/views/_essential/fallback/forbidden.vue'),
|
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:do-not-disturb-alt',
|
icon: 'mdi:do-not-disturb-alt',
|
||||||
title: '403',
|
title: '403',
|
||||||
|
@ -151,8 +150,7 @@ const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
name: 'Fallback404',
|
name: 'Fallback404',
|
||||||
path: '404',
|
path: '404',
|
||||||
component: () =>
|
component: () => import('#/views/_core/fallback/not-found.vue'),
|
||||||
import('#/views/_essential/fallback/not-found.vue'),
|
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:table-off',
|
icon: 'mdi:table-off',
|
||||||
title: '404',
|
title: '404',
|
||||||
|
@ -162,7 +160,7 @@ const routes: RouteRecordRaw[] = [
|
||||||
name: 'Fallback500',
|
name: 'Fallback500',
|
||||||
path: '500',
|
path: '500',
|
||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_essential/fallback/internal-error.vue'),
|
import('#/views/_core/fallback/internal-error.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:server-network-off',
|
icon: 'mdi:server-network-off',
|
||||||
title: '500',
|
title: '500',
|
||||||
|
@ -171,7 +169,7 @@ const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
name: 'FallbackOffline',
|
name: 'FallbackOffline',
|
||||||
path: 'offline',
|
path: 'offline',
|
||||||
component: () => import('#/views/_essential/fallback/offline.vue'),
|
component: () => import('#/views/_core/fallback/offline.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:offline',
|
icon: 'mdi:offline',
|
||||||
title: $t('fallback.offline'),
|
title: $t('fallback.offline'),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
import { VBEN_GITHUB_URL, VBEN_LOGO } from '@vben/constants';
|
import { VBEN_GITHUB_URL, VBEN_LOGO_URL } from '@vben/constants';
|
||||||
|
|
||||||
import { BasicLayout, IFrameView } from '#/layouts';
|
import { BasicLayout, IFrameView } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
@ -10,7 +10,7 @@ const routes: RouteRecordRaw[] = [
|
||||||
component: BasicLayout,
|
component: BasicLayout,
|
||||||
meta: {
|
meta: {
|
||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: VBEN_LOGO,
|
icon: VBEN_LOGO_URL,
|
||||||
order: 9999,
|
order: 9999,
|
||||||
title: 'Vben Admin',
|
title: 'Vben Admin',
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,7 @@ const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
name: 'VbenAbout',
|
name: 'VbenAbout',
|
||||||
path: 'about',
|
path: 'about',
|
||||||
component: () => import('#/views/_essential/vben/about/index.vue'),
|
component: () => import('#/views/_core/vben/about/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: 'mdi:creative-commons',
|
icon: 'mdi:creative-commons',
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
# \_essential
|
# \_core
|
||||||
|
|
||||||
此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。
|
此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"page": {
|
"page": {
|
||||||
"essentials": {
|
"core": {
|
||||||
"login": "Login",
|
"login": "Login",
|
||||||
"register": "Register",
|
"register": "Register",
|
||||||
"codeLogin": "Code Login",
|
"codeLogin": "Code Login",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"page": {
|
"page": {
|
||||||
"essentials": {
|
"core": {
|
||||||
"login": "登陆",
|
"login": "登陆",
|
||||||
"register": "注册",
|
"register": "注册",
|
||||||
"codeLogin": "验证码登陆",
|
"codeLogin": "验证码登陆",
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { defineBuildConfig } from 'unbuild';
|
||||||
|
|
||||||
|
export default defineBuildConfig({
|
||||||
|
clean: true,
|
||||||
|
declaration: true,
|
||||||
|
entries: ['src/index'],
|
||||||
|
});
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"name": "@vben-core/constants",
|
||||||
|
"version": "5.0.0",
|
||||||
|
"homepage": "https://github.com/vbenjs/vue-vben-admin",
|
||||||
|
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
|
||||||
|
"directory": "packages/@vben-core/shared/constants"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "pnpm unbuild",
|
||||||
|
"stub": "pnpm unbuild --stub"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"sideEffects": false,
|
||||||
|
"main": "./dist/index.mjs",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./src/index.ts",
|
||||||
|
"development": "./src/index.ts",
|
||||||
|
"default": "./dist/index.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"default": "./dist/index.mjs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ const VBEN_GITHUB_URL = 'https://github.com/vbenjs/vue-vben-admin';
|
||||||
/**
|
/**
|
||||||
* @zh_CN Vben Logo
|
* @zh_CN Vben Logo
|
||||||
*/
|
*/
|
||||||
const VBEN_LOGO =
|
const VBEN_LOGO_URL =
|
||||||
'https://cdn.jsdelivr.net/npm/@vbenjs/static-source@0.1.3/source/logo-v1.webp';
|
'https://cdn.jsdelivr.net/npm/@vbenjs/static-source@0.1.3/source/logo-v1.webp';
|
||||||
export { VBEN_GITHUB_URL, VBEN_LOGO };
|
|
||||||
|
export { VBEN_GITHUB_URL, VBEN_LOGO_URL };
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
|
"extends": "@vben/tsconfig/library.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
export type * from './app';
|
export type * from './app';
|
||||||
export * from './basic';
|
export type * from './basic';
|
||||||
export type * from './helper';
|
export type * from './helper';
|
||||||
export type * from './menu-record';
|
export type * from './menu-record';
|
||||||
export type * from './tabs';
|
export type * from './tabs';
|
||||||
|
|
|
@ -36,5 +36,8 @@
|
||||||
"default": "./dist/index.mjs"
|
"default": "./dist/index.mjs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@vben-core/constants": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export * from './_essentials';
|
export * from './core';
|
||||||
export * from './vben';
|
export * from '@vben-core/constants';
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { defineBuildConfig } from 'unbuild';
|
||||||
|
|
||||||
|
export default defineBuildConfig({
|
||||||
|
clean: true,
|
||||||
|
declaration: true,
|
||||||
|
entries: ['src/index'],
|
||||||
|
});
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"name": "@vben/hooks",
|
||||||
|
"version": "5.0.0",
|
||||||
|
"homepage": "https://github.com/vbenjs/vue-vben-admin",
|
||||||
|
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
|
||||||
|
"directory": "packages/hooks"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "pnpm unbuild",
|
||||||
|
"stub": "pnpm unbuild --stub"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"sideEffects": [
|
||||||
|
"**/*.css"
|
||||||
|
],
|
||||||
|
"main": "./dist/index.mjs",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./src/index.ts",
|
||||||
|
"development": "./src/index.ts",
|
||||||
|
"default": "./dist/index.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"default": "./dist/index.mjs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
|
"extends": "@vben/tsconfig/library.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
|
@ -639,6 +639,8 @@ importers:
|
||||||
specifier: ^9.13.1
|
specifier: ^9.13.1
|
||||||
version: 9.13.1(vue@3.4.31(typescript@5.5.3))
|
version: 9.13.1(vue@3.4.31(typescript@5.5.3))
|
||||||
|
|
||||||
|
packages/@core/shared/constants: {}
|
||||||
|
|
||||||
packages/@core/shared/design:
|
packages/@core/shared/design:
|
||||||
dependencies:
|
dependencies:
|
||||||
modern-normalize:
|
modern-normalize:
|
||||||
|
@ -908,7 +910,13 @@ importers:
|
||||||
specifier: ^1.5.5
|
specifier: ^1.5.5
|
||||||
version: 1.5.5
|
version: 1.5.5
|
||||||
|
|
||||||
packages/constants: {}
|
packages/constants:
|
||||||
|
dependencies:
|
||||||
|
'@vben-core/constants':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../@core/shared/constants
|
||||||
|
|
||||||
|
packages/hooks: {}
|
||||||
|
|
||||||
packages/icons:
|
packages/icons:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -64,6 +64,10 @@
|
||||||
"name": "@vben-core/locales",
|
"name": "@vben-core/locales",
|
||||||
"path": "packages/@core/locales",
|
"path": "packages/@core/locales",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "@vben-core/constants",
|
||||||
|
"path": "packages/@core/shared/constants",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "@vben-core/design",
|
"name": "@vben-core/design",
|
||||||
"path": "packages/@core/shared/design",
|
"path": "packages/@core/shared/design",
|
||||||
|
@ -116,6 +120,10 @@
|
||||||
"name": "@vben/constants",
|
"name": "@vben/constants",
|
||||||
"path": "packages/constants",
|
"path": "packages/constants",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "@vben/hooks",
|
||||||
|
"path": "packages/hooks",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "@vben/icons",
|
"name": "@vben/icons",
|
||||||
"path": "packages/icons",
|
"path": "packages/icons",
|
||||||
|
|
Loading…
Reference in New Issue