This commit is contained in:
XiaoDaiGua-Ray 2023-09-15 23:57:14 +08:00
parent 6acc80f18a
commit 4331b6a3b1
107 changed files with 529 additions and 441 deletions

View File

@ -1,5 +1,20 @@
# CHANGE LOG # CHANGE LOG
## 4.2.0
针对分包做了全局的重新设计、调整。让包的名称更加语义化最重要的是重新抽离了一些全局可能常用的方法例如useI18n、useDayjs 等,在以前这些方法存放于对应的包中,其实这样很不合理,所以现在统一存放于 `src/hooks` 包中。并且该包以后统一存放 `hooks` 方法,并不是 `utils` 方法,做了一个本质的区分,所以 `xxxCopilot.ts` 文件中的方法并不会移动,维持存放在原有的模块下。
引入 `useGlobalVariable` 来管理全局变量。与 `pinia` `的使用场景不同useGlobalVariable` 是用于引入一些全局的响应式变量,这些变量不需要缓存,也不依赖任何插件。一个典型的应用是实现 `GlobalSpin`。使用该方法时,请谨慎使用,避免滥用,因为这些变量会被全局缓存且无法被回收。该方法存放的值,暂不支持缓存(如果有需要,可能后期会增加该功能)。
当项目插件或者需要配置项过多时候,会导致 `vite.config.ts` 文件变得异常臃肿。所以,在本次更新中,将插件的配置单独提出维护(`vite.plugin.confit.ts`)。系统的常用配置依旧在 `cfg.ts` 文件中。所以默认情况下,一般不需要修改 `vite.config.ts` 文件。
### Feats
- 新增 `useGlobalVariable` 管理全局变量(该变量可以是在注册插件之前被调用)
- `v-disbaled` 指令现在会尝试给元素添加 `disabled` 属性,如果该属性生效的话
- 注册指令操作现在不会中断程序执行,但是会抛出错误警告
- 抽离 `vite.plugin.confit.ts` 维护项目启动所需插件
## 4.1.9 ## 4.1.9
### Feats ### Feats

View File

@ -1,5 +1,6 @@
<div align="center"> <a href="https://github.com/XiaoDaiGua-Ray/ray-template"> <img alt="Ray Template" width="200" height="200" src="https://usc1.contabostorage.com/c2e495d7890844d392e8ec0c6e5d77eb:alist/ray/ray.svg?sign=ZklU9Bh5b6oKp1X0LOhGwkx4g5mW4wk_w9Jt5zlZ5EQ=:0"> </a> <br> <br> <div align="center">
<a href="https://github.com/XiaoDaiGua-Ray/ray-template"> <img alt="Ray Template" width="200" height="200" src="https://usc1.contabostorage.com/c2e495d7890844d392e8ec0c6e5d77eb:alist/ray/ray.svg?sign=ZklU9Bh5b6oKp1X0LOhGwkx4g5mW4wk_w9Jt5zlZ5EQ=:0"> </a> <br> <br>
<a href="https://github.com/XiaoDaiGua-Ray/ray-template/blob/main/LICENSE"><img src="https://img.shields.io/github/license/XiaoDaiGua-Ray/ray-template" alt="LICENSE"></a>
</div> </div>
<div align="center"> <div align="center">

43
cfg.ts
View File

@ -38,15 +38,12 @@
import path from 'node:path' import path from 'node:path'
import { import { htmlTitlePlugin, mixinCSSPlugin } from './vite-plugins/index'
HTMLTitlePlugin,
buildOptions,
mixinCSSPlugin,
} from './vite-plugin/index'
import { APP_THEME } from './src/app-config/designConfig' import { APP_THEME } from './src/app-config/designConfig'
import { PRE_LOADING_CONFIG, SIDE_BAR_LOGO } from './src/app-config/appConfig' import { PRE_LOADING_CONFIG, SIDE_BAR_LOGO } from './src/app-config/appConfig'
import type { AppConfigExport } from '@/types/modules/cfg' import type { AppConfigExport } from '@/types/modules/cfg'
import type { BuildOptions } from 'vite'
const config: AppConfigExport = { const config: AppConfigExport = {
/** 公共基础路径配置, 如果为空则会默认以 '/' 填充 */ /** 公共基础路径配置, 如果为空则会默认以 '/' 填充 */
@ -82,7 +79,7 @@ const config: AppConfigExport = {
* *
* *
*/ */
title: HTMLTitlePlugin('Ray Template'), title: htmlTitlePlugin(PRE_LOADING_CONFIG.title || 'Ray Template'),
/** /**
* *
* HMR () * HMR ()
@ -109,7 +106,39 @@ const config: AppConfigExport = {
* *
* *
*/ */
buildOptions: buildOptions, buildOptions: (mode: string): BuildOptions => {
const outDirMap = {
test: 'dist/test-dist',
development: 'dist/development-dist',
production: 'dist/production-dist',
report: 'dist/report-dist',
}
const dirPath = outDirMap[mode] || 'dist/test-dist'
if (mode === 'production') {
return {
outDir: dirPath,
sourcemap: false,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
}
} else {
return {
outDir: dirPath,
sourcemap: true,
terserOptions: {
compress: {
drop_console: false,
drop_debugger: false,
},
},
}
}
},
/** /**
* *
* *

View File

@ -33,7 +33,11 @@ export const APP_KEEP_ALIVE: Readonly<AppKeepAlive> = {
maxKeepAliveLength: 5, maxKeepAliveLength: 5,
} }
/** 首屏加载信息配置 */ /**
*
*
* title
*/
export const PRE_LOADING_CONFIG: PreloadingConfig = { export const PRE_LOADING_CONFIG: PreloadingConfig = {
title: 'Ray Template', title: 'Ray Template',
tagColor: '#ff6700', tagColor: '#ff6700',

View File

@ -35,7 +35,10 @@ import type { AppRawRequestConfig } from '@/axios/type'
* vue effect 使 * vue effect 使
* @example * @example
* *
* // 请求函数
* const getUser = () => request({ url: 'http://localhost:3000/user' }) * const getUser = () => request({ url: 'http://localhost:3000/user' })
*
* // effect 中使用
* const { data } = useHookPlusRequest(getUser) * const { data } = useHookPlusRequest(getUser)
*/ */
function useRequest< function useRequest<

View File

@ -13,7 +13,7 @@ import type {
ChartThemeRawArray, ChartThemeRawArray,
ChartThemeRawModules, ChartThemeRawModules,
LoadingOptions, LoadingOptions,
} from '@/components/RayChart/type' } from '@/components/RChart/type'
/** /**
* *

View File

@ -55,7 +55,7 @@ import type {
LoadingOptions, LoadingOptions,
AutoResize, AutoResize,
ChartTheme, ChartTheme,
} from '@/components/RayChart/type' } from '@/components/RChart/type'
import type { import type {
UseResizeObserverReturn, UseResizeObserverReturn,
MaybeComputedElementRef, MaybeComputedElementRef,

View File

@ -24,7 +24,7 @@ import './index.scss'
import { collapseGridProps } from './props' import { collapseGridProps } from './props'
import { NCard, NGrid, NGridItem, NSpace } from 'naive-ui' import { NCard, NGrid, NGridItem, NSpace } from 'naive-ui'
import RayIcon from '@/components/RayIcon' import RayIcon from '@/components/RIcon'
import { call } from '@/utils/vue/index' import { call } from '@/utils/vue/index'

View File

@ -12,7 +12,7 @@
import './index.scss' import './index.scss'
import { NButton, NSpin } from 'naive-ui' import { NButton, NSpin } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import props from './props' import props from './props'
import { AwesomeQR } from 'awesome-qr' import { AwesomeQR } from 'awesome-qr'

View File

@ -10,7 +10,7 @@
*/ */
import { NPopconfirm, NSpace, NButton, NPopover } from 'naive-ui' import { NPopconfirm, NSpace, NButton, NPopover } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
export type EmitterType = 'positive' | 'negative' export type EmitterType = 'positive' | 'negative'

View File

@ -12,11 +12,11 @@
import './index.scss' import './index.scss'
import { NPopover } from 'naive-ui' import { NPopover } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import screenfull from 'screenfull' import screenfull from 'screenfull'
import type { TableSettingProvider } from '@/components/RayTable/src/type' import type { TableSettingProvider } from '@/components/RTable/src/type'
const TableScreenfull = defineComponent({ const TableScreenfull = defineComponent({
name: 'TableScreenfull', name: 'TableScreenfull',

View File

@ -1,4 +1,4 @@
import type { ActionOptions } from '@/components/RayTable/src/type' import type { ActionOptions } from '@/components/RTable/src/type'
export const setupSettingOptions = (options: ActionOptions[]) => { export const setupSettingOptions = (options: ActionOptions[]) => {
const arr = options.map((curr) => { const arr = options.map((curr) => {

View File

@ -19,7 +19,7 @@
import './index.scss' import './index.scss'
import { NCard, NPopover, NEllipsis } from 'naive-ui' import { NCard, NPopover, NEllipsis } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import VueDraggable from 'vuedraggable' import VueDraggable from 'vuedraggable'
import { setupSettingOptions } from './hook' import { setupSettingOptions } from './hook'
@ -30,7 +30,7 @@ import type {
ActionOptions, ActionOptions,
FixedType, FixedType,
TableSettingFixedPopoverIcon, TableSettingFixedPopoverIcon,
} from '@/components/RayTable/src/type' } from '@/components/RTable/src/type'
const TableSetting = defineComponent({ const TableSetting = defineComponent({
name: 'TableSetting', name: 'TableSetting',

View File

@ -12,11 +12,11 @@
import './index.scss' import './index.scss'
import { NPopover, NCard } from 'naive-ui' import { NPopover, NCard } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import { call } from '@/utils/vue/index' import { call } from '@/utils/vue/index'
import type { TableSettingProvider } from '@/components/RayTable/src/type' import type { TableSettingProvider } from '@/components/RTable/src/type'
import type { ComponentSize } from '@/types/modules/component' import type { ComponentSize } from '@/types/modules/component'
import type { MaybeArray } from '@/types/modules/utils' import type { MaybeArray } from '@/types/modules/utils'

View File

@ -10,30 +10,9 @@
*/ */
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { DEFAULT_DAYJS_LOCAL, DAYJS_LOCAL_MAP } from '@/app-config/localConfig' import { DEFAULT_DAYJS_LOCAL } from '@/app-config/localConfig'
import 'dayjs/locale/zh-cn' import 'dayjs/locale/zh-cn'
import type { DayjsLocal } from './type'
export const setupDayjs = () => { export const setupDayjs = () => {
dayjs.locale(DEFAULT_DAYJS_LOCAL) dayjs.locale(DEFAULT_DAYJS_LOCAL)
} }
/**
*
* dayjs hook
*
* :
* - locale: 切换 dayjs
*/
export const useDayjs = () => {
const locale = (key: DayjsLocal) => {
const mapkey = DAYJS_LOCAL_MAP[key]
mapkey ? dayjs.locale(mapkey) : dayjs.locale(DEFAULT_DAYJS_LOCAL)
}
return {
locale,
}
}

View File

@ -33,17 +33,20 @@ export const setupDirectives = (app: App<Element>) => {
// 将所有的包提取出来(./modules/[file-name]/index.ts) // 将所有的包提取出来(./modules/[file-name]/index.ts)
const directivesModules = combineDirective(directiveRawModules) const directivesModules = combineDirective(directiveRawModules)
// 提取文件名(./modules/copy/index.ts => copy) // 提取文件名(./modules/copy/index.ts => copy)
const reg = /(?<=modules\/).*(?=\/index\.ts)/ const regexExtractDirectiveName = /(?<=modules\/).*(?=\/index\.ts)/
// 匹配合法指令名称
const regexDirectiveName = /^([^-]+-)*[^-]+$/
forIn(directivesModules, (value, key) => { forIn(directivesModules, (value, key) => {
const dname = key.match(reg)?.[0] const dname = key.match(regexExtractDirectiveName)?.[0]
if (isValueType<string>(dname, 'String')) { if (
isValueType<string>(dname, 'String') &&
regexDirectiveName.test(dname)
) {
app.directive(dname, value?.()) app.directive(dname, value?.())
} else { } else {
throw new Error( console.error(`[setupDirectives] ${dname} is not a valid directive name`)
'directiveName is not string, please check your directive file name',
)
} }
}) })
} }

View File

@ -17,7 +17,6 @@
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import { on, off } from '@use-utils/element' import { on, off } from '@use-utils/element'
import type { Directive } from 'vue'
import type { DebounceBindingOptions } from './type' import type { DebounceBindingOptions } from './type'
import type { AnyFC } from '@/types/modules/utils' import type { AnyFC } from '@/types/modules/utils'
import type { DebouncedFunc } from 'lodash-es' import type { DebouncedFunc } from 'lodash-es'

View File

@ -22,7 +22,16 @@ const updateElementDisabledType = (el: HTMLElement, value: boolean) => {
if (el) { if (el) {
const classes = 'ray-template__directive--disabled' const classes = 'ray-template__directive--disabled'
value ? addClass(el, classes) : removeClass(el, classes) if (value) {
el.setAttribute('disabled', 'disabled')
addClass(el, classes)
} else {
el.removeAttribute('disabled')
removeClass(el, classes)
}
el?.setAttribute('disabled', value ? 'disabled' : '') el?.setAttribute('disabled', value ? 'disabled' : '')
} }
} }

View File

@ -17,7 +17,6 @@
import { throttle } from 'lodash-es' import { throttle } from 'lodash-es'
import { on, off } from '@use-utils/element' import { on, off } from '@use-utils/element'
import type { Directive } from 'vue'
import type { ThrottleBindingOptions } from './type' import type { ThrottleBindingOptions } from './type'
import type { AnyFC } from '@/types/modules/utils' import type { AnyFC } from '@/types/modules/utils'
import type { DebouncedFunc } from 'lodash-es' import type { DebouncedFunc } from 'lodash-es'

View File

@ -0,0 +1,18 @@
/**
*
* @author Ray <https://github.com/XiaoDaiGua-Ray>
*
* @date 2023-09-11
*
* @workspace ray-template
*
* @remark
*/
import {
setVariable,
getVariable,
globalVariableToRefs,
} from './useGlobalVariable'
export { setVariable, getVariable, globalVariableToRefs }

View File

@ -0,0 +1,40 @@
/**
*
* @author Ray <https://github.com/XiaoDaiGua-Ray>
*
* @date 2023-09-11
*
* @workspace ray-template
*
* @remark
*/
/**
*
* pinia 使
*
*
*
*/
/** 全局响应式变量 */
const variableState = reactive({
globalSpinning: false,
})
type VariableStateKey = keyof typeof variableState
export function setVariable(
key: VariableStateKey,
value: (typeof variableState)[VariableStateKey],
) {
variableState[key] = value
}
export function getVariable(key: VariableStateKey) {
return variableState[key] as (typeof variableState)[VariableStateKey]
}
export function globalVariableToRefs<K extends VariableStateKey>(key: K) {
return toRef<typeof variableState, K>(variableState, key)
}

16
src/hooks/web/index.ts Normal file
View File

@ -0,0 +1,16 @@
/**
*
* @author Ray <https://github.com/XiaoDaiGua-Ray>
*
* @date 2023-09-11
*
* @workspace ray-template
*
* @remark
*/
import { useI18n, t } from './useI18n'
import { useVueRouter } from '../web/useVueRouter'
import { useDayjs } from '../web/useDayjs'
export { useI18n, useVueRouter, useDayjs, t }

34
src/hooks/web/useDayjs.ts Normal file
View File

@ -0,0 +1,34 @@
/**
*
* @author Ray <https://github.com/XiaoDaiGua-Ray>
*
* @date 2023-09-11
*
* @workspace ray-template
*
* @remark
*/
import dayjs from 'dayjs'
import { DEFAULT_DAYJS_LOCAL, DAYJS_LOCAL_MAP } from '@/app-config/localConfig'
import type { DayjsLocal } from '@/dayjs/type'
/**
*
* dayjs hook
*
* :
* - locale: 切换 dayjs
*/
export const useDayjs = () => {
const locale = (key: DayjsLocal) => {
const mapkey = DAYJS_LOCAL_MAP[key]
mapkey ? dayjs.locale(mapkey) : dayjs.locale(DEFAULT_DAYJS_LOCAL)
}
return {
locale,
}
}

View File

@ -1,4 +1,15 @@
import { i18n } from './index' /**
*
* @author Ray <https://github.com/XiaoDaiGua-Ray>
*
* @date 2023-09-11
*
* @workspace ray-template
*
* @remark
*/
import { i18n } from '@/locales/index'
import type { WritableComputedRef } from 'vue' import type { WritableComputedRef } from 'vue'

View File

@ -11,8 +11,8 @@
import './index.scss' import './index.scss'
import { NEllipsis } from 'naive-ui' import { NEllipsis, NPopover } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
const SiderBarLogo = defineComponent({ const SiderBarLogo = defineComponent({
name: 'SiderBarLogo', name: 'SiderBarLogo',
@ -37,9 +37,14 @@ const SiderBarLogo = defineComponent({
} }
} }
const TemplateLogo = ({ cursor }: { cursor: string }) => (
<RayIcon name={sideBarLogo!.icon as string} size="30" cursor={cursor} />
)
return { return {
sideBarLogo, sideBarLogo,
handleSideBarLogoClick, handleSideBarLogoClick,
TemplateLogo,
} }
}, },
render() { render() {
@ -47,27 +52,32 @@ const SiderBarLogo = defineComponent({
<div <div
class={[ class={[
'ray-menu__logo', 'ray-menu__logo',
this.sideBarLogo?.url ? 'ray-menu__logo-url' : '', this.sideBarLogo?.url ? 'ray-menu__logo-url' : null,
]} ]}
onClick={this.handleSideBarLogoClick.bind(this)} onClick={this.handleSideBarLogoClick.bind(this)}
> >
{this.sideBarLogo?.icon ? ( {this.sideBarLogo?.icon ? (
<RayIcon name={this.sideBarLogo.icon} size="30" /> this.collapsed ? (
) : ( <NPopover placement="right">
'' {{
)} trigger: () => <this.TemplateLogo cursor="pointer" />,
default: () => this.sideBarLogo?.title,
}}
</NPopover>
) : (
<this.TemplateLogo cursor="pointer" />
)
) : null}
<h1 <h1
class={[ class={[
!this.collapsed ? 'ray-menu__logo-title--open' : '', !this.collapsed ? 'ray-menu__logo-title--open' : null,
'ray-menu__logo-title', 'ray-menu__logo-title',
]} ]}
> >
<NEllipsis>{this.sideBarLogo?.title}</NEllipsis> <NEllipsis>{this.sideBarLogo?.title}</NEllipsis>
</h1> </h1>
</div> </div>
) : ( ) : null
''
)
}, },
}) })

View File

@ -26,7 +26,7 @@
import './index.scss' import './index.scss'
import { NScrollbar, NTag, NSpace, NLayoutHeader, NDropdown } from 'naive-ui' import { NScrollbar, NTag, NSpace, NLayoutHeader, NDropdown } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import { useMenu, useSetting } from '@/store' import { useMenu, useSetting } from '@/store'
import { uuid } from '@/utils/hook' import { uuid } from '@/utils/hook'

View File

@ -12,7 +12,7 @@
import './index.scss' import './index.scss'
import { NInput, NModal, NResult, NScrollbar, NSpace } from 'naive-ui' import { NInput, NModal, NResult, NScrollbar, NSpace } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import { on, off, queryElements, addClass, removeClass } from '@/utils/element' import { on, off, queryElements, addClass, removeClass } from '@/utils/element'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'

View File

@ -10,10 +10,10 @@
*/ */
import { NSpace, NSwitch, NTooltip } from 'naive-ui' import { NSpace, NSwitch, NTooltip } from 'naive-ui'
import RayIcon from '@/components/RayIcon' import RayIcon from '@/components/RIcon'
import { useSetting } from '@/store' import { useSetting } from '@/store'
import { useI18n } from '@/locales/useI18n' import { useI18n } from '@/hooks/web/index'
const ThemeSwitch = defineComponent({ const ThemeSwitch = defineComponent({
name: 'ThemeSwitch', name: 'ThemeSwitch',

View File

@ -15,7 +15,7 @@ import ThemeSwitch from '@/layout/components/SiderBar/components/SettingDrawer/c
import { APP_THEME } from '@/app-config/designConfig' import { APP_THEME } from '@/app-config/designConfig'
import { useSetting } from '@/store' import { useSetting } from '@/store'
import { useI18n } from '@/locales/useI18n' import { useI18n } from '@/hooks/web/index'
import type { PropType } from 'vue' import type { PropType } from 'vue'
import type { Placement } from '@/types/modules/component' import type { Placement } from '@/types/modules/component'

View File

@ -12,7 +12,7 @@
import './index.scss' import './index.scss'
import { NTooltip } from 'naive-ui' import { NTooltip } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import { tooltipProps } from 'naive-ui' import { tooltipProps } from 'naive-ui'

View File

@ -20,7 +20,7 @@
import './index.scss' import './index.scss'
import { NLayoutHeader, NSpace, NTooltip, NDropdown } from 'naive-ui' import { NLayoutHeader, NSpace, NTooltip, NDropdown } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import TootipIcon from '@/layout/components/SiderBar/components/TooltipIcon/index' import TootipIcon from '@/layout/components/SiderBar/components/TooltipIcon/index'
import SettingDrawer from './components/SettingDrawer/index' import SettingDrawer from './components/SettingDrawer/index'
import Breadcrumb from './components/Breadcrumb/index' import Breadcrumb from './components/Breadcrumb/index'
@ -31,7 +31,7 @@ import { useSetting } from '@/store'
import { LOCAL_OPTIONS } from '@/app-config/localConfig' import { LOCAL_OPTIONS } from '@/app-config/localConfig'
import { useAvatarOptions, avatarDropdownClick } from './hook' import { useAvatarOptions, avatarDropdownClick } from './hook'
import screenfull from 'screenfull' import screenfull from 'screenfull'
import { useI18n } from '@/locales/useI18n' import { useI18n } from '@/hooks/web/index'
import type { IconEventMapOptions, IconEventMap } from './type' import type { IconEventMapOptions, IconEventMap } from './type'

View File

@ -18,7 +18,7 @@
import './index.scss' import './index.scss'
import { NSpin } from 'naive-ui' import { NSpin } from 'naive-ui'
import RayTransitionComponent from '@/components/RayTransitionComponent/index.vue' import RTransitionComponent from '@/components/RTransitionComponent/index.vue'
import AppRequestCancelerProvider from '@/app-components/provider/AppRequestCancelerProvider/index' import AppRequestCancelerProvider from '@/app-components/provider/AppRequestCancelerProvider/index'
import { useSetting } from '@/store' import { useSetting } from '@/store'
@ -66,7 +66,7 @@ const ContentWrapper = defineComponent({
> >
<AppRequestCancelerProvider /> <AppRequestCancelerProvider />
{this.reloadRouteSwitch ? ( {this.reloadRouteSwitch ? (
<RayTransitionComponent <RTransitionComponent
class="content-wrapper" class="content-wrapper"
transitionPropName={this.contentTransition + '-transform'} transitionPropName={this.contentTransition + '-transform'}
/> />

View File

@ -60,9 +60,7 @@ const RLayout = defineComponent({
<HeaderWrapper ref="layoutSiderBarRef" /> <HeaderWrapper ref="layoutSiderBarRef" />
{this.modelMenuTagSwitch ? ( {this.modelMenuTagSwitch ? (
<FeatureWrapper ref="layoutMenuTagRef" /> <FeatureWrapper ref="layoutMenuTagRef" />
) : ( ) : null}
''
)}
<NLayoutContent <NLayoutContent
ref="LAYOUT_CONTENT_REF" ref="LAYOUT_CONTENT_REF"
class="r-layout-full__viewer-content" class="r-layout-full__viewer-content"
@ -73,9 +71,7 @@ const RLayout = defineComponent({
{this.footerSwitch ? <FooterWrapper ref="layoutFooterRef" /> : ''} {this.footerSwitch ? <FooterWrapper ref="layoutFooterRef" /> : ''}
</NLayoutContent> </NLayoutContent>
</NLayout> </NLayout>
) : ( ) : null
''
)
}, },
}) })

View File

@ -5,7 +5,7 @@
> router modules 包中的路由模块会与菜单一一映射,也就是说,路由模块的配置结构会影响菜单的展示。当你有子菜单需要配置时,你需要使用该组件。 > router modules 包中的路由模块会与菜单一一映射,也就是说,路由模块的配置结构会影响菜单的展示。当你有子菜单需要配置时,你需要使用该组件。
```ts ```ts
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -12,7 +12,7 @@
import { permissionRouter } from './permission' import { permissionRouter } from './permission'
import { SETUP_ROUTER_ACTION, SUPER_ADMIN } from '@/app-config/routerConfig' import { SETUP_ROUTER_ACTION, SUPER_ADMIN } from '@/app-config/routerConfig'
import { useSignin } from '@/store' import { useSignin } from '@/store'
import { useVueRouter } from '@/router/helper/useVueRouter' import { useVueRouter } from '@/hooks/web/index'
import { ROOT_ROUTE } from '@/app-config/appConfig' import { ROOT_ROUTE } from '@/app-config/appConfig'
import { setStorage } from '@/utils/cache' import { setStorage } from '@/utils/cache'
import { getAppEnvironment } from '@/utils/hook' import { getAppEnvironment } from '@/utils/hook'

View File

@ -1,7 +1,7 @@
import { createRouter, createWebHashHistory } from 'vue-router' import { createRouter, createWebHashHistory } from 'vue-router'
import { scrollViewToTop } from '@/router/helper/helper' import { scrollViewToTop } from '@/router/helper/helper'
import { vueRouterRegister } from '@/router/helper/routerCopilot' import { vueRouterRegister } from '@/router/helper/routerCopilot'
import { useVueRouter } from '@/router/helper/useVueRouter' import { useVueRouter } from '@/hooks/web/index'
import constantRoutes from './routes' import constantRoutes from './routes'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -4,7 +4,7 @@
* *
*/ */
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,4 +1,4 @@
import { t } from '@/locales/useI18n' import { t } from '@/hooks/web/index'
import { LAYOUT } from '@/router/constant/index' import { LAYOUT } from '@/router/constant/index'
import type { AppRouteRecordRaw } from '@/router/type' import type { AppRouteRecordRaw } from '@/router/type'

View File

@ -1,5 +1,5 @@
import Layout from '@/layout/index' import Layout from '@/layout/index'
import { getAppRawRoutes } from './routeModules' import { getAppRawRoutes } from './appRouteModules'
import { ROOT_ROUTE } from '@/app-config/appConfig' import { ROOT_ROUTE } from '@/app-config/appConfig'
import { expandRoutes } from '@/router/helper/expandRoutes' import { expandRoutes } from '@/router/helper/expandRoutes'

View File

@ -1,9 +0,0 @@
export const spinValue = ref(false)
/**
*
* @param bool has spin
*
* @remark 使 spin
*/
export const setSpin = (bool: boolean) => (spinValue.value = bool)

View File

@ -16,8 +16,8 @@
* Naive UI Spin * Naive UI Spin
* *
* 使 * 使
* 1. import { setSpin } from '@/spin' * 1. import { setVariable } from '@/hooks/variable/index'
* 2. setSpin(true) | setSpin(false) * 2. setVariable('globalSpinning', true) | setVariable('globalSpinning', false)
* *
* *
* *
@ -29,9 +29,7 @@
import { NSpin } from 'naive-ui' import { NSpin } from 'naive-ui'
import { spinProps } from 'naive-ui' import { spinProps } from 'naive-ui'
import { spinValue } from './hook' import { globalVariableToRefs } from '@/hooks/variable/index'
export { setSpin } from './hook'
const GlobalSpin = defineComponent({ const GlobalSpin = defineComponent({
name: 'GlobalSpin', name: 'GlobalSpin',
@ -42,6 +40,7 @@ const GlobalSpin = defineComponent({
const overrides = { const overrides = {
opacitySpinning: '0.3', opacitySpinning: '0.3',
} }
const spinValue = globalVariableToRefs('globalSpinning')
return { return {
spinValue, spinValue,

View File

@ -12,7 +12,7 @@
/** 本方法感谢 <https://yunkuangao.me/> 的支持 */ /** 本方法感谢 <https://yunkuangao.me/> 的支持 */
import { APP_MENU_CONFIG, ROOT_ROUTE } from '@/app-config/appConfig' import { APP_MENU_CONFIG, ROOT_ROUTE } from '@/app-config/appConfig'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import { isValueType } from '@/utils/hook' import { isValueType } from '@/utils/hook'
import { getStorage, setStorage } from '@/utils/cache' import { getStorage, setStorage } from '@/utils/cache'
@ -164,6 +164,7 @@ export const hasMenuIcon = (option: AppMenuOption) => {
{ {
name: meta!.icon as string, name: meta!.icon as string,
size: APP_MENU_CONFIG.MENU_COLLAPSED_ICON_SIZE, size: APP_MENU_CONFIG.MENU_COLLAPSED_ICON_SIZE,
cursor: 'pointer',
}, },
{}, {},
) )

View File

@ -32,10 +32,10 @@ import {
hasMenuIcon, hasMenuIcon,
getCatchMenuKey, getCatchMenuKey,
} from './helper' } from './helper'
import { useI18n } from '@/locales/useI18n' import { useI18n } from '@/hooks/web/index'
import { getAppRawRoutes } from '@/router/routeModules' import { getAppRawRoutes } from '@/router/appRouteModules'
import { useKeepAlive } from '@/store' import { useKeepAlive } from '@/store'
import { useVueRouter } from '@/router/helper/useVueRouter' import { useVueRouter } from '@/hooks/web/index'
import type { AppRouteMeta, AppRouteRecordRaw } from '@/router/type' import type { AppRouteMeta, AppRouteRecordRaw } from '@/router/type'
import type { import type {

View File

@ -2,9 +2,9 @@ import { getAppDefaultLanguage } from '@/locales/helper'
import { setStorage } from '@use-utils/cache' import { setStorage } from '@use-utils/cache'
import { set } from 'lodash-es' import { set } from 'lodash-es'
import { addClass, removeClass, colorToRgba } from '@/utils/element' import { addClass, removeClass, colorToRgba } from '@/utils/element'
import { useI18n } from '@/locales/useI18n' import { useI18n } from '@/hooks/web/index'
import { APP_THEME } from '@/app-config/designConfig' import { APP_THEME } from '@/app-config/designConfig'
import { useDayjs } from '@/dayjs/index' import { useDayjs } from '@/hooks/web/index'
import type { ConditionalPick } from '@/types/modules/helper' import type { ConditionalPick } from '@/types/modules/helper'
import type { SettingState } from '@/store/modules/setting/type' import type { SettingState } from '@/store/modules/setting/type'

View File

@ -9,7 +9,7 @@ import {
NP, NP,
NH6, NH6,
} from 'naive-ui' } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
import RayLink from '@/app-components/app/RayLink/index' import RayLink from '@/app-components/app/RayLink/index'
const Dashboard = defineComponent({ const Dashboard = defineComponent({

View File

@ -9,7 +9,7 @@
* @remark * @remark
*/ */
import RayIframe from '@/components/RayIframe/index' import RayIframe from '@/components/RIframe/index'
const RTemplateDoc = defineComponent({ const RTemplateDoc = defineComponent({
name: 'RTemplateDoc', name: 'RTemplateDoc',

View File

@ -1,12 +1,12 @@
import './index.scss' import './index.scss'
import { NCard, NSwitch, NSpace, NP, NH2, NButton } from 'naive-ui' import { NCard, NSwitch, NSpace, NP, NH2, NButton } from 'naive-ui'
import RayChart from '@/components/RayChart/index' import RayChart from '@/components/RChart/index'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { ECharts } from 'echarts/core' import type { ECharts } from 'echarts/core'
import type { RayChartInst } from '@/components/RayChart/index' import type { RayChartInst } from '@/components/RChart/index'
const Echart = defineComponent({ const Echart = defineComponent({
name: 'REchart', name: 'REchart',

View File

@ -18,7 +18,7 @@
*/ */
import { NCard, NSpace } from 'naive-ui' import { NCard, NSpace } from 'naive-ui'
import RayIframe from '@/components/RayIframe/index' import RayIframe from '@/components/RIframe/index'
const IframeDemo = defineComponent({ const IframeDemo = defineComponent({
name: 'IframeDemo', name: 'IframeDemo',

View File

@ -10,8 +10,8 @@
*/ */
import { NSpace, NCard, NButton, NFormItemGi, NInput, NForm } from 'naive-ui' import { NSpace, NCard, NButton, NFormItemGi, NInput, NForm } from 'naive-ui'
import RayTable from '@/components/RayTable/index' import RayTable from '@/components/RTable/index'
import RayCollapseGrid from '@/components/RayCollapseGrid/index' import RayCollapseGrid from '@/components/RCollapseGrid/index'
import { useHookPlusRequest } from '@/axios/index' import { useHookPlusRequest } from '@/axios/index'
import { getPersonList } from '@/axios/api/demo/mock/person' import { getPersonList } from '@/axios/api/demo/mock/person'

View File

@ -10,11 +10,11 @@
*/ */
import { NSpace, NCard, NButton } from 'naive-ui' import { NSpace, NCard, NButton } from 'naive-ui'
import RayQRcode from '@/components/RayQRCode/index' import RayQRcode from '@/components/RQRCode/index'
import LOGO from '@/assets/images/ray.svg' import LOGO from '@/assets/images/ray.svg'
import type { QRCodeStatus, QRCodeInst } from '@/components/RayQRCode/index' import type { QRCodeStatus, QRCodeInst } from '@/components/RQRCode/index'
const RQRCode = defineComponent({ const RQRCode = defineComponent({
name: 'RQRCode', name: 'RQRCode',

View File

@ -10,7 +10,7 @@
*/ */
import { NSpace, NDataTable, NButton } from 'naive-ui' import { NSpace, NDataTable, NButton } from 'naive-ui'
import RayTable from '@/components/RayTable/index' import RayTable from '@/components/RTable/index'
import type { DataTableColumns } from 'naive-ui' import type { DataTableColumns } from 'naive-ui'

View File

@ -12,7 +12,7 @@
import './index.scss' import './index.scss'
import { NSpace, NCard, NPopover } from 'naive-ui' import { NSpace, NCard, NPopover } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
const PreviewSVGIcons = defineComponent({ const PreviewSVGIcons = defineComponent({
name: 'PreviewSVGIcons', name: 'PreviewSVGIcons',

View File

@ -24,11 +24,11 @@ import {
NLi, NLi,
NSpace, NSpace,
} from 'naive-ui' } from 'naive-ui'
import RayTable from '@/components/RayTable/index' import RayTable from '@/components/RTable/index'
import RayCollapseGrid from '@/components/RayCollapseGrid/index' import RayCollapseGrid from '@/components/RCollapseGrid/index'
import type { DataTableColumns } from 'naive-ui' import type { DataTableColumns } from 'naive-ui'
import type { RayTableInst } from '@/components/RayTable/index' import type { RayTableInst } from '@/components/RTable/index'
type RowData = { type RowData = {
key: number key: number

View File

@ -11,7 +11,7 @@
import './index.scss' import './index.scss'
import RayQRcode from '@/components/RayQRCode/index' import RayQRcode from '@/components/RQRCode/index'
import LOGO from '@/assets/images/ray.svg' import LOGO from '@/assets/images/ray.svg'

View File

@ -19,7 +19,7 @@
import './index.scss' import './index.scss'
import { NSpace, NPopover } from 'naive-ui' import { NSpace, NPopover } from 'naive-ui'
import RayIcon from '@/components/RayIcon/index' import RayIcon from '@/components/RIcon/index'
interface SSOSigninOptions { interface SSOSigninOptions {
icon: string icon: string

View File

@ -1,11 +1,11 @@
import { NForm, NFormItem, NInput, NButton, NSpace, NDivider } from 'naive-ui' import { NForm, NFormItem, NInput, NButton, NSpace, NDivider } from 'naive-ui'
import { setStorage } from '@/utils/cache' import { setStorage } from '@/utils/cache'
import { setSpin } from '@/spin'
import { useSignin } from '@/store' import { useSignin } from '@/store'
import { useI18n } from '@/locales/useI18n' import { useI18n } from '@/hooks/web/index'
import { APP_CATCH_KEY, ROOT_ROUTE } from '@/app-config/appConfig' import { APP_CATCH_KEY, ROOT_ROUTE } from '@/app-config/appConfig'
import { useVueRouter } from '@/router/helper/useVueRouter' import { useVueRouter } from '@/hooks/web/index'
import { setVariable } from '@/hooks/variable/index'
import type { FormInst } from 'naive-ui' import type { FormInst } from 'naive-ui'
@ -45,13 +45,13 @@ const Signin = defineComponent({
const handleLogin = () => { const handleLogin = () => {
loginFormRef.value?.validate((valid) => { loginFormRef.value?.validate((valid) => {
if (!valid) { if (!valid) {
setSpin(true) setVariable('globalSpinning', true)
signin(signinForm.value) signin(signinForm.value)
.then((res) => { .then((res) => {
if (res.code === 0) { if (res.code === 0) {
setTimeout(() => { setTimeout(() => {
setSpin(false) setVariable('globalSpinning', false)
window.$message.success(`欢迎${signinForm.value.name}登陆~`) window.$message.success(`欢迎${signinForm.value.name}登陆~`)

View File

@ -2,6 +2,7 @@ $positionX: 24px;
$positionY: 24px; $positionY: 24px;
.login { .login {
width: 100%;
display: flex; display: flex;
& .login-wrapper { & .login-wrapper {

View File

@ -15,13 +15,13 @@ import Signin from './components/Signin/index'
import Register from './components/Register/index' import Register from './components/Register/index'
import QRCodeSignin from './components/QRCodeSignin/index' import QRCodeSignin from './components/QRCodeSignin/index'
import SSOSignin from './components/SSOSignin/index' import SSOSignin from './components/SSOSignin/index'
import RayIcon from '@/components/RayIcon' import RayIcon from '@/components/RIcon'
import RayLink from '@/app-components/app/RayLink/index' import RayLink from '@/app-components/app/RayLink/index'
import ThemeSwitch from '@/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch/index' import ThemeSwitch from '@/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch/index'
import { useSetting } from '@/store' import { useSetting } from '@/store'
import { LOCAL_OPTIONS } from '@/app-config/localConfig' import { LOCAL_OPTIONS } from '@/app-config/localConfig'
import { useI18n } from '@/locales/useI18n' import { useI18n } from '@/hooks/web/index'
const Login = defineComponent({ const Login = defineComponent({
name: 'RLogin', name: 'RLogin',
@ -88,6 +88,7 @@ const Login = defineComponent({
customClassName="login-icon" customClassName="login-icon"
name="language" name="language"
size="18" size="18"
cursor="pointer"
/> />
</NDropdown> </NDropdown>
</NSpace> </NSpace>

Some files were not shown because too many files have changed in this diff Show More