From 36d646d8bae9d4258b19e37094b4469725a09b27 Mon Sep 17 00:00:00 2001
From: XiaoDaiGua-Ray <443547225@qq.com>
Date: Thu, 2 Nov 2023 17:51:12 +0800
Subject: [PATCH] v4.2.9
---
.vscode/settings.json | 13 ++-
CHANGELOG.md | 24 ++++-
package.json | 2 +-
src/App.tsx | 2 +-
src/{axios => }/api/demo/mock/person.ts | 0
src/{axios => }/api/demo/test.ts | 0
src/app-components/app/AppAvatar/index.tsx | 10 +-
.../components/UnlockScreen/index.tsx | 14 ++-
src/app-config/appConfig.ts | 4 +-
src/app-config/regexConfig.ts | 2 +-
src/axios/helper/RequestCanceler.ts | 4 +-
src/axios/helper/interceptor.ts | 2 +-
src/components/RChart/helper.ts | 4 +-
src/components/RChart/index.tsx | 39 ++++---
src/components/RCollapseGrid/src/index.tsx | 10 +-
src/components/RIcon/index.tsx | 54 +---------
src/components/RIcon/props.ts | 61 +++++++++++
src/components/RIframe/src/index.tsx | 5 +-
src/components/RMoreDropdown/src/index.tsx | 12 +--
src/components/RQRCode/src/props.ts | 2 +-
src/components/RTable/src/Table.tsx | 4 +-
src/directives/index.ts | 13 ++-
src/global-variable/README.md | 30 ++++++
src/global-variable/index.ts | 18 ++++
src/global-variable/variable.ts | 62 +++++++++++
src/hooks/variable/index.ts | 18 ----
src/hooks/variable/useGlobalVariable.ts | 41 -------
src/hooks/web/useDayjs.ts | 4 +-
src/icons/empty.svg | 6 ++
src/layout/components/Menu/index.tsx | 15 +--
src/layout/components/MenuTag/index.scss | 2 +-
src/layout/components/MenuTag/index.tsx | 67 ++++++------
.../{GlobalSeach => GlobalSearch}/index.scss | 43 +++++---
.../{GlobalSeach => GlobalSearch}/index.tsx | 100 +++++++++++-------
src/layout/components/SiderBar/hook.ts | 6 +-
src/layout/components/SiderBar/index.tsx | 14 +--
src/layout/default/ContentWrapper/index.tsx | 6 +-
src/locales/helper.ts | 4 +-
src/locales/lang/en-US/menu.json | 4 +-
src/locales/lang/zh-CN/menu.json | 4 +-
src/main.ts | 7 +-
src/router/helper/routerCopilot.ts | 8 +-
src/router/modules/demo/qrcode.ts | 2 +-
src/router/modules/demo/svg-icons.ts | 2 +-
src/spin/index.tsx | 4 +-
src/store/README.md | 2 +-
src/store/index.ts | 2 +-
src/store/modules/menu/helper.ts | 2 +-
src/store/modules/menu/index.ts | 8 +-
src/store/modules/signin/type.ts | 16 ---
.../modules/{signin => signing}/index.ts | 34 +++---
src/store/modules/signing/type.ts | 16 +++
src/styles/naive.scss | 7 +-
src/types/modules/utils.ts | 88 ++++++++++-----
src/utils/basic.ts | 79 +++++++++-----
src/utils/element.ts | 2 +-
src/utils/precision.ts | 2 +-
src/utils/vue/renderNode.ts | 14 +--
src/views/dashboard/index.tsx | 1 +
src/views/demo/axios/index.tsx | 2 +-
src/views/demo/mock-demo/index.tsx | 4 +-
src/views/login/components/Signin/index.tsx | 28 ++---
tsconfig.json | 4 +-
vite-plugins/index.ts | 12 +--
vite-plugins/type.ts | 4 +-
vite.pliugin.config.ts | 1 -
66 files changed, 644 insertions(+), 432 deletions(-)
rename src/{axios => }/api/demo/mock/person.ts (100%)
rename src/{axios => }/api/demo/test.ts (100%)
create mode 100644 src/components/RIcon/props.ts
create mode 100644 src/global-variable/README.md
create mode 100644 src/global-variable/index.ts
create mode 100644 src/global-variable/variable.ts
delete mode 100644 src/hooks/variable/index.ts
delete mode 100644 src/hooks/variable/useGlobalVariable.ts
create mode 100644 src/icons/empty.svg
rename src/layout/components/SiderBar/components/{GlobalSeach => GlobalSearch}/index.scss (68%)
rename src/layout/components/SiderBar/components/{GlobalSeach => GlobalSearch}/index.tsx (79%)
delete mode 100644 src/store/modules/signin/type.ts
rename src/store/modules/{signin => signing}/index.ts (75%)
create mode 100644 src/store/modules/signing/type.ts
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 409e9964..133d1347 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -17,5 +17,16 @@
"@mock": "/mock"
},
"alias-skip.allowedsuffix": ["ts", "tsx"],
- "alias-skip.rootpath": "package.json"
+ "alias-skip.rootpath": "package.json",
+ "cSpell.words": [
+ "Clickoutside",
+ "macarons",
+ "menutag",
+ "ndata",
+ "persistedstate",
+ "Popselect",
+ "siderbar",
+ "WUJIE",
+ "zlevel"
+ ]
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 766d5cf1..5ae9bfba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,27 @@
# CHANGE LOG
+## 4.2.9
+
+主要更新了命名问题。并且使用单词检查器,扫描整个项目替换了拼写错误的单词。
+
+### Feats
+
+- setVariable 方法新增回调函数参数
+- 优化 getVariable ts 类型提示,并且使用 readonly 方法包裹
+- 重命名 globalVariableToRefs 为 getVariableToRefs,并且使用 readonly 方法包裹
+- renderNode 方法新增对于 Slot 类型参数支持
+- 新增 BasicTypes 类型
+- 提取 RIcon 组件 props 单独维护
+- 将 api 管理,提取到 `src` 下维护
+- getAppLocalMessages 获取路径方式由相对路径改为绝对路径
+- 将 hooks 包中的 variable 方法提取至 `src` 下管理,并且更改名称为 `global-variable`
+- 调整 GlobalSearch 样式
+
+### Fixes
+
+- 修复 downloadBase64File 下载后不能正常移除 `a` 标签问题
+- 修复 downloadAnyFile 存在的可能未加载完成而提前执行方法的问题
+
## 4.2.8
我好像犯了一个很愚蠢的错误,那就是使用 useFullscreen 方法的时候总是会弹出提示。所以紧急修复了这个很愚蠢的问题,并且移除了这个方法。
@@ -30,7 +52,7 @@
- RChart
- 修复 animation false 状态渲染异常问题
- 修复响应式代理 echart instance 时,导致部分方法异常问题
-
+
## 4.2.7
主要是做了一些统一命名的事情,以前由于写的比较放浪形骸现在正在慢慢更改这个大问题。
diff --git a/package.json b/package.json
index 63e9da4c..87a3ec09 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "ray-template",
"private": false,
- "version": "4.2.8",
+ "version": "4.2.9",
"type": "module",
"engines": {
"node": ">=16.0.0",
diff --git a/src/App.tsx b/src/App.tsx
index ee1b0962..0f93d8be 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -16,7 +16,7 @@ export default defineComponent({
{{
default: () => ,
- description: () => 'lodaing...',
+ description: () => 'loading...',
}}
diff --git a/src/axios/api/demo/mock/person.ts b/src/api/demo/mock/person.ts
similarity index 100%
rename from src/axios/api/demo/mock/person.ts
rename to src/api/demo/mock/person.ts
diff --git a/src/axios/api/demo/test.ts b/src/api/demo/test.ts
similarity index 100%
rename from src/axios/api/demo/test.ts
rename to src/api/demo/test.ts
diff --git a/src/app-components/app/AppAvatar/index.tsx b/src/app-components/app/AppAvatar/index.tsx
index 4e561648..98e52a40 100644
--- a/src/app-components/app/AppAvatar/index.tsx
+++ b/src/app-components/app/AppAvatar/index.tsx
@@ -27,7 +27,7 @@ import { getStorage } from '@/utils/cache'
import type { PropType } from 'vue'
import type { AvatarProps, SpaceProps } from 'naive-ui'
-import type { SigninCallback } from '@/store/modules/signin/type'
+import type { SigningCallback } from '@/store/modules/signing/type'
const AppAvatar = defineComponent({
name: 'AppAvatar',
@@ -48,7 +48,7 @@ const AppAvatar = defineComponent({
},
},
setup(props) {
- const signin = getStorage(APP_CATCH_KEY.signin)
+ const signing = getStorage(APP_CATCH_KEY.signing)
const cssVars = computed(() => {
const vars = {
'--app-avatar-cursor': props.cursor,
@@ -58,7 +58,7 @@ const AppAvatar = defineComponent({
})
return {
- signin,
+ signing,
cssVars,
}
},
@@ -74,12 +74,12 @@ const AppAvatar = defineComponent({
- {this.signin?.name}
+ {this.signing?.name}
)
},
diff --git a/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx b/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx
index 1998d637..31cf66f0 100644
--- a/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx
+++ b/src/app-components/app/AppLockScreen/components/UnlockScreen/index.tsx
@@ -15,20 +15,20 @@ import { NInput, NForm, NFormItem, NButton, NSpace } from 'naive-ui'
import AppAvatar from '@/app-components/app/AppAvatar/index'
import dayjs from 'dayjs'
-import { useSetting, useSignin } from '@/store'
+import { useSetting, useSigning } from '@/store'
import { rules, useCondition } from '@/app-components/app/AppLockScreen/hook'
import useAppLockScreen from '@/app-components/app/AppLockScreen/appLockVar'
import { useDevice } from '@/hooks/web/index'
import type { FormInst, InputInst } from 'naive-ui'
-const UnlockScreen = defineComponent({
+export default defineComponent({
name: 'UnlockScreen',
setup() {
const formRef = ref(null)
const inputInstRef = ref(null)
- const { logout } = useSignin()
+ const { logout } = useSigning()
const { changeSwitcher } = useSetting()
const { setLockAppScreen } = useAppLockScreen()
const { isTabletOrSmaller } = useDevice()
@@ -55,7 +55,7 @@ const UnlockScreen = defineComponent({
}, 86_400_000)
/** 退出登陆并且回到登陆页 */
- const backToSignin = () => {
+ const backToSigning = () => {
window.$dialog.warning({
title: '警告',
content: '是否返回到登陆页?',
@@ -89,7 +89,7 @@ const UnlockScreen = defineComponent({
return {
...toRefs(state),
- backToSignin,
+ backToSigning,
unlockScreen,
formRef,
inputInstRef,
@@ -138,7 +138,7 @@ const UnlockScreen = defineComponent({
返回登陆
@@ -165,5 +165,3 @@ const UnlockScreen = defineComponent({
)
},
})
-
-export default UnlockScreen
diff --git a/src/app-config/appConfig.ts b/src/app-config/appConfig.ts
index 157d8506..4e6bd4f0 100644
--- a/src/app-config/appConfig.ts
+++ b/src/app-config/appConfig.ts
@@ -99,12 +99,12 @@ export const APP_MENU_CONFIG: Readonly = {
* 仅暴露部分系统获取缓存配置, 其余 key 暂不开放
*
* 说明:
- * - signin: 登陆信息缓存 key
+ * - signing: 登陆信息缓存 key
* - localeLanguage: 国际化默认缓存 key
* - token: token key
*/
export const APP_CATCH_KEY = {
- signin: 'signin',
+ signing: 'signing',
localeLanguage: 'localeLanguage',
token: 'token',
} as const
diff --git a/src/app-config/regexConfig.ts b/src/app-config/regexConfig.ts
index 1c0c5b06..60bd9986 100644
--- a/src/app-config/regexConfig.ts
+++ b/src/app-config/regexConfig.ts
@@ -17,6 +17,6 @@
export const APP_REGEX: Record = {
/** css 尺寸单位匹配 */
- validerCSSUnit:
+ validCSSUnit:
/^\d+(\.\d+)?(px|em|rem|%|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ch|ex|q|s|ms|deg|rad|turn|grad|hz|khz|dpi|dpcm|dppx|fr|auto)$/,
}
diff --git a/src/axios/helper/RequestCanceler.ts b/src/axios/helper/RequestCanceler.ts
index 6555f4ce..f35c642c 100644
--- a/src/axios/helper/RequestCanceler.ts
+++ b/src/axios/helper/RequestCanceler.ts
@@ -26,7 +26,7 @@ export default class RequestCanceler {
}
/** 是否需要加入取消请求表中 */
- private isApending(config: AppRawRequestConfig) {
+ private isAppending(config: AppRawRequestConfig) {
return config.cancelConfig?.needCancel ?? true
}
@@ -55,7 +55,7 @@ export default class RequestCanceler {
* @remark 给请求体添加 signal 属性, 用于取消请求
*/
addPendingRequest(config: AppRawRequestConfig) {
- if (this.isApending(config)) {
+ if (this.isAppending(config)) {
const requestKey = this.generateRequestKey(config)
if (!this.pendingRequest.has(requestKey)) {
diff --git a/src/axios/helper/interceptor.ts b/src/axios/helper/interceptor.ts
index 897059cd..4630c527 100644
--- a/src/axios/helper/interceptor.ts
+++ b/src/axios/helper/interceptor.ts
@@ -44,7 +44,7 @@ const axiosFetchError: AxiosFetchError = {
requestError: null,
responseError: null,
}
-/** 请求队列(区分 reslove 与 reject 状态) */
+/** 请求队列(区分 resolve 与 reject 状态) */
const implement: ImplementQueue = {
implementRequestInterceptorArray: [],
implementResponseInterceptorArray: [],
diff --git a/src/components/RChart/helper.ts b/src/components/RChart/helper.ts
index afc6437e..4f4ee0ea 100644
--- a/src/components/RChart/helper.ts
+++ b/src/components/RChart/helper.ts
@@ -34,10 +34,10 @@ export const setupChartTheme = () => {
import.meta.glob('@/echart-themes/**/*.json', {
eager: true,
})
- const regx = /\/([^/]+)\.json$/
+ const regex = /\/([^/]+)\.json$/
const rawThemes = Object.keys(themeRawModules).reduce((pre, curr) => {
- const name = curr.match(regx)?.[1]
+ const name = curr.match(regex)?.[1]
if (name) {
pre.push({
diff --git a/src/components/RChart/index.tsx b/src/components/RChart/index.tsx
index 83e07f0f..527e8398 100644
--- a/src/components/RChart/index.tsx
+++ b/src/components/RChart/index.tsx
@@ -56,7 +56,6 @@ import type { AnyFC } from '@/types/modules/utils'
import type { DebouncedFunc } from 'lodash-es'
import type { UseResizeObserverReturn } from '@vueuse/core'
import type { ECharts, EChartsCoreOption } from 'echarts/core'
-import type { RenderVNodeType } from '@use-utils/vue/renderNode'
import type { DropdownProps, DropdownOption } from 'naive-ui'
const defaultChartOptions = {
@@ -77,7 +76,7 @@ export default defineComponent({
const rayChartWrapperRef = ref()
const echartInstanceRef = ref() // echart 实例
let resizeThrottleReturn: DebouncedFunc | null // resize 防抖方法实例
- let resizeOvserverReturn: UseResizeObserverReturn | null
+ let resizeObserverReturn: UseResizeObserverReturn | null
const { echartTheme } = APP_THEME
let watchCallback: WatchStopHandle | null
let echartInst: ECharts | null // 无代理响应式代理缓存 echart inst
@@ -85,19 +84,16 @@ export default defineComponent({
{
label: '下载图片',
key: 'downloadChart',
- disabled:
+ disabled: !(
echartInstanceRef.value && echartInstanceRef.value.getDom()
- ? false
- : true,
+ ),
},
])
const cssVarsRef = computed(() => {
- const cssVars = {
+ return {
'--ray-chart-width': completeSize(props.width),
'--ray-chart-height': completeSize(props.height),
}
-
- return cssVars
})
/**
@@ -257,14 +253,16 @@ export default defineComponent({
}
}
+ const isDispose = () => !!(echartInst && echartInst.getDom())
+
/**
*
* 销毁 `chart` 实例, 释放资源
*/
const destroyChart = () => {
- if (echartInst && echartInst.getDom()) {
- echartInst.clear()
- echartInst.dispose()
+ if (isDispose()) {
+ echartInst!.clear()
+ echartInst!.dispose()
echartInstanceRef.value = void 0
}
}
@@ -277,11 +275,11 @@ export default defineComponent({
}
const dropdownSelect = (key: string | number, option: DropdownOption) => {
- if (key === 'downloadChart' && echartInst && echartInst.getDom()) {
+ if (key === 'downloadChart' && isDispose()) {
const { filename, ...args } = props.downloadOptions
downloadBase64File(
- echartInst.getDataURL(args),
+ echartInst!.getDataURL(args),
filename ?? `${new Date().getTime()}`,
)
}
@@ -310,7 +308,7 @@ export default defineComponent({
resizeThrottleReturn = throttle(resizeChart, props.throttleWait)
/** 监听内容区域尺寸变化更新 chart */
- resizeOvserverReturn = useResizeObserver(
+ resizeObserverReturn = useResizeObserver(
props.observer || rayChartWrapperRef,
resizeThrottleReturn,
)
@@ -323,7 +321,7 @@ export default defineComponent({
/** 注销防抖 */
resizeThrottleReturn?.cancel()
/** 注销 observer 监听 */
- resizeOvserverReturn?.stop?.()
+ resizeObserverReturn?.stop?.()
}
/** 监听全局主题变化, 然后重新渲染对应主题 echarts */
@@ -362,9 +360,9 @@ export default defineComponent({
if (props.watchOptions) {
watchCallback = watch(
() => props.options,
- (noptions) => {
+ (ndata) => {
/** 重新组合 options */
- const options = combineChartOptions(noptions)
+ const options = combineChartOptions(ndata)
const setOpt = Object.assign(
props.setChartOptions,
defaultChartOptions,
@@ -432,13 +430,13 @@ export default defineComponent({
bordered={bordered}
>
{{
- default: () => (
-
+ default: renderNode(
+ ,
),
header: renderNode(title, {
defaultElement: ,
}),
- 'header-extra': renderNode(cardExtra as RenderVNodeType, {
+ 'header-extra': renderNode(cardExtra, {
defaultElement: (
),
}),
diff --git a/src/components/RCollapseGrid/src/index.tsx b/src/components/RCollapseGrid/src/index.tsx
index cc0ffb66..f0d49819 100644
--- a/src/components/RCollapseGrid/src/index.tsx
+++ b/src/components/RCollapseGrid/src/index.tsx
@@ -27,13 +27,13 @@ import RIcon from '@/components/RIcon'
import { call } from '@/utils/vue/index'
import props from './props'
-const RCollapseGrid = defineComponent({
+export default defineComponent({
name: 'RCollapseGrid',
props,
setup(props) {
const modelCollapsed = ref(!props.open)
- const handleCollapse = () => {
+ const collapseClick = () => {
modelCollapsed.value = !modelCollapsed.value
const { onUpdateValue, 'onUpdate:value': _onUpdateValue } = props
@@ -48,7 +48,7 @@ const RCollapseGrid = defineComponent({
}
const CollapseIcon = () => (
-
+
{modelCollapsed.value
? props.collapseToggleText[0]
@@ -66,7 +66,7 @@ const RCollapseGrid = defineComponent({
return {
modelCollapsed,
- handleCollapse,
+ collapseClick,
CollapseIcon,
}
},
@@ -97,5 +97,3 @@ const RCollapseGrid = defineComponent({
)
},
})
-
-export default RCollapseGrid
diff --git a/src/components/RIcon/index.tsx b/src/components/RIcon/index.tsx
index 7c46694b..2695052b 100644
--- a/src/components/RIcon/index.tsx
+++ b/src/components/RIcon/index.tsx
@@ -13,57 +13,11 @@ import './index.scss'
import { call } from '@/utils/vue/index'
import { completeSize } from '@/utils/element'
+import props from './props'
-import type { PropType } from 'vue'
-import type { MaybeArray } from '@/types/modules/utils'
-
-const RIcon = defineComponent({
+export default defineComponent({
name: 'RIcon',
- props: {
- color: {
- type: String,
- default: 'currentColor',
- },
- prefix: {
- type: String,
- default: 'icon',
- },
- name: {
- type: String,
- required: true,
- },
- size: {
- type: [Number, String],
- default: 14,
- },
- width: {
- type: [Number, String],
- default: 0,
- },
- height: {
- type: [Number, String],
- default: 0,
- },
- customClassName: {
- /** 自定义 class name */
- type: String,
- default: null,
- },
- depth: {
- /** 图标深度 */
- type: Number,
- default: 1,
- },
- cursor: {
- /** 鼠标指针样式 */
- type: String,
- default: 'default',
- },
- onClick: {
- type: [Function, Array] as PropType void>>,
- default: null,
- },
- },
+ props,
setup(props) {
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
const cssVars = computed(() => {
@@ -111,5 +65,3 @@ const RIcon = defineComponent({
)
},
})
-
-export default RIcon
diff --git a/src/components/RIcon/props.ts b/src/components/RIcon/props.ts
new file mode 100644
index 00000000..bce58a2e
--- /dev/null
+++ b/src/components/RIcon/props.ts
@@ -0,0 +1,61 @@
+/**
+ *
+ * @author Ray
+ *
+ * @date 2023-10-27
+ *
+ * @workspace ray-template
+ *
+ * @remark 今天也是元气满满撸代码的一天
+ */
+
+import type { PropType } from 'vue'
+import type { MaybeArray } from '@/types/modules/utils'
+
+const props = {
+ color: {
+ type: String,
+ default: 'currentColor',
+ },
+ prefix: {
+ type: String,
+ default: 'icon',
+ },
+ name: {
+ type: String,
+ required: true,
+ },
+ size: {
+ type: [Number, String],
+ default: 14,
+ },
+ width: {
+ type: [Number, String],
+ default: 0,
+ },
+ height: {
+ type: [Number, String],
+ default: 0,
+ },
+ customClassName: {
+ /** 自定义 class name */
+ type: String,
+ default: null,
+ },
+ depth: {
+ /** 图标深度 */
+ type: Number,
+ default: 1,
+ },
+ cursor: {
+ /** 鼠标指针样式 */
+ type: String,
+ default: 'default',
+ },
+ onClick: {
+ type: [Function, Array] as PropType void>>,
+ default: null,
+ },
+}
+
+export default props
diff --git a/src/components/RIframe/src/index.tsx b/src/components/RIframe/src/index.tsx
index 2c9a8f65..8f527861 100644
--- a/src/components/RIframe/src/index.tsx
+++ b/src/components/RIframe/src/index.tsx
@@ -17,7 +17,7 @@ import { completeSize, on, off } from '@use-utils/element'
import { call } from '@/utils/vue/index'
import props from './props'
-const RIframe = defineComponent({
+export default defineComponent({
name: 'RIframe',
props,
setup(props, { expose }) {
@@ -61,7 +61,6 @@ const RIframe = defineComponent({
on(iframeRef.value, 'load', iframeLoadSuccess.bind(this))
on(iframeRef.value, 'error', iframeLoadError)
})
-
onBeforeUnmount(() => {
off(iframeRef.value, 'load', iframeLoadSuccess)
off(iframeRef.value, 'error', iframeLoadError)
@@ -101,5 +100,3 @@ const RIframe = defineComponent({
)
},
})
-
-export default RIframe
diff --git a/src/components/RMoreDropdown/src/index.tsx b/src/components/RMoreDropdown/src/index.tsx
index 57ca242b..444a8b9c 100644
--- a/src/components/RMoreDropdown/src/index.tsx
+++ b/src/components/RMoreDropdown/src/index.tsx
@@ -13,20 +13,20 @@ import { NDropdown } from 'naive-ui'
import RIcon from '@/components/RIcon/index'
import props from './props'
+import { renderNode } from '@use-utils/vue/index'
export default defineComponent({
name: 'RMoreDropdown',
props,
render() {
const { iconSize, cursor } = this
+ const { default: $default } = this.$slots
return (
-
- {this.$slots.default ? (
- this.$slots.default()
- ) : (
-
- )}
+
+ {renderNode($default, {
+ defaultElement: ,
+ })}
)
},
diff --git a/src/components/RQRCode/src/props.ts b/src/components/RQRCode/src/props.ts
index 7fc97324..2bf05073 100644
--- a/src/components/RQRCode/src/props.ts
+++ b/src/components/RQRCode/src/props.ts
@@ -27,7 +27,7 @@ const props = {
watchText: {
/**
*
- * Atuo watch QR code text
+ * Auto watch QR code text
* If update text, then re-render QR code
*
* @default true
diff --git a/src/components/RTable/src/Table.tsx b/src/components/RTable/src/Table.tsx
index 3f5523f9..6d619ab2 100644
--- a/src/components/RTable/src/Table.tsx
+++ b/src/components/RTable/src/Table.tsx
@@ -13,7 +13,7 @@ import './index.scss'
import { NCard, NDataTable, NDropdown, NSpace } from 'naive-ui'
import Size from './components/Size'
-import Screenfull from './components/Fullscreen'
+import Fullscreen from './components/Fullscreen'
import C from './components/C'
import Print from './components/Print'
@@ -118,7 +118,7 @@ export default defineComponent({
<>
-
+
>
)
diff --git a/src/directives/index.ts b/src/directives/index.ts
index e419739f..0d7580d4 100644
--- a/src/directives/index.ts
+++ b/src/directives/index.ts
@@ -37,12 +37,17 @@ export const setupDirectives = (app: App) => {
const regexDirectiveName = /^([^-]+-)*[^-]+$/
forIn(directivesModules, (value, key) => {
- const dname = key.match(regexExtractDirectiveName)?.[0]
+ const directiveBindName = key.match(regexExtractDirectiveName)?.[0]
- if (typeof dname === 'string' && regexDirectiveName.test(dname)) {
- app.directive(dname, value())
+ if (
+ typeof directiveBindName === 'string' &&
+ regexDirectiveName.test(directiveBindName)
+ ) {
+ app.directive(directiveBindName, value())
} else {
- console.error(`[setupDirectives] ${dname} is not a valid directive name`)
+ console.error(
+ `[setupDirectives] ${directiveBindName} is not a valid directive name`,
+ )
}
})
}
diff --git a/src/global-variable/README.md b/src/global-variable/README.md
new file mode 100644
index 00000000..6c18809a
--- /dev/null
+++ b/src/global-variable/README.md
@@ -0,0 +1,30 @@
+## global-variable
+
+简单的管理全局响应式变量,但是不支持缓存。
+
+创建该模块是因为在有时候不需要 `pinia` 这么复杂流程的全局变量。所以该模块管理的都是一些简单的全局变量,并且不支持缓存。
+
+## 添加全局变量
+
+1. 首先在 `variableState` 变量中添加对应变量
+2. 调用对应方法获取、更新变量
+
+```ts
+// 添加变量
+const variableState = reactive({
+ globalSpinning: false,
+ globalDrawerValue: false,
+ yourGlobalValue: 'demo value',
+})
+
+// 更新变量
+setVariable(key, value)
+
+// 获取非响应式变量
+const yourGlobalValue = getVariable('yourGlobalValue') // Readonly
+
+// 获取响应式变量
+const yourGlobalValue = getVariableToRefs('yourGlobalValue') // Readonly[>
+```
+
+> 注意,避免滥用该模块。可能会导致管理不当引起内存泄漏。
diff --git a/src/global-variable/index.ts b/src/global-variable/index.ts
new file mode 100644
index 00000000..44df445d
--- /dev/null
+++ b/src/global-variable/index.ts
@@ -0,0 +1,18 @@
+/**
+ *
+ * @author Ray
+ *
+ * @date 2023-09-11
+ *
+ * @workspace ray-template
+ *
+ * @remark 今天也是元气满满撸代码的一天
+ */
+
+import { setVariable, getVariable, getVariableToRefs } from './variable'
+
+import type { VariableState, VariableStateKey } from './variable'
+
+export { setVariable, getVariable, getVariableToRefs }
+
+export type { VariableState, VariableStateKey }
diff --git a/src/global-variable/variable.ts b/src/global-variable/variable.ts
new file mode 100644
index 00000000..35ce02c6
--- /dev/null
+++ b/src/global-variable/variable.ts
@@ -0,0 +1,62 @@
+/**
+ *
+ * @author Ray
+ *
+ * @date 2023-09-11
+ *
+ * @workspace ray-template
+ *
+ * @remark 今天也是元气满满撸代码的一天
+ */
+
+/**
+ *
+ * 存放全局临时变量,脱离 pinia 使用的变量
+ * 简单的全局变量,并不需要复杂的控制流程
+ *
+ * 使用方法
+ * @example
+ *
+ * 获取普通变量
+ * getVariable('target key', 'default value')
+ *
+ * 获取响应式变量
+ * getVariableToRefs('target key')
+ *
+ * 更改 state 变量
+ * setVariable('key', 'value')
+ */
+
+import type { AnyFC } from '@/types/modules/utils'
+
+const variableState = reactive({
+ globalSpinning: false,
+ globalDrawerValue: false,
+})
+
+export type VariableState = typeof variableState
+
+export type VariableStateKey = keyof VariableState
+
+export function setVariable(
+ key: T,
+ value: VariableState[T],
+ cb?: AnyFC,
+) {
+ variableState[key] = value
+
+ cb?.()
+}
+
+export function getVariable(
+ key: VariableStateKey,
+ defaultValue?: VariableState[T],
+) {
+ const v = variableState[key]
+
+ return v ? readonly(variableState)[key] : defaultValue
+}
+
+export function getVariableToRefs(key: K) {
+ return readonly(toRef(variableState, key))
+}
diff --git a/src/hooks/variable/index.ts b/src/hooks/variable/index.ts
deleted file mode 100644
index 191dd170..00000000
--- a/src/hooks/variable/index.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- *
- * @author Ray
- *
- * @date 2023-09-11
- *
- * @workspace ray-template
- *
- * @remark 今天也是元气满满撸代码的一天
- */
-
-import {
- setVariable,
- getVariable,
- globalVariableToRefs,
-} from './useGlobalVariable'
-
-export { setVariable, getVariable, globalVariableToRefs }
diff --git a/src/hooks/variable/useGlobalVariable.ts b/src/hooks/variable/useGlobalVariable.ts
deleted file mode 100644
index 9bf20e75..00000000
--- a/src/hooks/variable/useGlobalVariable.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- * @author Ray
- *
- * @date 2023-09-11
- *
- * @workspace ray-template
- *
- * @remark 今天也是元气满满撸代码的一天
- */
-
-/**
- *
- * 存放全局临时变量,脱离 pinia 使用的变量
- * 简单的全局变量,并不需要复杂的控制流程
- *
- * 但不建议滥用
- */
-
-/** 全局响应式变量 */
-const variableState = reactive({
- globalSpinning: false,
- globalDrawerValue: 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(key: K) {
- return readonly(toRef(variableState, key))
-}
diff --git a/src/hooks/web/useDayjs.ts b/src/hooks/web/useDayjs.ts
index e014c776..d719a3da 100644
--- a/src/hooks/web/useDayjs.ts
+++ b/src/hooks/web/useDayjs.ts
@@ -23,9 +23,9 @@ import type { DayjsLocal } from '@/dayjs/type'
*/
export const useDayjs = () => {
const locale = (key: DayjsLocal) => {
- const mapkey = DAYJS_LOCAL_MAP[key]
+ const locale = DAYJS_LOCAL_MAP[key]
- mapkey ? dayjs.locale(mapkey) : dayjs.locale(DEFAULT_DAYJS_LOCAL)
+ locale ? dayjs.locale(locale) : dayjs.locale(DEFAULT_DAYJS_LOCAL)
}
return {
diff --git a/src/icons/empty.svg b/src/icons/empty.svg
new file mode 100644
index 00000000..54db9edc
--- /dev/null
+++ b/src/icons/empty.svg
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/src/layout/components/Menu/index.tsx b/src/layout/components/Menu/index.tsx
index e5a62906..ed25c9d6 100644
--- a/src/layout/components/Menu/index.tsx
+++ b/src/layout/components/Menu/index.tsx
@@ -17,7 +17,7 @@ import SiderBarLogo from './components/SiderBarLogo/index'
import { useMenu } from '@/store'
import { APP_MENU_CONFIG } from '@/app-config/appConfig'
import { useDevice } from '@/hooks/web/index'
-import { globalVariableToRefs, setVariable } from '@/hooks/variable/index'
+import { getVariableToRefs, setVariable } from '@/global-variable/index'
import type { MenuInst } from 'naive-ui'
import type { NaiveMenuOptions } from '@/types/modules/component'
@@ -49,7 +49,7 @@ export default defineComponent({
const modelCollapsed = computed(() => menuStore.collapsed)
const { isTabletOrSmaller } = useDevice()
const modelGlobalDrawerValue = computed({
- get: () => globalVariableToRefs('globalDrawerValue').value,
+ get: () => getVariableToRefs('globalDrawerValue').value,
set: (val) => {
setVariable('globalDrawerValue', val)
},
@@ -63,7 +63,7 @@ export default defineComponent({
})
}
- const BaseicMenu = () => (
+ const BasicMenu = () => (
+
) : (
)
},
diff --git a/src/layout/components/MenuTag/index.scss b/src/layout/components/MenuTag/index.scss
index f74e1a8a..1d7db2cc 100644
--- a/src/layout/components/MenuTag/index.scss
+++ b/src/layout/components/MenuTag/index.scss
@@ -8,7 +8,7 @@ $menuTagWrapperWidth: 76px;
align-items: center;
padding: 4px 0;
- & .menu-tag-sapce {
+ & .menu-tag-space {
width: calc(100% - $space * 2);
padding: $space;
diff --git a/src/layout/components/MenuTag/index.tsx b/src/layout/components/MenuTag/index.tsx
index 90deb2d2..71c3172c 100644
--- a/src/layout/components/MenuTag/index.tsx
+++ b/src/layout/components/MenuTag/index.tsx
@@ -35,6 +35,7 @@ import { hasClass } from '@/utils/element'
import { redirectRouterToDashboard } from '@/router/helper/routerCopilot'
import { ROOT_ROUTE } from '@/app-config/appConfig'
import { queryElements } from '@use-utils/element'
+import { renderNode } from '@/utils/vue/index'
import type { MenuOption, ScrollbarInst } from 'naive-ui'
import type { MenuTagOptions, AppMenuOption } from '@/types/modules/app'
@@ -58,7 +59,10 @@ export default defineComponent({
const { path } = ROOT_ROUTE
const exclude = ['closeAll', 'closeRight', 'closeLeft', 'closeOther']
- let currentContentmenuIndex = -1 // 当前右键标签页索引位置
+ let currentContextmenuIndex = -1 // 当前右键标签页索引位置
+ const iconConfig = {
+ size: 16,
+ }
const modelMenuTagOptions = computed(() =>
menuTagOptions.value.map((curr, _idx, currentArray) => {
if (curr.key === menuKey.value && curr.key !== path) {
@@ -86,7 +90,7 @@ export default defineComponent({
h(
RIcon,
{
- size: 16,
+ size: iconConfig.size,
name: 'reload',
},
{},
@@ -99,7 +103,7 @@ export default defineComponent({
h(
RIcon,
{
- size: 16,
+ size: iconConfig.size,
name: 'other',
},
{},
@@ -112,7 +116,7 @@ export default defineComponent({
h(
RIcon,
{
- size: 16,
+ size: iconConfig.size,
name: 'right_arrow',
},
{},
@@ -125,7 +129,7 @@ export default defineComponent({
h(
RIcon,
{
- size: 16,
+ size: iconConfig.size,
name: 'left_arrow',
},
{},
@@ -142,7 +146,7 @@ export default defineComponent({
h(
RIcon,
{
- size: 16,
+ size: iconConfig.size,
name: 'close',
},
{},
@@ -176,16 +180,16 @@ export default defineComponent({
* 如果当前选择标签与 menuKey 不匹配, 则会关闭当前标签右侧所有变迁并且跳转至该页面
*/
const length = moreOptions.value.length
- const routeItem = modelMenuTagOptions.value[currentContentmenuIndex]
+ const routeItem = modelMenuTagOptions.value[currentContextmenuIndex]
- spliceMenTagOptions(currentContentmenuIndex + 1, length - 1)
+ spliceMenTagOptions(currentContextmenuIndex + 1, length - 1)
if (menuKey.value !== routeItem.key) {
changeMenuModelValue(routeItem.key, routeItem)
}
},
closeLeft: () => {
- spliceMenTagOptions(0, currentContentmenuIndex)
+ spliceMenTagOptions(0, currentContextmenuIndex)
},
closeOther: () => {
/**
@@ -194,7 +198,7 @@ export default defineComponent({
*
* 如果关闭标签与当前 menuKey 不匹配, 则会关闭当前选择标签页以外的所有标签页并且跳转至该页面
*/
- const routeItem = modelMenuTagOptions.value[currentContentmenuIndex]
+ const routeItem = modelMenuTagOptions.value[currentContextmenuIndex]
if (menuKey.value !== routeItem.key) {
emptyMenuTagOptions()
@@ -306,7 +310,7 @@ export default defineComponent({
e.preventDefault()
actionState.actionDropdownShow = false
- currentContentmenuIndex = idx
+ currentContextmenuIndex = idx
nextTick().then(() => {
actionState.actionDropdownShow = true
@@ -318,31 +322,31 @@ export default defineComponent({
const setDisabledAccordionToIndex = () => {
const length = modelMenuTagOptions.value.length - 1
- if (currentContentmenuIndex === length) {
+ if (currentContextmenuIndex === length) {
setMoreOptionsDisabled('closeRight', true)
- } else if (currentContentmenuIndex < length) {
+ } else if (currentContextmenuIndex < length) {
setMoreOptionsDisabled('closeRight', false)
}
- if (currentContentmenuIndex === 0) {
+ if (currentContextmenuIndex === 0) {
setMoreOptionsDisabled('closeLeft', true)
- } else if (currentContentmenuIndex > 0) {
+ } else if (currentContextmenuIndex > 0) {
setMoreOptionsDisabled('closeLeft', false)
}
}
/**
*
- * 如果通过更多按钮触发关闭事件, 则根据当前标签所在索引值为 currentContentmenuIndex
+ * 如果通过更多按钮触发关闭事件, 则根据当前标签所在索引值为 currentContextmenuIndex
*
* 并且动态设置是否可操作状态
*/
- const setCurrentContentmenuIndex = () => {
+ const setCurrentContextmenuIndex = () => {
const index = modelMenuTagOptions.value.findIndex(
(curr) => curr.key === menuKey.value,
)
- currentContentmenuIndex = index
+ currentContextmenuIndex = index
setDisabledAccordionToIndex()
}
@@ -445,13 +449,18 @@ export default defineComponent({
rootPath: path,
actionState,
handleContextMenu,
- setCurrentContentmenuIndex,
+ setCurrentContextmenuIndex,
menuTagMouseenter,
menuTagMouseleave,
MENU_TAG_DATA,
}
},
render() {
+ const iconConfig = {
+ width: 20,
+ height: 28,
+ }
+
return (
]