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 { $t } from '#/locales';
|
||||
|
||||
const forbiddenComponent = () =>
|
||||
import('#/views/_essential/fallback/forbidden.vue');
|
||||
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
|
||||
|
||||
async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||
const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
|
||||
|
|
|
@ -8,7 +8,7 @@ import { useTitle } from '@vueuse/core';
|
|||
|
||||
import { generateAccess } from '#/forward';
|
||||
import { $t } from '#/locales';
|
||||
import { dynamicRoutes, essentialsRouteNames } from '#/router/routes';
|
||||
import { coreRouteNames, dynamicRoutes } from '#/router/routes';
|
||||
import { useAccessStore } from '#/store';
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ function setupAccessGuard(router: Router) {
|
|||
if (!accessToken) {
|
||||
if (
|
||||
// 基本路由,这些路由不需要进入权限拦截
|
||||
essentialsRouteNames.includes(to.name as string) ||
|
||||
coreRouteNames.includes(to.name as string) ||
|
||||
// 明确声明忽略权限访问权限,则可以访问
|
||||
to.meta.ignoreAccess
|
||||
) {
|
||||
|
|
|
@ -4,11 +4,11 @@ import { DEFAULT_HOME_PATH } from '@vben/constants';
|
|||
|
||||
import { AuthPageLayout } from '#/layouts';
|
||||
import { $t } from '#/locales';
|
||||
import Login from '#/views/_essential/authentication/login.vue';
|
||||
import Login from '#/views/_core/authentication/login.vue';
|
||||
|
||||
/** 全局404页面 */
|
||||
const fallbackNotFoundRoute: RouteRecordRaw = {
|
||||
component: () => import('#/views/_essential/fallback/not-found.vue'),
|
||||
component: () => import('#/views/_core/fallback/not-found.vue'),
|
||||
meta: {
|
||||
hideInBreadcrumb: true,
|
||||
hideInMenu: true,
|
||||
|
@ -20,7 +20,7 @@ const fallbackNotFoundRoute: RouteRecordRaw = {
|
|||
};
|
||||
|
||||
/** 基本路由,这些路由是必须存在的 */
|
||||
const essentialsRoutes: RouteRecordRaw[] = [
|
||||
const coreRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
meta: {
|
||||
title: 'Root',
|
||||
|
@ -42,47 +42,45 @@ const essentialsRoutes: RouteRecordRaw[] = [
|
|||
path: 'login',
|
||||
component: Login,
|
||||
meta: {
|
||||
title: $t('page.essentials.login'),
|
||||
title: $t('page.core.login'),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'CodeLogin',
|
||||
path: 'code-login',
|
||||
component: () =>
|
||||
import('#/views/_essential/authentication/code-login.vue'),
|
||||
component: () => import('#/views/_core/authentication/code-login.vue'),
|
||||
meta: {
|
||||
title: $t('page.essentials.codeLogin'),
|
||||
title: $t('page.core.codeLogin'),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'QrCodeLogin',
|
||||
path: 'qrcode-login',
|
||||
component: () =>
|
||||
import('#/views/_essential/authentication/qrcode-login.vue'),
|
||||
import('#/views/_core/authentication/qrcode-login.vue'),
|
||||
meta: {
|
||||
title: $t('page.essentials.qrcodeLogin'),
|
||||
title: $t('page.core.qrcodeLogin'),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ForgetPassword',
|
||||
path: 'forget-password',
|
||||
component: () =>
|
||||
import('#/views/_essential/authentication/forget-password.vue'),
|
||||
import('#/views/_core/authentication/forget-password.vue'),
|
||||
meta: {
|
||||
title: $t('page.essentials.forgetPassword'),
|
||||
title: $t('page.core.forgetPassword'),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Register',
|
||||
path: 'register',
|
||||
component: () =>
|
||||
import('#/views/_essential/authentication/register.vue'),
|
||||
component: () => import('#/views/_core/authentication/register.vue'),
|
||||
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 { mergeRouteModules } from '@vben-core/helpers';
|
||||
|
||||
import { essentialsRoutes, fallbackNotFoundRoute } from './_essentials';
|
||||
import { coreRoutes, fallbackNotFoundRoute } from './core';
|
||||
|
||||
const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
|
||||
eager: true,
|
||||
|
@ -21,15 +21,12 @@ const staticRoutes: RouteRecordRaw[] = [];
|
|||
|
||||
/** 路由列表,由基本路由+静态路由组成 */
|
||||
const routes: RouteRecordRaw[] = [
|
||||
...essentialsRoutes,
|
||||
...coreRoutes,
|
||||
...staticRoutes,
|
||||
fallbackNotFoundRoute,
|
||||
];
|
||||
|
||||
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
||||
const essentialsRouteNames = traverseTreeValues(
|
||||
essentialsRoutes,
|
||||
(route) => route.name,
|
||||
);
|
||||
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
||||
|
||||
export { dynamicRoutes, essentialsRouteNames, routes };
|
||||
export { coreRouteNames, dynamicRoutes, routes };
|
||||
|
|
|
@ -141,8 +141,7 @@ const routes: RouteRecordRaw[] = [
|
|||
{
|
||||
name: 'Fallback403',
|
||||
path: '403',
|
||||
component: () =>
|
||||
import('#/views/_essential/fallback/forbidden.vue'),
|
||||
component: () => import('#/views/_core/fallback/forbidden.vue'),
|
||||
meta: {
|
||||
icon: 'mdi:do-not-disturb-alt',
|
||||
title: '403',
|
||||
|
@ -151,8 +150,7 @@ const routes: RouteRecordRaw[] = [
|
|||
{
|
||||
name: 'Fallback404',
|
||||
path: '404',
|
||||
component: () =>
|
||||
import('#/views/_essential/fallback/not-found.vue'),
|
||||
component: () => import('#/views/_core/fallback/not-found.vue'),
|
||||
meta: {
|
||||
icon: 'mdi:table-off',
|
||||
title: '404',
|
||||
|
@ -162,7 +160,7 @@ const routes: RouteRecordRaw[] = [
|
|||
name: 'Fallback500',
|
||||
path: '500',
|
||||
component: () =>
|
||||
import('#/views/_essential/fallback/internal-error.vue'),
|
||||
import('#/views/_core/fallback/internal-error.vue'),
|
||||
meta: {
|
||||
icon: 'mdi:server-network-off',
|
||||
title: '500',
|
||||
|
@ -171,7 +169,7 @@ const routes: RouteRecordRaw[] = [
|
|||
{
|
||||
name: 'FallbackOffline',
|
||||
path: 'offline',
|
||||
component: () => import('#/views/_essential/fallback/offline.vue'),
|
||||
component: () => import('#/views/_core/fallback/offline.vue'),
|
||||
meta: {
|
||||
icon: 'mdi:offline',
|
||||
title: $t('fallback.offline'),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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 { $t } from '#/locales';
|
||||
|
@ -10,7 +10,7 @@ const routes: RouteRecordRaw[] = [
|
|||
component: BasicLayout,
|
||||
meta: {
|
||||
badgeType: 'dot',
|
||||
icon: VBEN_LOGO,
|
||||
icon: VBEN_LOGO_URL,
|
||||
order: 9999,
|
||||
title: 'Vben Admin',
|
||||
},
|
||||
|
@ -21,7 +21,7 @@ const routes: RouteRecordRaw[] = [
|
|||
{
|
||||
name: 'VbenAbout',
|
||||
path: 'about',
|
||||
component: () => import('#/views/_essential/vben/about/index.vue'),
|
||||
component: () => import('#/views/_core/vben/about/index.vue'),
|
||||
meta: {
|
||||
badgeType: 'dot',
|
||||
icon: 'mdi:creative-commons',
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# \_essential
|
||||
# \_core
|
||||
|
||||
此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"page": {
|
||||
"essentials": {
|
||||
"core": {
|
||||
"login": "Login",
|
||||
"register": "Register",
|
||||
"codeLogin": "Code Login",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"page": {
|
||||
"essentials": {
|
||||
"core": {
|
||||
"login": "登陆",
|
||||
"register": "注册",
|
||||
"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
|
||||
*/
|
||||
const VBEN_LOGO =
|
||||
const VBEN_LOGO_URL =
|
||||
'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 * from './basic';
|
||||
export type * from './basic';
|
||||
export type * from './helper';
|
||||
export type * from './menu-record';
|
||||
export type * from './tabs';
|
||||
|
|
|
@ -36,5 +36,8 @@
|
|||
"default": "./dist/index.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@vben-core/constants": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
export * from './_essentials';
|
||||
export * from './vben';
|
||||
export * from './core';
|
||||
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
|
||||
version: 9.13.1(vue@3.4.31(typescript@5.5.3))
|
||||
|
||||
packages/@core/shared/constants: {}
|
||||
|
||||
packages/@core/shared/design:
|
||||
dependencies:
|
||||
modern-normalize:
|
||||
|
@ -908,7 +910,13 @@ importers:
|
|||
specifier: ^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:
|
||||
dependencies:
|
||||
|
|
|
@ -64,6 +64,10 @@
|
|||
"name": "@vben-core/locales",
|
||||
"path": "packages/@core/locales",
|
||||
},
|
||||
{
|
||||
"name": "@vben-core/constants",
|
||||
"path": "packages/@core/shared/constants",
|
||||
},
|
||||
{
|
||||
"name": "@vben-core/design",
|
||||
"path": "packages/@core/shared/design",
|
||||
|
@ -116,6 +120,10 @@
|
|||
"name": "@vben/constants",
|
||||
"path": "packages/constants",
|
||||
},
|
||||
{
|
||||
"name": "@vben/hooks",
|
||||
"path": "packages/hooks",
|
||||
},
|
||||
{
|
||||
"name": "@vben/icons",
|
||||
"path": "packages/icons",
|
||||
|
|
Loading…
Reference in New Issue