diff --git a/cfg.ts b/cfg.ts index e63dc75a..e18666c3 100644 --- a/cfg.ts +++ b/cfg.ts @@ -43,6 +43,12 @@ import { buildOptions, mixinCSSPlugin, } from './vite-plugin/index' +import { APP_PRIMARY_COLOR } from './src/appConfig/designConfig' +import { + PRE_LOADING_CONFIG, + ROOT_ROUTE, + SIDE_BAR_LOGO, +} from './src/appConfig/appConfig' import type { AppConfigExport } from './src/types/cfg' @@ -50,44 +56,11 @@ const config: AppConfigExport = { /** 公共基础路径配置, 如果为空则会默认以 '/' 填充 */ base: '/ray-template/', /** 配置首屏加载信息 */ - preloadingConfig: { - title: 'Ray Template', - tagColor: '#ff6700', - titleColor: '#2d8cf0', - }, + preloadingConfig: PRE_LOADING_CONFIG, /** 默认主题色(不可省略, 必填), 也用于 ejs 注入 */ - appPrimaryColor: { - /** 主题色 */ - primaryColor: '#2d8cf0', - /** 主题辅助色(用于整体 hover、active 等之类颜色) */ - primaryFadeColor: 'rgba(45, 140, 240, 0.3)', - }, - /** - * - * 配置根页面 - * 该项目所有重定向至首页, 都依赖该配置项 - * - * 如果修改了该项目的首页路由配置, 需要更改该配置项, 以免重定向首页操作出现错误 - */ - rootRoute: { - name: 'dashboard', - path: '/dashboard', - }, - /** - * - * icon: LOGO 图标, 依赖 `RayIcon` 实现(如果为空则不会渲染图标) - * title: LOGO 标题 - * url: 点击跳转地址, 如果不配置该属性, 则不会触发跳转 - * jumpType: 跳转类型(station: 项目内跳转, outsideStation: 新页面打开) - * - * 如果不设置该属性或者为空, 则不会渲染 LOGO - */ - sideBarLogo: { - icon: 'ray', - title: 'Ray Template', - url: '/dashboard', - jumpType: 'station', - }, + appPrimaryColor: APP_PRIMARY_COLOR, + rootRoute: ROOT_ROUTE, + sideBarLogo: SIDE_BAR_LOGO, /** * * 预处理全局需要注入的 css 文件 diff --git a/src/appConfig/appConfig.ts b/src/appConfig/appConfig.ts new file mode 100644 index 00000000..3b0f5aa2 --- /dev/null +++ b/src/appConfig/appConfig.ts @@ -0,0 +1,53 @@ +/** + * + * @author Ray + * + * @date 2023-05-23 + * + * @workspace ray-template + * + * @remark 今天也是元气满满撸代码的一天 + */ + +/** 系统配置 */ + +import type { + LayoutSideBarLogo, + PreloadingConfig, + RootRoute, +} from '../types/cfg' + +/** 首屏加载信息配置 */ +export const PRE_LOADING_CONFIG: PreloadingConfig = { + title: 'Ray Template', + tagColor: '#ff6700', + titleColor: '#2d8cf0', +} + +/** + * + * 配置根页面 + * 该项目所有重定向至首页, 都依赖该配置项 + * + * 如果修改了该项目的首页路由配置, 需要更改该配置项, 以免重定向首页操作出现错误 + */ +export const ROOT_ROUTE: RootRoute = { + name: 'Dashboard', + path: '/dashboard', +} + +/** + * + * icon: LOGO 图标, 依赖 `RayIcon` 实现(如果为空则不会渲染图标) + * title: LOGO 标题 + * url: 点击跳转地址, 如果不配置该属性, 则不会触发跳转 + * jumpType: 跳转类型(station: 项目内跳转, outsideStation: 新页面打开) + * + * 如果不设置该属性或者为空, 则不会渲染 LOGO + */ +export const SIDE_BAR_LOGO: LayoutSideBarLogo = { + icon: 'ray', + title: 'Ray Template', + url: '/dashboard', + jumpType: 'station', +} diff --git a/src/appConfig/designConfig.ts b/src/appConfig/designConfig.ts index 1f96a2e2..9271af84 100644 --- a/src/appConfig/designConfig.ts +++ b/src/appConfig/designConfig.ts @@ -11,6 +11,8 @@ /** 系统颜色风格配置入口 */ +import type { AppPrimaryColor } from '../types/cfg' + /** * * 系统主题颜色预设色盘 @@ -26,3 +28,11 @@ export const APP_THEME_COLOR = [ '#ff9800', '#18A058', ] + +/** 系统主题色 */ +export const APP_PRIMARY_COLOR: AppPrimaryColor = { + /** 主题色 */ + primaryColor: '#2d8cf0', + /** 主题辅助色(用于整体 hover、active 等之类颜色) */ + primaryFadeColor: 'rgba(45, 140, 240, 0.3)', +} diff --git a/src/router/type.ts b/src/router/type.ts index 1a557b5b..7007f4d5 100644 --- a/src/router/type.ts +++ b/src/router/type.ts @@ -2,9 +2,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import type { RouteRecordRaw } from 'vue-router' import type { Recordable } from '@/types/type-utils' +import type { DefineComponent } from 'vue' export type Component = - | ReturnType + | DefineComponent<{}, {}, any> | (() => Promise) | (() => Promise) diff --git a/tsconfig.node.json b/tsconfig.node.json index 1ecfb322..4de1a9c5 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -11,8 +11,9 @@ "vite-plugin/index.ts", "vite-plugin/type.ts", "cfg.ts", - "src/types/cfg.ts", + "src/types/*.ts", "package.json", - "vite-env.d.ts" + "vite-env.d.ts", + "src/appConfig/*.ts" ] }