diff --git a/CHANGELOG.md b/CHANGELOG.md index 82926a5f..8dbedda5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # CHANGE LOG +## 5.0.0 + +## Feats + +- `RTable` 组件现在默认 `attrs` 透传不会再透传至 `Table` 而是透传至容器 `Card` +- `AppAvatar` 组件获取用户信息由 `localStorage` 缓存获取变更为 `getSigningCallback` 响应式获取 +- 移除 `SUPER_ADMIN` 默认值 +- 移除 `APP_KEEP_ALIVE` 配置项,迁移至 `settingStore` +- 移除 `SIDE_BAR_LOGO_DEFAULT` 配置项,迁移至 `settingStore` +- 移除 `APP_MENU_CONFIG` 配置项,迁移至 `settingStore` +- 移除所有的 `ray-template` 相关注释信息 +- `SettingDrawer` 新增更多配置项,允许通过配置入口配置更多的配置项 +- 新增 `DatePicker`, `InputNumber` 样式,默认设置 `width` 为 `100%` +- 新增 `updateObjectValue` 方法,并且全局替换重复类似方法 +- `useTheme` 新增 `syncSystemTheme` 方法,允许同步系统主题 +- 新增 `ThemeSegment` 主题切换组件 +- 移除 `watchOnce` 方法引入,使用原生 `watch` 方法替代 +- 取消 `SettingDrawer` 自动聚焦可选中元素 + ## 4.9.7 从该版本开始,默认关闭了 `cdn` 构建生产环境;因为国内厂商真心不给力。 diff --git a/mock/shared/database.ts b/mock/shared/database.ts index 91b817c5..54da93de 100644 --- a/mock/shared/database.ts +++ b/mock/shared/database.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import Mock from 'mockjs' /** diff --git a/mock/shared/utils.ts b/mock/shared/utils.ts index 94ccd564..c1e2a811 100644 --- a/mock/shared/utils.ts +++ b/mock/shared/utils.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /* eslint-disable @typescript-eslint/no-explicit-any */ export function array(length: number) { diff --git a/package.json b/package.json index 37e52f48..612f3c1f 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ray-template", "private": false, - "version": "4.9.7", + "version": "5.0.0", "type": "module", "engines": { "node": "^18.0.0 || >=20.0.0", diff --git a/src/api/demo/test.ts b/src/api/demo/test.ts index d02130e4..103f04e0 100644 --- a/src/api/demo/test.ts +++ b/src/api/demo/test.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-03-31 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 该方法演示如何封装一个通用请求方法 diff --git a/src/app-components/app/AppAvatar/index.tsx b/src/app-components/app/AppAvatar/index.tsx index 596c5984..59b7c10b 100644 --- a/src/app-components/app/AppAvatar/index.tsx +++ b/src/app-components/app/AppAvatar/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-05-31 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 系统管理员头像与名称 @@ -17,17 +6,13 @@ * 默认读取本地 session catch 缓存 */ -import './index.scss' - import { NAvatar, NButton, NFlex } from 'naive-ui' import { avatarProps } from 'naive-ui' -import { APP_CATCH_KEY } from '@/app-config' -import { getStorage } from '@/utils' +import { useSigningGetters } from '@/store' import type { PropType } from 'vue' import type { AvatarProps, FlexProps } from 'naive-ui' -import type { SigningCallback } from '@/store/modules/signing/types' const AppAvatar = defineComponent({ name: 'AppAvatar', @@ -50,30 +35,27 @@ const AppAvatar = defineComponent({ default: false, }, }, - setup(props) { - const signing = getStorage( - APP_CATCH_KEY.signing, - 'localStorage', - ) + setup() { + const { getSigningCallback } = useSigningGetters() return { - signing, + getSigningCallback, } }, render() { - const { signing, avatarSize, spaceSize, $props, vertical } = this + const { getSigningCallback, avatarSize, spaceSize, $props, vertical } = this return ( - {signing?.name} + {getSigningCallback?.name} ) diff --git a/src/app-components/app/AppGlobalSpin/index.tsx b/src/app-components/app/AppGlobalSpin/index.tsx index 928924df..c18c58b2 100644 --- a/src/app-components/app/AppGlobalSpin/index.tsx +++ b/src/app-components/app/AppGlobalSpin/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-01-18 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 全屏加载效果 diff --git a/src/app-components/app/AppLockScreen/appLockVar.ts b/src/app-components/app/AppLockScreen/appLockVar.ts index b1698403..1937bc1f 100644 --- a/src/app-components/app/AppLockScreen/appLockVar.ts +++ b/src/app-components/app/AppLockScreen/appLockVar.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-20 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 统一管理是否处于锁屏状态 diff --git a/src/app-components/app/AppLockScreen/components/LockScreen/index.tsx b/src/app-components/app/AppLockScreen/components/LockScreen/index.tsx index ba3933eb..57a2d2f7 100644 --- a/src/app-components/app/AppLockScreen/components/LockScreen/index.tsx +++ b/src/app-components/app/AppLockScreen/components/LockScreen/index.tsx @@ -1,16 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-20 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** 锁屏界面 */ - import { NInput, NForm, NFormItem, NButton } from 'naive-ui' import useAppLockScreen from '@/app-components/app/AppLockScreen/appLockVar' diff --git a/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx b/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx index 477994eb..60aaa5b3 100644 --- a/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx +++ b/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx @@ -1,16 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-20 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** 解锁界面 */ - import { NInput, NForm, NFormItem, NButton, NFlex } from 'naive-ui' import AppAvatar from '@/app-components/app/AppAvatar' diff --git a/src/app-components/app/AppLockScreen/index.tsx b/src/app-components/app/AppLockScreen/index.tsx index 8394700c..9cb1aed0 100644 --- a/src/app-components/app/AppLockScreen/index.tsx +++ b/src/app-components/app/AppLockScreen/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-05-13 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 这里没有做解锁密码校验, 只要符合校验规则值皆可 diff --git a/src/app-components/app/AppLockScreen/shared.ts b/src/app-components/app/AppLockScreen/shared.ts index 97ab8661..51643e88 100644 --- a/src/app-components/app/AppLockScreen/shared.ts +++ b/src/app-components/app/AppLockScreen/shared.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-20 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import type { InputInst } from 'naive-ui' import type { Ref } from 'vue' diff --git a/src/app-components/app/AppShareLink/index.tsx b/src/app-components/app/AppShareLink/index.tsx index 83d11cbb..6ba72bfd 100644 --- a/src/app-components/app/AppShareLink/index.tsx +++ b/src/app-components/app/AppShareLink/index.tsx @@ -1,8 +1,3 @@ -/** - * - * 友情链接组件,无实际项目意义 - */ - import { NAvatar, NTooltip, NFlex } from 'naive-ui' interface AvatarOptions { diff --git a/src/app-components/provider/AppNaiveGlobalProvider/index.tsx b/src/app-components/provider/AppNaiveGlobalProvider/index.tsx index f0b042fa..d463483f 100644 --- a/src/app-components/provider/AppNaiveGlobalProvider/index.tsx +++ b/src/app-components/provider/AppNaiveGlobalProvider/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-14 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 全局注入 naive ui 提示性组件 diff --git a/src/app-components/provider/AppRequestCancelerProvider/index.tsx b/src/app-components/provider/AppRequestCancelerProvider/index.tsx index ad8838f4..aa8a74ba 100644 --- a/src/app-components/provider/AppRequestCancelerProvider/index.tsx +++ b/src/app-components/provider/AppRequestCancelerProvider/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-07-21 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 路由更新前,取消上一路由所有请求 diff --git a/src/app-components/provider/AppStyleProvider/index.tsx b/src/app-components/provider/AppStyleProvider/index.tsx index c59f4815..83a3cde1 100644 --- a/src/app-components/provider/AppStyleProvider/index.tsx +++ b/src/app-components/provider/AppStyleProvider/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-07-08 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { get } from 'lodash-es' import { setClass, diff --git a/src/app-components/provider/AppVersionProvider/index.tsx b/src/app-components/provider/AppVersionProvider/index.tsx index 2dcef8b7..86453308 100644 --- a/src/app-components/provider/AppVersionProvider/index.tsx +++ b/src/app-components/provider/AppVersionProvider/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-01-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 检测当前版本是否为最新版本 diff --git a/src/app-components/provider/AppWatermarkProvider/index.tsx b/src/app-components/provider/AppWatermarkProvider/index.tsx index 41784da8..b068dd9b 100644 --- a/src/app-components/provider/AppWatermarkProvider/index.tsx +++ b/src/app-components/provider/AppWatermarkProvider/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-21 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 全局水印注入 diff --git a/src/app-config/app-config.ts b/src/app-config/app-config.ts index 15928f49..720057fe 100644 --- a/src/app-config/app-config.ts +++ b/src/app-config/app-config.ts @@ -1,18 +1,4 @@ -/** - * - * @author Ray - * - * @date 2023-05-23 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** 系统配置 */ - -import type { LayoutSideBarLogo, PreloadingConfig } from '@/types' -import type { AppMenuConfig, AppKeepAlive } from '@/types' +import type { AppMenuConfig, PreloadingConfig } from '@/types' import type { MessageProviderProps } from 'naive-ui' /** @@ -30,8 +16,9 @@ export const MESSAGE_PROVIDER: MessageProviderProps = { /** * + * @description * 是否启用路由切换 spin 加载; - * 如果启用该配置项,啧会在路由更新时触发内容区域的加载状态,直到路由加载完成。 + * 如果启用该配置项,则会在路由更新时触发内容区域的加载状态,直到路由加载完成。 * * 在 v4.7.5 版本后,默认关闭了该配置项。 */ @@ -39,25 +26,11 @@ export const LAYOUT_CONTENT_SPIN_WHEN_ROUTE_CHANGE = false /** * - * 全局 Spin 加载内容 + * @description + * 全局 Spin 加载内容。 */ export const APP_GLOBAL_LOADING = 'loading' -/** - * - * 系统缓存 - * - * 说明: - * - setupKeepAlive: 是否启用系统页面缓存, 设置为 false 则关闭系统页面缓存 - * - keepAliveExclude: 排除哪些页面不缓存 - * - maxKeepAliveLength: 最大缓存页面数量 - */ -export const APP_KEEP_ALIVE: Readonly = { - setupKeepAlive: true, - keepAliveExclude: [], - maxKeepAliveLength: 5, -} - /** * * 首屏加载信息配置 @@ -71,61 +44,26 @@ export const PRE_LOADING_CONFIG: PreloadingConfig = { /** * - * icon: LOGO 图标, 依赖 `RIcon` 实现(如果为空则不会渲染图标);4.8.2 版本后支持 VNode - * title: LOGO 标题 - * url: 点击跳转地址, 如果不配置该属性, 则不会触发跳转 - * jumpType: 跳转类型(station: 项目内跳转, outsideStation: 新页面打开) + * @description + * 系统缓存 key 前缀。 + * 可以选择自定义缓存 key 前缀,在使用 getStorage 和 setStorage 时可以考虑是否启用前缀的方式来避免缓存 key 冲突。 + * 该配置项也可以结合 APP_CATCH_KEY 使用。 * - * 如果不设置该属性或者为空, 则不会渲染 LOGO - */ -export const SIDE_BAR_LOGO_DEFAULT: LayoutSideBarLogo | undefined = { - icon: 'ray', - title: 'Ray Template', - url: '/dashboard', - jumpType: 'station', -} - -/** + * 值得注意的是,该方法整合进了 cache.ts 方法包中。也就是说只要该配置项不为空字符串则会自动启用缓存前缀。 * - * 系统菜单折叠配置 - * - * menuCollapsedWidth 配置仅当 menuCollapsedMode 为 width 风格时才有效 - * - * menuCollapsedMode: - * - transform: 边栏将只会移动它的位置而不会改变宽度 - * - width: Sider 的内容宽度将会被实际改变 - * menuCollapsedIconSize 配置菜单未折叠时图标的大小 - * menuCollapsedIndent 配置菜单每级的缩进 - * menuAccordion 手风琴模式 - */ -export const APP_MENU_CONFIG: Readonly = { - menuCollapsedWidth: 64, - menuCollapsedMode: 'width', - menuCollapsedIconSize: 22, - menuCollapsedIndent: 24, - menuAccordion: false, -} - -/** - * - * 系统缓存 key 前缀 - * 可以选择自定义缓存 key 前缀,在使用 getStorage 和 setStorage 时可以考虑是否启用前缀的方式来避免缓存 key 冲突 - * 该配置项也可以结合 APP_CATCH_KEY 使用 - * - * 值得注意的是,该方法整合进了 cache.ts 方法包中。也就是说只要该配置项不为空字符串则会自动启用缓存前缀 - * - * 默认不启用 + * 默认不启用。 * * @example * export const APP_CATCH_KEY_PREFIX = 'ray-template:' * - * 'ray-template:signing' // 会自动拼接为 + * 转换后的缓存 key: ray-template:signing。 */ export const APP_CATCH_KEY_PREFIX = '' /** * - * 系统默认缓存 key 配置 + * @description + * 系统默认缓存 key 配置。 * * 说明: * - signing: 登陆信息缓存 key @@ -154,9 +92,10 @@ export const APP_CATCH_KEY = { /** * - * 系统内容切换动画配置 - * 但是在配置的时候,会自动拼接一个 `transform` 前缀 - * 例如: `transform-fade-bottom` + * @description + * 系统内容切换动画配置。 + * 但是在配置的时候,会自动拼接一个 transform 前缀。 + * 例如: transform-fade-bottom。 */ export const CONTENT_TRANSITION_OPTIONS = [ { diff --git a/src/app-config/design-config.ts b/src/app-config/design-config.ts index 4494e28d..34eb9a21 100644 --- a/src/app-config/design-config.ts +++ b/src/app-config/design-config.ts @@ -1,16 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-05-19 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** 系统颜色风格配置入口 */ - import type { AppTheme } from '@/types' export const APP_THEME: AppTheme = { diff --git a/src/app-config/local-config.ts b/src/app-config/local-config.ts index 9834f3ef..4c5285be 100644 --- a/src/app-config/local-config.ts +++ b/src/app-config/local-config.ts @@ -1,16 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-05-19 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** 国际化相关配置 */ - import type { TemplateLocale, LocalOptions, DayjsLocalMap } from '@/types' import type { ValueOf } from '@/types' diff --git a/src/app-config/regex-config.ts b/src/app-config/regex-config.ts index ab84168c..40e19590 100644 --- a/src/app-config/regex-config.ts +++ b/src/app-config/regex-config.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-12 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 正则入口 diff --git a/src/app-config/request-config.ts b/src/app-config/request-config.ts index c8bc8e31..bd058d50 100644 --- a/src/app-config/request-config.ts +++ b/src/app-config/request-config.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import type { AxiosConfig } from '@/types' /** axios 相关配置 */ diff --git a/src/app-config/router-config.ts b/src/app-config/router-config.ts index c8e07d12..ff1bcc4d 100644 --- a/src/app-config/router-config.ts +++ b/src/app-config/router-config.ts @@ -1,16 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-05-19 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** vue-router 相关配置入口 */ - import type { LayoutInst } from 'naive-ui' import type { Ref } from 'vue' @@ -71,4 +58,4 @@ export const WHITE_ROUTES: string[] = ['RLogin', 'ErrorPage', 'RayTemplateDoc'] * 超级管理员 * 配置默认超级管理员, 默认拥有全部最高权限 */ -export const SUPER_ADMIN: (string | number)[] = ['admin'] +export const SUPER_ADMIN: (string | number)[] = [] diff --git a/src/axios/axios-interceptor/request/index.ts b/src/axios/axios-interceptor/request/index.ts index 123ccdbb..3db8b6d1 100644 --- a/src/axios/axios-interceptor/request/index.ts +++ b/src/axios/axios-interceptor/request/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-23 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useAxiosInterceptor } from '@/axios/utils/interceptor' import implement from './provider' diff --git a/src/axios/axios-interceptor/request/provider.ts b/src/axios/axios-interceptor/request/provider.ts index 2eaebcd5..ba8165bf 100644 --- a/src/axios/axios-interceptor/request/provider.ts +++ b/src/axios/axios-interceptor/request/provider.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-06 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 请求拦截器入口 diff --git a/src/axios/axios-interceptor/response/index.ts b/src/axios/axios-interceptor/response/index.ts index c06a1556..9fb6cb60 100644 --- a/src/axios/axios-interceptor/response/index.ts +++ b/src/axios/axios-interceptor/response/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-23 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useAxiosInterceptor } from '@/axios/utils/interceptor' import implement from './provider' diff --git a/src/axios/axios-interceptor/response/provider.ts b/src/axios/axios-interceptor/response/provider.ts index 031d2eb9..880fa8f8 100644 --- a/src/axios/axios-interceptor/response/provider.ts +++ b/src/axios/axios-interceptor/response/provider.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-06 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 响应拦截器入口 diff --git a/src/axios/index.ts b/src/axios/index.ts index 27d3d303..01e1020e 100644 --- a/src/axios/index.ts +++ b/src/axios/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-07-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 基于 vue-hook-plus 与 axios 封装 diff --git a/src/axios/instance.ts b/src/axios/instance.ts index 4025967c..680712f5 100644 --- a/src/axios/instance.ts +++ b/src/axios/instance.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2022-11-18 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 请求拦截器与响应拦截器 diff --git a/src/axios/utils/RequestCanceler.ts b/src/axios/utils/RequestCanceler.ts index b50c7d0b..1eeb6c89 100644 --- a/src/axios/utils/RequestCanceler.ts +++ b/src/axios/utils/RequestCanceler.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-02-27 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 自动取消重复请求 diff --git a/src/axios/utils/axios-copilot.ts b/src/axios/utils/axios-copilot.ts index 259e3798..24a8b5eb 100644 --- a/src/axios/utils/axios-copilot.ts +++ b/src/axios/utils/axios-copilot.ts @@ -1,16 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** axios 拦截器工具 */ - import type { RawAxiosRequestHeaders, AxiosRequestConfig } from 'axios' import type { RequestHeaderOptions } from '../types' diff --git a/src/axios/utils/interceptor.ts b/src/axios/utils/interceptor.ts index 8b0d254d..240c30c0 100644 --- a/src/axios/utils/interceptor.ts +++ b/src/axios/utils/interceptor.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-05 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * axios 拦截器注入 diff --git a/src/components-pro/RCollapse/Collapse.tsx b/src/components-pro/RCollapse/Collapse.tsx index fbcfd2ae..255d4d99 100644 --- a/src/components-pro/RCollapse/Collapse.tsx +++ b/src/components-pro/RCollapse/Collapse.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-05-16 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RCollapseGrid, RForm } from '@/components' import { collapseGridProps, formProps } from '@/components' @@ -23,21 +12,21 @@ import type { FormProps, GridProps } from 'naive-ui' */ export default defineComponent({ name: 'RCollapse', - props: Object.assign( - {}, - { - ...collapseGridProps, - open: { - type: Boolean, - default: true, - }, - cols: { - type: Number, - default: 4, - }, + props: Object.assign({}, formProps, { + ...collapseGridProps, + open: { + type: Boolean, + default: true, }, - formProps, - ), + cols: { + type: Number, + default: 4, + }, + bordered: { + type: Boolean, + default: true, + }, + }), render() { const { $slots, $props } = this const { labelPlacement, showFeedback, ...rest } = $props as FormProps & diff --git a/src/components-pro/RTablePro/src/TablePro.tsx b/src/components-pro/RTablePro/src/TablePro.tsx index eccebab9..ed4d61db 100644 --- a/src/components-pro/RTablePro/src/TablePro.tsx +++ b/src/components-pro/RTablePro/src/TablePro.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-05-10 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RTable } from '@/components' import props from './props' diff --git a/src/components/RBarcode/src/Barcode.tsx b/src/components/RBarcode/src/Barcode.tsx index a8ff3edb..02057532 100644 --- a/src/components/RBarcode/src/Barcode.tsx +++ b/src/components/RBarcode/src/Barcode.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-04-14 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NSpin } from 'naive-ui' diff --git a/src/components/RCollapseGrid/src/index.tsx b/src/components/RCollapseGrid/src/index.tsx index 918e5c25..97e5bed0 100644 --- a/src/components/RCollapseGrid/src/index.tsx +++ b/src/components/RCollapseGrid/src/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2022-12-27 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * @@ -92,10 +81,11 @@ export default defineComponent({ yGap, collapsedRows, cssVars, + bordered, } = this return ( - + {{ default: () => ( - * - * @date 2024-03-27 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NForm } from 'naive-ui' import props from './props' diff --git a/src/components/RIcon/src/index.tsx b/src/components/RIcon/src/index.tsx index 06fcaf4f..918edf56 100644 --- a/src/components/RIcon/src/index.tsx +++ b/src/components/RIcon/src/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-01-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { completeSize, call } from '@/utils' diff --git a/src/components/RIcon/src/props.ts b/src/components/RIcon/src/props.ts index f071751c..3f34ac0d 100644 --- a/src/components/RIcon/src/props.ts +++ b/src/components/RIcon/src/props.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-27 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import type { PropType } from 'vue' import type { MaybeArray } from '@/types' diff --git a/src/components/RIframe/src/index.tsx b/src/components/RIframe/src/index.tsx index 15d4ee06..c391e43e 100644 --- a/src/components/RIframe/src/index.tsx +++ b/src/components/RIframe/src/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-09 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NSpin } from 'naive-ui' diff --git a/src/components/RIframe/src/props.ts b/src/components/RIframe/src/props.ts index 011a02cf..aa6b4f66 100644 --- a/src/components/RIframe/src/props.ts +++ b/src/components/RIframe/src/props.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import type { PropType } from 'vue' import type { MaybeArray } from '@/types' import type { SpinProps } from 'naive-ui' diff --git a/src/components/RIframe/src/types.ts b/src/components/RIframe/src/types.ts index df8ab37c..c0cccd95 100644 --- a/src/components/RIframe/src/types.ts +++ b/src/components/RIframe/src/types.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - export interface RIframeInst { iframe: Ref } diff --git a/src/components/RModal/src/Modal.tsx b/src/components/RModal/src/Modal.tsx index 730d2352..642575ce 100644 --- a/src/components/RModal/src/Modal.tsx +++ b/src/components/RModal/src/Modal.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-22 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NModal } from 'naive-ui' diff --git a/src/components/RModal/src/props.ts b/src/components/RModal/src/props.ts index e5b2d8de..baf0217b 100644 --- a/src/components/RModal/src/props.ts +++ b/src/components/RModal/src/props.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-22 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { modalProps } from 'naive-ui' import type { PropType } from 'vue' diff --git a/src/components/RMoreDropdown/src/index.tsx b/src/components/RMoreDropdown/src/index.tsx index 4ed9ace0..a5cd7278 100644 --- a/src/components/RMoreDropdown/src/index.tsx +++ b/src/components/RMoreDropdown/src/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-21 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NDropdown } from 'naive-ui' import { RIcon } from '@/components' diff --git a/src/components/RMoreDropdown/src/props.ts b/src/components/RMoreDropdown/src/props.ts index 0431b338..aa6749e3 100644 --- a/src/components/RMoreDropdown/src/props.ts +++ b/src/components/RMoreDropdown/src/props.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-21 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { dropdownProps } from 'naive-ui' const props = { diff --git a/src/components/RSegment/src/Segment.tsx b/src/components/RSegment/src/Segment.tsx index 51d6dc0c..5cf76f4a 100644 --- a/src/components/RSegment/src/Segment.tsx +++ b/src/components/RSegment/src/Segment.tsx @@ -1,21 +1,10 @@ -/** - * - * @author Ray - * - * @date 2024-04-10 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NTabs, NTab, NPopover, NFlex } from 'naive-ui' import props from './props' import { themeOverrides } from './constant' -import { completeSize, isValueType } from '@/utils' +import { completeSize, isValueType, renderNode } from '@/utils' import type { TabsProps } from 'naive-ui' import type { RSegmentOptions } from './types' @@ -26,7 +15,7 @@ const iconSegmentTab = (option: RSegmentOptions) => { if (icon) { return ( - + {renderNode(icon)?.()}
{label}
) diff --git a/src/components/RSegment/src/types.ts b/src/components/RSegment/src/types.ts index 77306fdf..e6d1a361 100644 --- a/src/components/RSegment/src/types.ts +++ b/src/components/RSegment/src/types.ts @@ -54,7 +54,7 @@ export interface RSegmentOptions { * @description * 自定义图标。 */ - icon?: VNode + icon?: VNode | (() => VNode) } export type RSegmentWidth = number | 'block' | 'fitContent' diff --git a/src/components/RTable/src/Table.tsx b/src/components/RTable/src/Table.tsx index 77398d10..70881185 100644 --- a/src/components/RTable/src/Table.tsx +++ b/src/components/RTable/src/Table.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NCard, NDataTable, NDropdown, NFlex } from 'naive-ui' @@ -258,7 +247,7 @@ export default defineComponent({ propsPopselectValue, renderWrapperHeader, } = this - const { class: className } = $attrs + const { class: className, ...restAttrs } = $attrs const { tool, combineRowProps, contextMenuSelect } = this return ( @@ -267,6 +256,7 @@ export default defineComponent({ {...{ id: uuidWrapper, }} + {...restAttrs} ref="wrapperRef" bordered={wrapperBordered} class={className} @@ -278,7 +268,6 @@ export default defineComponent({ {...{ id: uuidTable, }} - {...$attrs} {...($props as DataTableProps)} {...propsPopselectValue} rowProps={combineRowProps.bind(this)} diff --git a/src/components/RTable/src/components/C.tsx b/src/components/RTable/src/components/C.tsx index 005391c1..2637f5e2 100644 --- a/src/components/RTable/src/components/C.tsx +++ b/src/components/RTable/src/components/C.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 自定义表格列的顺序 diff --git a/src/components/RTable/src/components/Fullscreen.tsx b/src/components/RTable/src/components/Fullscreen.tsx index a5bc313d..6d11436c 100644 --- a/src/components/RTable/src/components/Fullscreen.tsx +++ b/src/components/RTable/src/components/Fullscreen.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RIcon } from '@/components' import { config } from '../shared' diff --git a/src/components/RTable/src/components/Print.tsx b/src/components/RTable/src/components/Print.tsx index b6c5e777..172c5d13 100644 --- a/src/components/RTable/src/components/Print.tsx +++ b/src/components/RTable/src/components/Print.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-05 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RIcon } from '@/components' import { config } from '../shared' diff --git a/src/components/RTable/src/components/Props.tsx b/src/components/RTable/src/components/Props.tsx index 7b78fb66..bc08da92 100644 --- a/src/components/RTable/src/components/Props.tsx +++ b/src/components/RTable/src/components/Props.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NPopselect } from 'naive-ui' import { RIcon } from '@/components' diff --git a/src/components/RTable/src/components/Size.tsx b/src/components/RTable/src/components/Size.tsx index e54faed5..37b03acf 100644 --- a/src/components/RTable/src/components/Size.tsx +++ b/src/components/RTable/src/components/Size.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NPopselect } from 'naive-ui' import { RIcon } from '@/components' diff --git a/src/components/RTable/src/props.ts b/src/components/RTable/src/props.ts index d8a0f19f..37fa8a78 100644 --- a/src/components/RTable/src/props.ts +++ b/src/components/RTable/src/props.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { dataTableProps } from 'naive-ui' import type { PropType, VNode } from 'vue' diff --git a/src/components/RTable/src/shared.ts b/src/components/RTable/src/shared.ts index 522f8f30..dd498c40 100644 --- a/src/components/RTable/src/shared.ts +++ b/src/components/RTable/src/shared.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - export const config = { tableIconSize: '18', tableKey: Symbol('r-table'), diff --git a/src/components/RTransitionComponent/src/index.vue b/src/components/RTransitionComponent/src/index.vue index 5ffb91d9..071e9fb2 100644 --- a/src/components/RTransitionComponent/src/index.vue +++ b/src/components/RTransitionComponent/src/index.vue @@ -9,10 +9,10 @@ > @@ -24,8 +24,7 @@ diff --git a/src/dayjs/index.ts b/src/dayjs/index.ts index e7ee7af9..352eb91d 100644 --- a/src/dayjs/index.ts +++ b/src/dayjs/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import dayjs from 'dayjs' import { DEFAULT_DAYJS_LOCAL } from '@/app-config' import 'dayjs/locale/zh-cn' diff --git a/src/directives/index.ts b/src/directives/index.ts index ab5b59ea..6f5c79bc 100644 --- a/src/directives/index.ts +++ b/src/directives/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { combineDirective } from './utils/combine' import { forIn } from 'lodash-es' diff --git a/src/directives/modules/copy/index.ts b/src/directives/modules/copy/index.ts index 6ec9d7ba..9759e5a2 100644 --- a/src/directives/modules/copy/index.ts +++ b/src/directives/modules/copy/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * directive name: copy diff --git a/src/directives/modules/debounce/index.ts b/src/directives/modules/debounce/index.ts index b2ce40bb..25e45b9d 100644 --- a/src/directives/modules/debounce/index.ts +++ b/src/directives/modules/debounce/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * directive name: debounce diff --git a/src/directives/modules/disabled/index.ts b/src/directives/modules/disabled/index.ts index 0b8e0997..6e8a3576 100644 --- a/src/directives/modules/disabled/index.ts +++ b/src/directives/modules/disabled/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-26 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * directive name: disabled diff --git a/src/directives/modules/throttle/index.ts b/src/directives/modules/throttle/index.ts index 111edde2..ac3c8862 100644 --- a/src/directives/modules/throttle/index.ts +++ b/src/directives/modules/throttle/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * directive name: throttle diff --git a/src/directives/utils/combine.ts b/src/directives/utils/combine.ts index 07bb3fb2..c8b8dbc9 100644 --- a/src/directives/utils/combine.ts +++ b/src/directives/utils/combine.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import type { DirectiveModules, CustomDirectiveFC } from '@/directives/types' export const combineDirective = < diff --git a/src/global-variable/index.ts b/src/global-variable/index.ts index d98eb5cd..c6b65aec 100644 --- a/src/global-variable/index.ts +++ b/src/global-variable/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-09-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - export * from './variable' export type * from './variable' diff --git a/src/global-variable/variable.ts b/src/global-variable/variable.ts index f2733437..2496bc30 100644 --- a/src/global-variable/variable.ts +++ b/src/global-variable/variable.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-09-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * @description diff --git a/src/hooks/components/useContextmenuCoordinate.ts b/src/hooks/components/useContextmenuCoordinate.ts index 7f8a1698..bfbc7a3b 100644 --- a/src/hooks/components/useContextmenuCoordinate.ts +++ b/src/hooks/components/useContextmenuCoordinate.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-12-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useEventListener, onClickOutside } from '@vueuse/core' import type { BasicTarget } from '@/types' diff --git a/src/hooks/template/useAppNavigation.ts b/src/hooks/template/useAppNavigation.ts index 985c09c9..7abfb936 100644 --- a/src/hooks/template/useAppNavigation.ts +++ b/src/hooks/template/useAppNavigation.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useMenuGetters } from '@/store' import { useVueRouter } from '@/hooks' diff --git a/src/hooks/template/useAppRoot.ts b/src/hooks/template/useAppRoot.ts index b70f3d7c..9732209e 100644 --- a/src/hooks/template/useAppRoot.ts +++ b/src/hooks/template/useAppRoot.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-17 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useSettingGetters, useSettingActions } from '@/store' import type { AppRootRoute } from '@/store/modules/setting/types' diff --git a/src/hooks/template/useMaximize.ts b/src/hooks/template/useMaximize.ts index 0caba2e9..ffef198f 100644 --- a/src/hooks/template/useMaximize.ts +++ b/src/hooks/template/useMaximize.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-30 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { setVariable, getVariableToRefs } from '@/global-variable' import { LAYOUT_CONTENT_REF } from '@/app-config' import { unrefElement } from '@/utils' diff --git a/src/hooks/template/useSiderBar.ts b/src/hooks/template/useSiderBar.ts index 87a673fc..b7e00f79 100644 --- a/src/hooks/template/useSiderBar.ts +++ b/src/hooks/template/useSiderBar.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useMenuGetters, useMenuActions } from '@/store' import { useVueRouter, useAppRoot } from '@/hooks' import { pick } from 'lodash-es' diff --git a/src/hooks/template/useSpinning.ts b/src/hooks/template/useSpinning.ts index 42bec339..f2837f3a 100644 --- a/src/hooks/template/useSpinning.ts +++ b/src/hooks/template/useSpinning.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-30 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { setVariable } from '@/global-variable' export const useSpinning = () => { diff --git a/src/hooks/template/useTheme.ts b/src/hooks/template/useTheme.ts index bc872f15..49fc630c 100644 --- a/src/hooks/template/useTheme.ts +++ b/src/hooks/template/useTheme.ts @@ -1,17 +1,7 @@ -/** - * - * @author Ray - * - * @date 2023-11-30 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useSettingActions, useSettingGetters } from '@/store' import { useI18n } from '@/hooks' import { APP_THEME } from '@/app-config' +import { useColorMode } from '@vueuse/core' export type ThemeLabel = 'Dark' | 'Light' @@ -93,7 +83,8 @@ export const useTheme = () => { const darkTheme = () => { const { updateSettingState } = useSettingActions() - updateSettingState('appTheme', true) + updateSettingState('_appTheme', true) + updateSettingState('appTheme', 'dark') setThemeOverrides(true) } @@ -108,10 +99,29 @@ export const useTheme = () => { const lightTheme = () => { const { updateSettingState } = useSettingActions() - updateSettingState('appTheme', false) + updateSettingState('_appTheme', false) + updateSettingState('appTheme', 'light') setThemeOverrides(false) } + /** + * + * @description + * 同步系统主题。 + * + * @example + * syncSystemTheme() + */ + const syncSystemTheme = () => { + const { getAppTheme } = useSettingGetters() + const { updateSettingState } = useSettingActions() + const { system } = useColorMode() + + updateSettingState('_appTheme', system.value === 'dark') + updateSettingState('appTheme', 'auto') + setThemeOverrides(getAppTheme.value) + } + /** * * @param theme 当前主题色 @@ -129,7 +139,8 @@ export const useTheme = () => { const { theme } = getAppTheme() const { updateSettingState } = useSettingActions() - updateSettingState('appTheme', !theme) + updateSettingState('_appTheme', !theme) + updateSettingState('appTheme', !theme ? 'dark' : 'light') setThemeOverrides(!theme) } @@ -138,6 +149,7 @@ export const useTheme = () => { lightTheme, toggleTheme, getAppTheme, + syncSystemTheme, } } diff --git a/src/hooks/template/useWatermark.ts b/src/hooks/template/useWatermark.ts index aeab2fff..b3a43aed 100644 --- a/src/hooks/template/useWatermark.ts +++ b/src/hooks/template/useWatermark.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-30 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { useSettingActions, useSettingGetters } from '@/store' export const useWatermark = () => { diff --git a/src/hooks/web/useDayjs.ts b/src/hooks/web/useDayjs.ts index d3b8de84..c6eaf764 100644 --- a/src/hooks/web/useDayjs.ts +++ b/src/hooks/web/useDayjs.ts @@ -1,15 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-09-11 - * - * @workspace ray-template - * - * @description - * 今天也是元气满满撸代码的一天。 - */ - import dayjs from 'dayjs' import { DEFAULT_DAYJS_LOCAL, DAYJS_LOCAL_MAP } from '@/app-config' diff --git a/src/hooks/web/useDevice.ts b/src/hooks/web/useDevice.ts index 09d767c3..750d8146 100644 --- a/src/hooks/web/useDevice.ts +++ b/src/hooks/web/useDevice.ts @@ -1,19 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** - * - * 检测当前尺寸是否为平板或者更小 - */ - import { useWindowSize } from '@vueuse/core' import { watchEffectWithTarget } from '@/utils' diff --git a/src/hooks/web/useI18n.ts b/src/hooks/web/useI18n.ts index 374b15ca..4fafc63a 100644 --- a/src/hooks/web/useI18n.ts +++ b/src/hooks/web/useI18n.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-09-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { i18n } from '@/locales' import type { I18n } from 'vue-i18n' diff --git a/src/hooks/web/useVueRouter.ts b/src/hooks/web/useVueRouter.ts index 2c16e461..56da8161 100644 --- a/src/hooks/web/useVueRouter.ts +++ b/src/hooks/web/useVueRouter.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { router } from '@/router' import type { Router } from 'vue-router' diff --git a/src/icons/template/dark.svg b/src/icons/template/dark.svg index 9c69a797..1e247138 100644 --- a/src/icons/template/dark.svg +++ b/src/icons/template/dark.svg @@ -1,3 +1,6 @@ - - + + + \ No newline at end of file diff --git a/src/icons/template/light.svg b/src/icons/template/light.svg index 2df0d3e2..c4a6f8fe 100644 --- a/src/icons/template/light.svg +++ b/src/icons/template/light.svg @@ -1,6 +1,6 @@ - - - - - + + + \ No newline at end of file diff --git a/src/icons/template/system_os.svg b/src/icons/template/system_os.svg new file mode 100644 index 00000000..bd295ccf --- /dev/null +++ b/src/icons/template/system_os.svg @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/src/icons/tip/question.svg b/src/icons/tip/question.svg new file mode 100644 index 00000000..39d3da0d --- /dev/null +++ b/src/icons/tip/question.svg @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/src/layout/components/Menu/components/SiderBarLogo/index.scss b/src/layout/components/Menu/components/SiderBarLogo/index.scss index 8a5fd57d..2aa10dbb 100644 --- a/src/layout/components/Menu/components/SiderBarLogo/index.scss +++ b/src/layout/components/Menu/components/SiderBarLogo/index.scss @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-08 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - .ray-menu__logo { height: $layoutHeaderHeight; padding: 0 18px 0 24px; diff --git a/src/layout/components/Menu/components/SiderBarLogo/index.tsx b/src/layout/components/Menu/components/SiderBarLogo/index.tsx index 32e15835..bebed826 100644 --- a/src/layout/components/Menu/components/SiderBarLogo/index.tsx +++ b/src/layout/components/Menu/components/SiderBarLogo/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-08 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NEllipsis, NTooltip } from 'naive-ui' diff --git a/src/layout/components/Menu/index.tsx b/src/layout/components/Menu/index.tsx index 51e90c69..650a792f 100644 --- a/src/layout/components/Menu/index.tsx +++ b/src/layout/components/Menu/index.tsx @@ -1,23 +1,12 @@ -/** - * - * @author Ray - * - * @date 2022-10-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NMenu, NLayoutSider, NDrawer } from 'naive-ui' import SiderBarLogo from './components/SiderBarLogo' -import { APP_MENU_CONFIG, LAYOUT_SIDER_REF } from '@/app-config' +import { LAYOUT_SIDER_REF } from '@/app-config' import { useDevice } from '@/hooks' import { getVariableToRefs, setVariable } from '@/global-variable' -import { useMenuGetters, useMenuActions } from '@/store' +import { useMenuGetters, useMenuActions, useSettingGetters } from '@/store' import type { MenuInst } from 'naive-ui' import type { NaiveMenuOptions } from '@/types' @@ -30,6 +19,7 @@ export default defineComponent({ const { changeMenuModelValue, collapsedMenu, updateMenuState } = useMenuActions() + const { getMenuConfig } = useSettingGetters() const { getMenuOptions, getCollapsed, getMenuKey } = useMenuGetters() const modelMenuKey = computed({ @@ -87,8 +77,8 @@ export default defineComponent({ { changeMenuModelValue(key, op as unknown as AppMenuOption) }} - accordion={APP_MENU_CONFIG.menuAccordion} + accordion={getMenuConfig.value.accordion} /> ) diff --git a/src/layout/components/MenuTag/index.tsx b/src/layout/components/MenuTag/index.tsx index 282f52dd..ff1bbfeb 100644 --- a/src/layout/components/MenuTag/index.tsx +++ b/src/layout/components/MenuTag/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2022-12-08 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * @description diff --git a/src/layout/components/Search/GlobalSearch/index.tsx b/src/layout/components/Search/GlobalSearch/index.tsx index c3d19859..840e81a8 100644 --- a/src/layout/components/Search/GlobalSearch/index.tsx +++ b/src/layout/components/Search/GlobalSearch/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-04-16 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * app search 搜索功能 diff --git a/src/layout/components/Search/GlobalSearchButton/index.tsx b/src/layout/components/Search/GlobalSearchButton/index.tsx index 77be6150..65a9cad2 100644 --- a/src/layout/components/Search/GlobalSearchButton/index.tsx +++ b/src/layout/components/Search/GlobalSearchButton/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-01-23 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NButton, NFlex } from 'naive-ui' diff --git a/src/layout/components/SiderBar/components/Breadcrumb/index.tsx b/src/layout/components/SiderBar/components/Breadcrumb/index.tsx index 43051fca..2467ae67 100644 --- a/src/layout/components/SiderBar/components/Breadcrumb/index.tsx +++ b/src/layout/components/SiderBar/components/Breadcrumb/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-03-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 顶部面包屑 diff --git a/src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSegment.tsx b/src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSegment.tsx new file mode 100644 index 00000000..00430a39 --- /dev/null +++ b/src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSegment.tsx @@ -0,0 +1,80 @@ +import { RSegment, RIcon } from '@/components' + +import { useSettingGetters, useSettingActions } from '@/store' +import { useColorMode } from '@vueuse/core' + +import type { SettingState } from '@/store/modules/setting/types' + +export default defineComponent({ + name: 'ThemeSegment', + setup() { + const { system } = useColorMode() + const { getAppThemeStr, getAppTheme } = useSettingGetters() + const { updateSettingState } = useSettingActions() + const options = [ + { + label: '深色', + key: 'dark', + icon: () => , + }, + { + label: '浅色', + key: 'light', + icon: () => , + }, + { + label: '自动', + key: 'auto', + icon: () => , + }, + ] + const modelAppTheme = computed({ + get: () => { + if (getAppThemeStr.value === 'auto') { + return 'auto' + } + + return getAppTheme.value ? 'dark' : 'light' + }, + set: (val) => { + updateThemeFn(val, system.value) + }, + }) + + const updateThemeFn = ( + themeModel: SettingState['appTheme'], + systemTheme: 'dark' | 'light', + ) => { + if (themeModel === 'auto') { + updateSettingState('_appTheme', systemTheme === 'dark') + updateSettingState('appTheme', 'auto') + + return + } + + updateSettingState('_appTheme', themeModel === 'dark') + updateSettingState('appTheme', themeModel) + } + + watchEffect(() => { + updateThemeFn(modelAppTheme.value, system.value) + }) + + return { + options, + modelAppTheme, + } + }, + render() { + const { options } = this + + return ( + + ) + }, +}) diff --git a/src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch/index.tsx b/src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch.tsx similarity index 90% rename from src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch/index.tsx rename to src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch.tsx index c483675e..6581a5d8 100644 --- a/src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch/index.tsx +++ b/src/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-04-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex, NSwitch, NTooltip } from 'naive-ui' import { RIcon } from '@/components' diff --git a/src/layout/components/SiderBar/components/SettingDrawer/constant.ts b/src/layout/components/SiderBar/components/SettingDrawer/constant.ts new file mode 100644 index 00000000..4241a5c8 --- /dev/null +++ b/src/layout/components/SiderBar/components/SettingDrawer/constant.ts @@ -0,0 +1,21 @@ +import type { SettingState } from '@/store/modules/setting/types' + +export const defaultSettingConfig: Partial = { + contentTransition: 'scale', + watermarkSwitch: false, + keepAliveConfig: { + maxKeepAliveLength: 10, + setupKeepAlive: true, + }, + menuConfig: { + collapsedWidth: 64, + collapsedMode: 'width', + collapsedIconSize: 22, + collapsedIndent: 24, + accordion: false, + }, + menuTagSwitch: true, + breadcrumbSwitch: true, + copyrightSwitch: true, + drawerPlacement: 'right', +} diff --git a/src/layout/components/SiderBar/components/SettingDrawer/index.tsx b/src/layout/components/SiderBar/components/SettingDrawer/index.tsx index 8a2a8f2f..6a4221ba 100644 --- a/src/layout/components/SiderBar/components/SettingDrawer/index.tsx +++ b/src/layout/components/SiderBar/components/SettingDrawer/index.tsx @@ -1,13 +1,3 @@ -/** - * - * app setting 抽屉 - * 提供了一些基础的动态配置能力 - * 如果需要其他额外的配置项,可以按照当前的方式进行拓展 - * - * 可能会疑问,为什么可配置项那么少? - * 其实并不少,只是有一些东西,在我看来是没多大意义需要动态的去改动的,所以都是在 `app-config` 包中进行配置维护 - */ - import './index.scss' import { @@ -20,14 +10,24 @@ import { NDescriptions, NDescriptionsItem, NSelect, + NInputNumber, + NFormItem, + NForm, + NButton, + NText, + NTooltip, } from 'naive-ui' -import ThemeSwitch from '@/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch' +import ThemeSegment from './components/ThemeSegment' +import { RIcon } from '@/components' import { APP_THEME, CONTENT_TRANSITION_OPTIONS } from '@/app-config' import { useSettingGetters, useSettingActions } from '@/store' +import { defaultSettingConfig } from './constant' +import { forIn } from 'lodash-es' import type { PropType } from 'vue' import type { Placement } from '@/types' +import type { SettingState } from '@/store/modules/setting/types' export default defineComponent({ name: 'SettingDrawer', @@ -56,6 +56,9 @@ export default defineComponent({ getCopyrightSwitch, getContentTransition, getWatermarkSwitch, + getKeepAliveConfig, + getMenuConfig, + getDrawerPlacement, } = useSettingGetters() const modelShow = computed({ @@ -65,7 +68,7 @@ export default defineComponent({ }, }) // 为了方便管理多个 computed,因为 computed 不能被逆向修改 - const modelSwitchReactive = computed({ + const modelReactive = computed({ get: () => { return { getMenuTagSwitch: getMenuTagSwitch.value, @@ -73,35 +76,52 @@ export default defineComponent({ getCopyrightSwitch: getCopyrightSwitch.value, getContentTransition: getContentTransition.value, getWatermarkSwitch: getWatermarkSwitch.value, + getKeepAliveConfig: getKeepAliveConfig.value, + getMenuConfig: getMenuConfig.value, + getDrawerPlacement: getDrawerPlacement.value, } }, set: (value) => {}, }) + const defaultSettingBtnClick = () => { + forIn(defaultSettingConfig, (value, key) => { + updateSettingState(key as keyof SettingState, value) + }) + } + return { modelShow, changePrimaryColor, getAppTheme, getPrimaryColorOverride, updateSettingState, - modelSwitchReactive, + modelReactive, + defaultSettingBtnClick, } }, render() { - const { $t, changePrimaryColor, updateSettingState } = this + const { + $t, + changePrimaryColor, + updateSettingState, + defaultSettingBtnClick, + } = this return ( - + {$t('headerSettingOptions.ThemeOptions.Title')} - + {$t('headerSettingOptions.ThemeOptions.PrimaryColorConfig')} @@ -114,19 +134,56 @@ export default defineComponent({ {$t('headerSettingOptions.ContentTransition')} { updateSettingState('contentTransition', value) }} /> - - {$t('headerSettingOptions.InterfaceDisplay')} - + 抽屉位置 + { + updateSettingState('drawerPlacement', value) + }} + /> + 系统设置 + + + updateSettingState('menuConfig', { + accordion: bool, + }) + } + /> + + + + updateSettingState('keepAliveConfig', { + setupKeepAlive: bool, + }) + } + /> + updateSettingState('menuTagSwitch', bool) } @@ -134,7 +191,7 @@ export default defineComponent({ updateSettingState('breadcrumbSwitch', bool) } @@ -142,7 +199,7 @@ export default defineComponent({ updateSettingState('watermarkSwitch', bool) } @@ -150,13 +207,91 @@ export default defineComponent({ updateSettingState('copyrightSwitch', bool) } /> + 菜单样式 + + + { + if (value !== null) { + updateSettingState('menuConfig', { + collapsedIndent: value, + }) + } + }} + /> + + + { + if (value !== null) { + updateSettingState('menuConfig', { + collapsedIconSize: value, + }) + } + }} + /> + + + { + if (value !== null) { + updateSettingState('menuConfig', { + collapsedWidth: value, + }) + } + }} + /> + + + + + + {{ + trigger: () => , + default: () => '当设置为【0】时,缓存将会失效', + }} + + 最大缓存数 + + + + 操作 + + + 清除设置 + + diff --git a/src/layout/components/SiderBar/components/TooltipIcon/index.tsx b/src/layout/components/SiderBar/components/TooltipIcon/index.tsx index 38fa42a5..35205530 100644 --- a/src/layout/components/SiderBar/components/TooltipIcon/index.tsx +++ b/src/layout/components/SiderBar/components/TooltipIcon/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2022-12-29 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NTooltip } from 'naive-ui' diff --git a/src/layout/components/SiderBar/index.tsx b/src/layout/components/SiderBar/index.tsx index 49f8b43a..a8e7ef1a 100644 --- a/src/layout/components/SiderBar/index.tsx +++ b/src/layout/components/SiderBar/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-01-04 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 本来想通过写数据配置化的方式实现顶部的功能小按钮, 结果事实发现... diff --git a/src/layout/default/ContentWrapper/index.tsx b/src/layout/default/ContentWrapper/index.tsx index b22fc22d..cc79d950 100644 --- a/src/layout/default/ContentWrapper/index.tsx +++ b/src/layout/default/ContentWrapper/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-04-21 - * - * @workspace ray-template-mine - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 使用 NSpin 组件实现 loading 效果 diff --git a/src/layout/default/FeatureWrapper/index.tsx b/src/layout/default/FeatureWrapper/index.tsx index 32b062c7..57f2dc40 100644 --- a/src/layout/default/FeatureWrapper/index.tsx +++ b/src/layout/default/FeatureWrapper/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-09 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import MenuTag from '@/layout/components/MenuTag' export default defineComponent({ diff --git a/src/layout/default/FooterWrapper/index.tsx b/src/layout/default/FooterWrapper/index.tsx index f42a05f9..63256847 100644 --- a/src/layout/default/FooterWrapper/index.tsx +++ b/src/layout/default/FooterWrapper/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-04-21 - * - * @workspace ray-template-mine - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' export default defineComponent({ diff --git a/src/layout/default/HeaderWrapper/index.tsx b/src/layout/default/HeaderWrapper/index.tsx index 751bac07..7c85dea5 100644 --- a/src/layout/default/HeaderWrapper/index.tsx +++ b/src/layout/default/HeaderWrapper/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-09 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex } from 'naive-ui' import SiderBar from '@/layout/components/SiderBar' diff --git a/src/locales/index.ts b/src/locales/index.ts index b820ca90..492fe1e9 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2022-12-08 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 注册 `vue-i18n` diff --git a/src/router/app-route-modules.ts b/src/router/app-route-modules.ts index 4fb9cd49..78aafab4 100644 --- a/src/router/app-route-modules.ts +++ b/src/router/app-route-modules.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 描述: diff --git a/src/router/utils/expand-routes.ts b/src/router/utils/expand-routes.ts index 0ed6a9c0..03791a67 100644 --- a/src/router/utils/expand-routes.ts +++ b/src/router/utils/expand-routes.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 该功能基于 提供代码改进实现 diff --git a/src/router/utils/permission.ts b/src/router/utils/permission.ts index 23bd3fe0..a82c2d4d 100644 --- a/src/router/utils/permission.ts +++ b/src/router/utils/permission.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-01-28 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 路由守卫 diff --git a/src/store/hooks/useKeepAliveStore.ts b/src/store/hooks/useKeepAliveStore.ts index 33c02a48..f07897bf 100644 --- a/src/store/hooks/useKeepAliveStore.ts +++ b/src/store/hooks/useKeepAliveStore.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-06 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { piniaKeepAliveStore } from '../index' export const useKeepAliveGetters = () => { diff --git a/src/store/hooks/useMenuStore.ts b/src/store/hooks/useMenuStore.ts index dc54d752..ef0a9d3f 100644 --- a/src/store/hooks/useMenuStore.ts +++ b/src/store/hooks/useMenuStore.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-05 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { piniaMenuStore } from '../modules/menu' import { useAppRoot } from '@/hooks' diff --git a/src/store/hooks/useSettingStore.ts b/src/store/hooks/useSettingStore.ts index 7e7b2e53..f3dbd3e8 100644 --- a/src/store/hooks/useSettingStore.ts +++ b/src/store/hooks/useSettingStore.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-06 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { piniaSettingStore } from '../modules/setting' export const useSettingGetters = () => { @@ -31,7 +20,13 @@ export const useSettingGetters = () => { * @description * 获取 app 主题。 */ - const getAppTheme = computed(() => variable.appTheme) + const getAppTheme = computed(() => variable._appTheme) + /** + * + * @description + * 获取 app 主题。 + */ + const getAppThemeStr = computed(() => variable.appTheme) /** * * @description @@ -96,6 +91,20 @@ export const useSettingGetters = () => { */ const getSideBarLogo = computed(() => variable.sideBarLogo) + /** + * + * @description + * 获取缓存设置。 + */ + const getKeepAliveConfig = computed(() => variable.keepAliveConfig) + + /** + * + * @description + * 获取菜单设置。 + */ + const getMenuConfig = computed(() => variable.menuConfig) + return { getDrawerPlacement, getPrimaryColorOverride, @@ -110,6 +119,9 @@ export const useSettingGetters = () => { getWatermarkConfig, getAppRootRoute, getSideBarLogo, + getKeepAliveConfig, + getMenuConfig, + getAppThemeStr, } } diff --git a/src/store/hooks/useSigningStore.ts b/src/store/hooks/useSigningStore.ts index f055338c..aeaef32f 100644 --- a/src/store/hooks/useSigningStore.ts +++ b/src/store/hooks/useSigningStore.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-06 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { piniaSigningStore } from '../index' export const useSigningGetters = () => { diff --git a/src/store/index.ts b/src/store/index.ts index 33e19b22..a255081a 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-01-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 模板约定不直接操作 store 实例,所有操作都应在 hooks 中二次封装的 getters, actions diff --git a/src/store/modules/keep-alive/index.ts b/src/store/modules/keep-alive/index.ts index ade92cd8..f291be20 100644 --- a/src/store/modules/keep-alive/index.ts +++ b/src/store/modules/keep-alive/index.ts @@ -1,25 +1,5 @@ -/** - * - * @author Ray - * - * @date 2023-06-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - -/** - * - * 缓存 - * - * 管理系统缓存 - * 基于 KeepAlive 组件实现 - * 依赖 APP_KEEP_ALIVE 配置 - */ - -import { APP_KEEP_ALIVE } from '@/app-config' import { APP_CATCH_KEY } from '@/app-config' +import { piniaSettingStore } from '../setting' import type { KeepAliveStoreState } from './types' import type { AppMenuOption } from '@/types' @@ -27,8 +7,6 @@ import type { AppMenuOption } from '@/types' export const piniaKeepAliveStore = defineStore( 'keepAlive', () => { - const { maxKeepAliveLength } = APP_KEEP_ALIVE - const state = reactive({ keepAliveInclude: [], }) @@ -39,8 +17,9 @@ export const piniaKeepAliveStore = defineStore( * * @param option current menu option * - * @remark 判断当前页面是否配置需要缓存, 并且判断当前缓存数量是否超过最大缓存数设置数量 - * @remark 如果超过最大阈值, 则会按照尾插头删方式维护该队列 + * @description + * 设置当前可缓存项。 + * 如果当前可缓存项数量超过最大缓存数量,则移除第一个,添加最后一个。 */ const setKeepAliveInclude = (option: AppMenuOption) => { const length = getCurrentKeepAliveLength() @@ -48,6 +27,7 @@ export const piniaKeepAliveStore = defineStore( name, meta: { keepAlive }, } = option + const { maxKeepAliveLength } = piniaSettingStore().keepAliveConfig if (keepAlive) { if ( @@ -66,7 +46,7 @@ export const piniaKeepAliveStore = defineStore( } } - /** 获取当前缓存队列 */ + // 获取当前缓存队列 const getKeepAliveInclude = () => state.keepAliveInclude return { diff --git a/src/store/modules/menu/index.ts b/src/store/modules/menu/index.ts index f87db6d0..71cb9457 100644 --- a/src/store/modules/menu/index.ts +++ b/src/store/modules/menu/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2022-11-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 该文件为 menu 菜单 pinia store @@ -28,7 +17,7 @@ import { NEllipsis } from 'naive-ui' -import { setStorage, equalRouterPath } from '@/utils' +import { setStorage, equalRouterPath, updateObjectValue } from '@/utils' import { validRole, validMenuItemShow } from '@/router/utils' import { parseAndFindMatchingNodes, @@ -116,10 +105,8 @@ export const piniaMenuStore = defineStore( * @description * 更新 menu state 指定 key 的值。 */ - const updateMenuState: UpdateMenuState = (key, value) => { - if (Object.hasOwn(menuState, key as string)) { - menuState[key] = value - } + const updateMenuState: UpdateMenuState = (key, value, cb) => { + updateObjectValue(menuState, key, value, cb) } /** diff --git a/src/store/modules/menu/types.ts b/src/store/modules/menu/types.ts index a6f3880c..a00f4715 100644 --- a/src/store/modules/menu/types.ts +++ b/src/store/modules/menu/types.ts @@ -1,4 +1,4 @@ -import type { AppMenuOption, MenuTagOptions, AppMenuKey } from '@/types' +import type { AppMenuOption, MenuTagOptions, AppMenuKey, AnyFC } from '@/types' export interface MenuState { menuKey: AppMenuKey @@ -13,5 +13,6 @@ type PickUpdateKeys = 'collapsed' | 'currentMenuOption' export type UpdateMenuState = >( key: T, - value: MenuState[T], + value: Partial, + cb?: AnyFC, ) => void diff --git a/src/store/modules/menu/utils.ts b/src/store/modules/menu/utils.ts index 02c3c06e..ae3b4fe0 100644 --- a/src/store/modules/menu/utils.ts +++ b/src/store/modules/menu/utils.ts @@ -1,22 +1,12 @@ -/** - * - * @author Ray - * - * @date 2023-03-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** 本方法感谢 的支持 */ import { RIcon } from '@/components' -import { APP_MENU_CONFIG, APP_CATCH_KEY } from '@/app-config' +import { APP_CATCH_KEY } from '@/app-config' import { getStorage, isValueType } from '@/utils' import { useAppRoot, useI18n } from '@/hooks' import { NTag } from 'naive-ui' +import { piniaSettingStore } from '../setting' import type { AppMenuOption, AppMenuKey } from '@/types/modules/app' import type { TagProps } from 'naive-ui' @@ -124,9 +114,7 @@ export const updateDocumentTitle = (option: AppMenuOption) => { return } - const { - layout: { sideBarLogo }, - } = __APP_CFG__ + const { sideBarLogo } = piniaSettingStore() const spliceTitle = sideBarLogo ? sideBarLogo.title : '' document.title = breadcrumbLabel + ' - ' + spliceTitle @@ -155,11 +143,12 @@ export const createMenuIcon = (option: AppMenuOption) => { return () => icon } + const { menuConfig } = piniaSettingStore() const _icon = h( RIcon, { name: icon, - size: APP_MENU_CONFIG.menuCollapsedIconSize, + size: menuConfig.collapsedIconSize, cursor: 'pointer', }, {}, diff --git a/src/store/modules/setting/index.ts b/src/store/modules/setting/index.ts index 19358f7b..96180e82 100644 --- a/src/store/modules/setting/index.ts +++ b/src/store/modules/setting/index.ts @@ -1,8 +1,7 @@ import { getAppDefaultLanguage } from '@/locales/utils' -import { colorToRgba, setStorage } from '@/utils' +import { colorToRgba, setStorage, updateObjectValue } from '@/utils' import { useI18n, useDayjs } from '@/hooks' -import { watchOnce } from '@vueuse/core' -import { APP_CATCH_KEY, APP_THEME, SIDE_BAR_LOGO_DEFAULT } from '@/app-config' +import { APP_CATCH_KEY, APP_THEME } from '@/app-config' import type { SettingState } from '@/store/modules/setting/types' import type { LocalKey } from '@/hooks' @@ -18,7 +17,9 @@ export const piniaSettingStore = defineStore( const { locale: dayjsLocal } = useDayjs() const settingState = reactive({ + // 默认设置出现位置 drawerPlacement: 'right', + // 默认主题色 primaryColorOverride: { common: { primaryColor: primaryColor, @@ -26,14 +27,24 @@ export const piniaSettingStore = defineStore( primaryColorPressed: primaryColor, }, }, - appTheme: false, // true 为黑夜主题, false 为明亮主题 - menuTagSwitch: true, // 多标签页开关 - breadcrumbSwitch: true, // 面包屑开关 + // true 为黑夜主题, false 为明亮主题 + _appTheme: false, + appTheme: 'light', + // 多标签页开关 + menuTagSwitch: true, + // 面包屑开关 + breadcrumbSwitch: true, + // 默认国际化语言 localeLanguage: getAppDefaultLanguage(), - lockScreenSwitch: false, // 锁屏开关 - copyrightSwitch: true, // 底部区域开关 - contentTransition: 'scale', // 切换过渡效果 - watermarkSwitch: false, // 水印开关, + // 锁屏开关 + lockScreenSwitch: false, + // 底部区域开关 + copyrightSwitch: true, + // 切换过渡效果 + contentTransition: 'scale', + // 水印开关 + watermarkSwitch: false, + // 水印 watermarkConfig: { content: 'Trying be better~', fontSize: 16, @@ -44,14 +55,35 @@ export const piniaSettingStore = defineStore( yOffset: 60, rotate: -15, }, + // 根路由信息 appRootRoute: { name: 'Dashboard', path: '/dashboard', }, - sideBarLogo: Object.assign({}, SIDE_BAR_LOGO_DEFAULT), + // 侧边栏设置 + sideBarLogo: { + icon: 'ray', + title: 'Ray Template', + url: '/dashboard', + jumpType: 'station', + }, + // 缓存动态设置 + keepAliveConfig: { + setupKeepAlive: true, + keepAliveExclude: [], + maxKeepAliveLength: 10, + }, + // 菜单配置 + menuConfig: { + collapsedWidth: 64, + collapsedMode: 'width', + collapsedIconSize: 22, + collapsedIndent: 24, + accordion: false, + }, }) - /** 修改当前语言 */ + // 修改当前语言 const updateLocale = (key: string) => { locale(key) dayjsLocal(key as LocalKey) @@ -63,7 +95,8 @@ export const piniaSettingStore = defineStore( /** * - * 切换主题色,传递对应颜色即可更新 naive-ui 的主题色 + * @description + * 切换主题色,传递对应颜色即可更新 naive-ui 的主题色。 */ const changePrimaryColor = (value: string, alpha = 0.3) => { const alphaColor = colorToRgba(value, alpha) @@ -88,8 +121,9 @@ export const piniaSettingStore = defineStore( * @param value settingState 的 value * @param cb 回调函数 * - * 更新 settingState 的值,如果 key 不存在与 settingState 中,则不会更新 - * 但是不论是否更新成功,都会执行回调函数 + * @description + * 更新 settingState 的值,如果 key 不存在与 settingState 中,则不会更新。 + * 但是不论是否更新成功,都会执行回调函数。 * * @example * updateSettingState('drawerPlacement', 'left') @@ -101,14 +135,10 @@ export const piniaSettingStore = defineStore( C extends AnyFC, >( key: T, - value: V[T], + value: Partial, cb?: C, ) => { - if (Object.hasOwn(settingState, key)) { - settingState[key] = value - } - - cb?.() + updateObjectValue(settingState, key, value, cb) } /** @@ -116,7 +146,7 @@ export const piniaSettingStore = defineStore( * 初始化合并自定义主题色 * 该方法会在初始化时执行一次,之后会在切换主题色时执行 */ - watchOnce( + watch( () => settingState.appTheme, (ndata) => { ndata @@ -135,6 +165,7 @@ export const piniaSettingStore = defineStore( }, { immediate: true, + once: true, }, ) diff --git a/src/store/modules/setting/types.ts b/src/store/modules/setting/types.ts index 711c1ee6..a136b668 100644 --- a/src/store/modules/setting/types.ts +++ b/src/store/modules/setting/types.ts @@ -1,5 +1,10 @@ import type { GlobalThemeOverrides } from 'naive-ui' -import type { Placement, LayoutSideBarLogo } from '@/types' +import type { + Placement, + LayoutSideBarLogo, + AppKeepAlive, + AppMenuConfig, +} from '@/types' export interface WatermarkConfig { content: string @@ -20,7 +25,8 @@ export interface AppRootRoute { export interface SettingState { drawerPlacement: Placement primaryColorOverride: GlobalThemeOverrides - appTheme: boolean + appTheme: 'dark' | 'light' | 'auto' + _appTheme: boolean menuTagSwitch: boolean breadcrumbSwitch: boolean localeLanguage: string @@ -30,5 +36,38 @@ export interface SettingState { contentTransition: string watermarkConfig: WatermarkConfig appRootRoute: AppRootRoute + /** + * + * @description + * icon: LOGO 图标, 依赖 `RIcon` 实现(如果为空则不会渲染图标);4.8.2 版本后支持 VNode。 + * title: LOGO 标题。 + * url: 点击跳转地址, 如果不配置该属性, 则不会触发跳转。 + * jumpType: 跳转类型(station: 项目内跳转, outsideStation: 新页面打开)。 + * + * 如果不设置该属性或者为空, 则不会渲染 LOGO。 + */ sideBarLogo: LayoutSideBarLogo | undefined + /** + * + * @description + * setupKeepAlive: 是否启用系统页面缓存,设置为 false 则关闭系统页面缓存。 + * keepAliveExclude: 排除哪些页面不缓存。 + * maxKeepAliveLength: 最大缓存页面数量。 + */ + keepAliveConfig: AppKeepAlive + /** + * + * @description + * 系统菜单折叠配置 + * + * collapsedWidth 配置仅当 collapsedMode 为 width 风格时才有效。 + * + * collapsedMode: + * - transform: 边栏将只会移动它的位置而不会改变宽度 + * - width: Sider 的内容宽度将会被实际改变 + * collapsedIconSize 配置菜单未折叠时图标的大小 + * collapsedIndent 配置菜单每级的缩进 + * accordion 手风琴模式 + */ + menuConfig: AppMenuConfig } diff --git a/src/store/modules/signing/index.ts b/src/store/modules/signing/index.ts index ee4c203b..edcc8c00 100644 --- a/src/store/modules/signing/index.ts +++ b/src/store/modules/signing/index.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-01-28 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 出于便捷性考虑, 将用户部分信息存于 pinia 仓库 diff --git a/src/styles/naive.scss b/src/styles/naive.scss index b643bfb1..59ddfc38 100644 --- a/src/styles/naive.scss +++ b/src/styles/naive.scss @@ -23,6 +23,7 @@ align-items: center; } +// 调整自定义 AppMenu 样式 .r-menu--app { // 手动设置 label 宽度,兼容 extra 的情况 .n-menu-item-content-header .n-ellipsis { @@ -33,3 +34,9 @@ margin-right: 8px; } } + +// 手动设置 NDatePicker, NInputNumber 样式 +.n-date-picker, +.n-input-number { + width: 100%; +} diff --git a/src/types/modules/app-config.ts b/src/types/modules/app-config.ts index 2929e952..934336fc 100644 --- a/src/types/modules/app-config.ts +++ b/src/types/modules/app-config.ts @@ -3,11 +3,11 @@ import type { CreateAxiosDefaults } from 'axios' export type CollapsedMode = 'transform' | 'width' export interface AppMenuConfig { - menuCollapsedWidth: number - menuCollapsedMode: CollapsedMode - menuCollapsedIconSize: number - menuCollapsedIndent: number - menuAccordion: boolean + collapsedWidth: number + collapsedMode: CollapsedMode + collapsedIconSize: number + collapsedIndent: number + accordion: boolean } export interface AppKeepAlive { diff --git a/src/types/modules/vite-custom-config.ts b/src/types/modules/vite-custom-config.ts index a292658e..3ffffb83 100644 --- a/src/types/modules/vite-custom-config.ts +++ b/src/types/modules/vite-custom-config.ts @@ -46,7 +46,6 @@ export interface Config { alias: AliasOptions title: HTMLTitle copyright?: LayoutCopyright - sideBarLogo?: LayoutSideBarLogo mixinCSS?: string preloadingConfig?: PreloadingConfig base?: string @@ -69,7 +68,6 @@ export interface AppConfig { } layout: { copyright?: LayoutCopyright - sideBarLogo?: LayoutSideBarLogo } base?: string appPrimaryColor: AppPrimaryColor diff --git a/src/utils/cache.ts b/src/utils/cache.ts index ab06eb48..7da665ea 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-05 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { APP_CATCH_KEY_PREFIX } from '@/app-config' import type { StorageLike, StorageOptions, RemoveStorageFC } from '@/types' diff --git a/src/utils/index.ts b/src/utils/index.ts index 0c467dce..a984caa7 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -8,3 +8,4 @@ export * from './precision' export * from './vue' export * from './app' export { positionSelectedMenuItem } +export { updateObjectValue } from './update-object-value' diff --git a/src/utils/precision.ts b/src/utils/precision.ts index b4595a2a..798f0ece 100644 --- a/src/utils/precision.ts +++ b/src/utils/precision.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-07 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 文档地址: diff --git a/src/utils/update-object-value.ts b/src/utils/update-object-value.ts new file mode 100644 index 00000000..3a4e495f --- /dev/null +++ b/src/utils/update-object-value.ts @@ -0,0 +1,47 @@ +import type { Recordable, AnyFC } from '@/types' + +/** + * + * @param targetObject 目标对象值 + * @param key 目标 key + * @param value 待修改值 + * @param callback 修改完成后的回调,只有修改成功才会触发 + * + * @description + * 所以这是一个的更新对象值的方法。 + * 仅允许修改目标对象本身的属性值,不允许修改对象中嵌套的对象属性值与原型连上的值。 + * 如果更新未成功,不会触发 callback 回调方法。 + * + * @example + * const obj = { a: 1, b: 2, c: { d: 3 } } + * updateObjectValue(obj, 'a', 2) + * updateObjectValue(obj, 'b', 3) + * updateObjectValue(obj, 'c', { d: 4 }) + */ +export const updateObjectValue = < + Target extends Recordable, + Key extends keyof Target, + Value extends Partial, + Callback extends AnyFC, +>( + targetObject: Target, + key: Key, + value: Value, + callback?: Callback, +) => { + if (!targetObject || typeof targetObject !== 'object') { + console.warn( + `[updateObjectValue]: targetObject must be an object, expected ${typeof targetObject}`, + ) + + return + } + + if (Object.hasOwn(targetObject, key)) { + typeof value === 'object' + ? (targetObject[key] = Object.assign({}, targetObject[key], value)) + : (targetObject[key] = value) + + callback?.() + } +} diff --git a/src/utils/vue/effect-dispose.ts b/src/utils/vue/effect-dispose.ts index af898e2c..b8e11458 100644 --- a/src/utils/vue/effect-dispose.ts +++ b/src/utils/vue/effect-dispose.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-10 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { getCurrentScope, onScopeDispose } from 'vue' import type { AnyFC } from '@/types' diff --git a/src/utils/vue/render-node.ts b/src/utils/vue/render-node.ts index 579456c5..16cd133a 100644 --- a/src/utils/vue/render-node.ts +++ b/src/utils/vue/render-node.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-27 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { isValueType } from '@/utils' import type { VNode, Slot } from 'vue' diff --git a/src/utils/vue/unref-element.ts b/src/utils/vue/unref-element.ts index cadec386..6d65a560 100644 --- a/src/utils/vue/unref-element.ts +++ b/src/utils/vue/unref-element.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-10-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import type { BasicTarget, TargetType, TargetValue } from '@/types' import type { ComponentPublicInstance } from 'vue' diff --git a/src/utils/vue/watch-effect-with-target.ts b/src/utils/vue/watch-effect-with-target.ts index c740e87c..d592ba01 100644 --- a/src/utils/vue/watch-effect-with-target.ts +++ b/src/utils/vue/watch-effect-with-target.ts @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-11-10 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { effectDispose } from './effect-dispose' import type { WatchOptionsBase } from 'vue' diff --git a/src/views/demo/BarcodeDemo.tsx b/src/views/demo/BarcodeDemo.tsx index 49091b87..1ad93d86 100644 --- a/src/views/demo/BarcodeDemo.tsx +++ b/src/views/demo/BarcodeDemo.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-04-14 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RBarcode } from '@/components' import { NAlert, diff --git a/src/views/demo/TablePro.tsx b/src/views/demo/TablePro.tsx index 49eea75e..aaccd5d9 100644 --- a/src/views/demo/TablePro.tsx +++ b/src/views/demo/TablePro.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-08-23 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RTablePro, RCollapse } from '@/components-pro' import { NFlex, @@ -330,7 +319,7 @@ export default defineComponent({ return ( - + {{ default: () => ( <> diff --git a/src/views/demo/cache-demo/index.tsx b/src/views/demo/cache-demo/index.tsx index bdda2bd0..2a30c02b 100644 --- a/src/views/demo/cache-demo/index.tsx +++ b/src/views/demo/cache-demo/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-01-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NButton, NCard, diff --git a/src/views/demo/context-menu/index.tsx b/src/views/demo/context-menu/index.tsx index d623e131..19511456 100644 --- a/src/views/demo/context-menu/index.tsx +++ b/src/views/demo/context-menu/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-12-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex, NCard, NDropdown } from 'naive-ui' import { useContextmenuCoordinate } from '@/hooks' diff --git a/src/views/demo/directive/index.tsx b/src/views/demo/directive/index.tsx index 33068b6a..f893a42b 100644 --- a/src/views/demo/directive/index.tsx +++ b/src/views/demo/directive/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex, NCard, diff --git a/src/views/demo/doc/index.tsx b/src/views/demo/doc/index.tsx index 97781a88..b56f2741 100644 --- a/src/views/demo/doc/index.tsx +++ b/src/views/demo/doc/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-07-14 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RIframe } from '@/components' const RTemplateDoc = defineComponent({ diff --git a/src/views/demo/form/index.tsx b/src/views/demo/form/index.tsx index bccb3213..b9bd29fb 100644 --- a/src/views/demo/form/index.tsx +++ b/src/views/demo/form/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-03-27 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RForm } from '@/components' import { NFormItemGi, diff --git a/src/views/demo/iframe/index.tsx b/src/views/demo/iframe/index.tsx index 3dc560e8..bb6a4aef 100644 --- a/src/views/demo/iframe/index.tsx +++ b/src/views/demo/iframe/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-09 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * RIframe 组件使用示例 diff --git a/src/views/demo/mock-demo/index.tsx b/src/views/demo/mock-demo/index.tsx index 5be7bad8..1ef574e4 100644 --- a/src/views/demo/mock-demo/index.tsx +++ b/src/views/demo/mock-demo/index.tsx @@ -1,16 +1,6 @@ -/** - * - * @author Ray - * - * @date 2023-08-11 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex, NCard, NButton, NFormItemGi, NInput, NForm } from 'naive-ui' -import { RCollapseGrid, RTable } from '@/components' +import { RTable } from '@/components' +import { RCollapse } from '@/components-pro' import { useHookPlusRequest } from '@/axios' import { getPersonList } from '@/api/demo/mock/person' @@ -148,7 +138,7 @@ const MockDemo = defineComponent({
- + {{ default: () => ( <> @@ -163,7 +153,7 @@ const MockDemo = defineComponent({ ), }} - + - * - * @date 2023-11-24 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { RModal } from '@/components' import { NButton, NCard, NFlex } from 'naive-ui' diff --git a/src/views/demo/multi/views/multi-menu-one/index.tsx b/src/views/demo/multi/views/multi-menu-one/index.tsx index f4f6983d..a2b11a30 100644 --- a/src/views/demo/multi/views/multi-menu-one/index.tsx +++ b/src/views/demo/multi/views/multi-menu-one/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-03-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NInput } from 'naive-ui' const MultiMenuOne = defineComponent({ diff --git a/src/views/demo/multi/views/multi-menu-two/views/sub-menu-other/index.tsx b/src/views/demo/multi/views/multi-menu-two/views/sub-menu-other/index.tsx index 7fdd09d6..89207744 100644 --- a/src/views/demo/multi/views/multi-menu-two/views/sub-menu-other/index.tsx +++ b/src/views/demo/multi/views/multi-menu-two/views/sub-menu-other/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-03-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NInput } from 'naive-ui' const SubMenuOther = defineComponent({ diff --git a/src/views/demo/multi/views/multi-menu-two/views/sub-menu/views/multi-menu-two-one/index.tsx b/src/views/demo/multi/views/multi-menu-two/views/sub-menu/views/multi-menu-two-one/index.tsx index 9fdef39c..0a907012 100644 --- a/src/views/demo/multi/views/multi-menu-two/views/sub-menu/views/multi-menu-two-one/index.tsx +++ b/src/views/demo/multi/views/multi-menu-two/views/sub-menu/views/multi-menu-two-one/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-03-01 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NInput } from 'naive-ui' const MultiMenuTwoOne = defineComponent({ diff --git a/src/views/demo/precision/index.tsx b/src/views/demo/precision/index.tsx index e8140219..cf3680e1 100644 --- a/src/views/demo/precision/index.tsx +++ b/src/views/demo/precision/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-07 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NLayout, NCard, NDynamicTags, NFlex, NInputNumber } from 'naive-ui' import { add, subtract, multiply, divide, distribute, format } from '@/utils' diff --git a/src/views/demo/qrcode/index.tsx b/src/views/demo/qrcode/index.tsx index 19836b97..23d9314e 100644 --- a/src/views/demo/qrcode/index.tsx +++ b/src/views/demo/qrcode/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-30 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex, NCard, NButton } from 'naive-ui' import { Vue3NextQrcode } from 'vue3-next-qrcode' diff --git a/src/views/demo/router-demo/router-demo-detail/index.tsx b/src/views/demo/router-demo/router-demo-detail/index.tsx index a36b05da..53fe2b69 100644 --- a/src/views/demo/router-demo/router-demo-detail/index.tsx +++ b/src/views/demo/router-demo/router-demo-detail/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-30 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NCard, NFlex } from 'naive-ui' const RouterDemoDetail = defineComponent({ diff --git a/src/views/demo/router-demo/router-demo-home/index.tsx b/src/views/demo/router-demo/router-demo-home/index.tsx index be1872c0..5548f76f 100644 --- a/src/views/demo/router-demo/router-demo-home/index.tsx +++ b/src/views/demo/router-demo/router-demo-home/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-30 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex, NButton } from 'naive-ui' import { RTable } from '@/components' diff --git a/src/views/demo/segment/index.tsx b/src/views/demo/segment/index.tsx index a5e5ccd3..4c158a2a 100644 --- a/src/views/demo/segment/index.tsx +++ b/src/views/demo/segment/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2024-04-10 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NCard, NFlex, diff --git a/src/views/demo/svg-icons/index.tsx b/src/views/demo/svg-icons/index.tsx index 6683ac1a..087554a2 100644 --- a/src/views/demo/svg-icons/index.tsx +++ b/src/views/demo/svg-icons/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-08-25 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { NFlex, NCard, NPopover } from 'naive-ui' diff --git a/src/views/demo/table/index.tsx b/src/views/demo/table/index.tsx index ca540da9..bbb9b8e1 100644 --- a/src/views/demo/table/index.tsx +++ b/src/views/demo/table/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2022-12-08 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NTag, NButton, @@ -22,7 +11,8 @@ import { NCard, NAlert, } from 'naive-ui' -import { RCollapseGrid, RTable, RIcon, RMoreDropdown } from '@/components' +import { RTable, RIcon, RMoreDropdown } from '@/components' +import { RCollapse } from '@/components-pro' import { uuid } from '@/utils' import { useTable, useCheckedRowKeys } from '@/components' @@ -298,13 +288,12 @@ const TableView = defineComponent({
- window.$message.info( - `我是 RCollapseGrid 组件${value ? '收起' : '展开'}的回调函数`, + `我是 RCollapse 组件${value ? '收起' : '展开'}的回调函数`, ) } > @@ -335,7 +324,7 @@ const TableView = defineComponent({ ), }} - + - * - * @date 2023-11-03 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import { NFlex, NCard, NButton, NInput } from 'naive-ui' import { RIcon } from '@/components' @@ -40,7 +29,8 @@ export default defineComponent({ setWatermarkContent, toggleWatermark, } = useWatermark() - const { darkTheme, lightTheme, toggleTheme, getAppTheme } = useTheme() + const { darkTheme, lightTheme, toggleTheme, getAppTheme, syncSystemTheme } = + useTheme() const { hidden: badgeHidden, show: badgeShow, @@ -69,6 +59,7 @@ export default defineComponent({ badgeShow, badgeUpdateLabel, badgeValue, + syncSystemTheme, } }, render() { @@ -90,6 +81,7 @@ export default defineComponent({ badgeHidden, badgeShow, badgeUpdateLabel, + syncSystemTheme, } = this return ( @@ -148,6 +140,7 @@ export default defineComponent({ darkTheme()}>切换暗黑主题 lightTheme()}>切换明亮主题 + syncSystemTheme()}>跟随主题 toggleTheme()}>切换主题 diff --git a/src/views/error/PageResult/index.tsx b/src/views/error/PageResult/index.tsx index c11a22c6..6885c7e7 100644 --- a/src/views/error/PageResult/index.tsx +++ b/src/views/error/PageResult/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * 错误页面 diff --git a/src/views/error/views/Error404/index.tsx b/src/views/error/views/Error404/index.tsx index d1559c67..4de3a4a6 100644 --- a/src/views/error/views/Error404/index.tsx +++ b/src/views/error/views/Error404/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import PageResult from '@/views/error' const ErrorPage404 = defineComponent({ diff --git a/src/views/error/views/Error500/index.tsx b/src/views/error/views/Error500/index.tsx index 475ae7a5..57c146ba 100644 --- a/src/views/error/views/Error500/index.tsx +++ b/src/views/error/views/Error500/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-06-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import PageResult from '@/views/error' const ErrorPage500 = defineComponent({ diff --git a/src/views/login/components/QRCodeSigning/index.tsx b/src/views/login/components/QRCodeSigning/index.tsx index 449233c6..e533b6e4 100644 --- a/src/views/login/components/QRCodeSigning/index.tsx +++ b/src/views/login/components/QRCodeSigning/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-04-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - import './index.scss' import { Vue3NextQrcode } from 'vue3-next-qrcode' diff --git a/src/views/login/components/SSOSigning/index.tsx b/src/views/login/components/SSOSigning/index.tsx index 84c86e41..04570c0d 100644 --- a/src/views/login/components/SSOSigning/index.tsx +++ b/src/views/login/components/SSOSigning/index.tsx @@ -1,14 +1,3 @@ -/** - * - * @author Ray - * - * @date 2023-04-02 - * - * @workspace ray-template - * - * @remark 今天也是元气满满撸代码的一天 - */ - /** * * SSO 单点登录模块组件 diff --git a/vite-helper/svg-icon-resolve.ts b/vite-helper/svg-icon-resolve.ts index b28ff9ae..3f1add65 100644 --- a/vite-helper/svg-icon-resolve.ts +++ b/vite-helper/svg-icon-resolve.ts @@ -28,5 +28,7 @@ export const svgIconResolve = (directory = 'src/icons') => { } } + console.log(folders) + return folders } diff --git a/vite.config.ts b/vite.config.ts index 4dcd3847..b1428a89 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,7 +12,6 @@ export default defineConfig(({ mode }) => { buildOptions, alias, copyright, - sideBarLogo, mixinCSS, appPrimaryColor, base, @@ -27,7 +26,6 @@ export default defineConfig(({ mode }) => { }, layout: { copyright, - sideBarLogo, }, appPrimaryColor, } diff --git a/vite.custom.config.ts b/vite.custom.config.ts index 04d51c2a..9a7837bd 100644 --- a/vite.custom.config.ts +++ b/vite.custom.config.ts @@ -40,10 +40,7 @@ import path from 'node:path' import { htmlTitlePlugin, mixinCss } from './vite-helper' import { APP_THEME } from './src/app-config/design-config' -import { - PRE_LOADING_CONFIG, - SIDE_BAR_LOGO_DEFAULT, -} from './src/app-config/app-config' +import { PRE_LOADING_CONFIG } from './src/app-config/app-config' import type { AppConfigExport } from '@/types' import type { BuildOptions } from 'vite' @@ -57,7 +54,6 @@ const config: AppConfigExport = { preloadingConfig: PRE_LOADING_CONFIG, // 默认主题色(不可省略,必填),也用于 ejs 注入 appPrimaryColor: APP_THEME.appPrimaryColor, - sideBarLogo: SIDE_BAR_LOGO_DEFAULT, /** * * 预处理全局需要注入的 css 文件