mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-05 19:42:07 +08:00
v4.4.1
This commit is contained in:
parent
429e51fc30
commit
9e3cbac091
22
CHANGELOG.md
22
CHANGELOG.md
@ -1,5 +1,27 @@
|
||||
# CHANGE LOG
|
||||
|
||||
## 4.4.1
|
||||
|
||||
更新 `vite` 版本至 `5.0.4`。同步修复了一些小问题。
|
||||
|
||||
基础性能优化,根据开发模式与构建模式拆分插件启用。避免某些仅仅需要在构建模式的插件在开发模式下也被启用。
|
||||
|
||||
新增预构建插件列表。
|
||||
|
||||
### Feats
|
||||
|
||||
- 补充 components 包组件的 `props` 类型导出
|
||||
- 补充 `__DEV__` 全局变量
|
||||
- 优化 `precision` 包中的基本运算方法,并且将小数点默认保留 `8` 位
|
||||
- 新增 `isCurrency` 方法检测是否为 `currency.js` 对象
|
||||
- 按照构建模式与开发模式拆分插件启用
|
||||
- 新增预构建列表
|
||||
|
||||
## Fixes
|
||||
|
||||
- 修复 `i18n fallbackLocale` 错误配置为 `SYSTEM_DEFAULT_LOCAL` 的问题
|
||||
- 修复 `SYSTEM_DEFAULT_LOCAL` 类型定义错误问题
|
||||
|
||||
## 4.4.0
|
||||
|
||||
补充了几个组件。并且更改了组件的导入、导出方式,由从前很恶心的一个个导入,变为 `import { RIcon } from '@/components'`。
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ray-template",
|
||||
"private": false,
|
||||
"version": "4.4.0",
|
||||
"version": "4.4.1",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": "^18.0.0 || >=20.0.0",
|
||||
@ -83,7 +83,7 @@
|
||||
"typescript": "^5.2.2",
|
||||
"unplugin-auto-import": "^0.16.6",
|
||||
"unplugin-vue-components": "^0.25.2",
|
||||
"vite": "^5.0.2",
|
||||
"vite": "^5.0.4",
|
||||
"vite-plugin-cdn2": "0.15.2",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-ejs": "^1.7.0",
|
||||
|
62
pnpm-lock.yaml
generated
62
pnpm-lock.yaml
generated
@ -102,10 +102,10 @@ devDependencies:
|
||||
version: 6.5.0(eslint@8.52.0)(typescript@5.2.2)
|
||||
'@vitejs/plugin-vue':
|
||||
specifier: ^4.4.1
|
||||
version: 4.4.1(vite@5.0.2)(vue@3.3.8)
|
||||
version: 4.4.1(vite@5.0.4)(vue@3.3.8)
|
||||
'@vitejs/plugin-vue-jsx':
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2(vite@5.0.2)(vue@3.3.8)
|
||||
version: 3.0.2(vite@5.0.4)(vue@3.3.8)
|
||||
'@vue-hooks-plus/resolvers':
|
||||
specifier: 1.2.4
|
||||
version: 1.2.4(vue-hooks-plus@1.8.5)
|
||||
@ -179,32 +179,32 @@ devDependencies:
|
||||
specifier: ^0.25.2
|
||||
version: 0.25.2(vue@3.3.8)
|
||||
vite:
|
||||
specifier: ^5.0.2
|
||||
version: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
specifier: ^5.0.4
|
||||
version: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite-plugin-cdn2:
|
||||
specifier: 0.15.2
|
||||
version: 0.15.2
|
||||
vite-plugin-compression:
|
||||
specifier: ^0.5.1
|
||||
version: 0.5.1(vite@5.0.2)
|
||||
version: 0.5.1(vite@5.0.4)
|
||||
vite-plugin-ejs:
|
||||
specifier: ^1.7.0
|
||||
version: 1.7.0(vite@5.0.2)
|
||||
version: 1.7.0(vite@5.0.4)
|
||||
vite-plugin-eslint:
|
||||
specifier: 1.8.1
|
||||
version: 1.8.1(eslint@8.52.0)(vite@5.0.2)
|
||||
version: 1.8.1(eslint@8.52.0)(vite@5.0.4)
|
||||
vite-plugin-imp:
|
||||
specifier: ^2.4.0
|
||||
version: 2.4.0(vite@5.0.2)
|
||||
version: 2.4.0(vite@5.0.4)
|
||||
vite-plugin-inspect:
|
||||
specifier: ^0.7.38
|
||||
version: 0.7.38(vite@5.0.2)
|
||||
version: 0.7.38(vite@5.0.4)
|
||||
vite-plugin-mock-dev-server:
|
||||
specifier: 1.3.4
|
||||
version: 1.3.4(vite@5.0.2)
|
||||
version: 1.3.4(vite@5.0.4)
|
||||
vite-plugin-svg-icons:
|
||||
specifier: ^2.0.1
|
||||
version: 2.0.1(vite@5.0.2)
|
||||
version: 2.0.1(vite@5.0.4)
|
||||
vite-svg-loader:
|
||||
specifier: ^4.0.0
|
||||
version: 4.0.0
|
||||
@ -1932,7 +1932,7 @@ packages:
|
||||
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
|
||||
dev: true
|
||||
|
||||
/@vitejs/plugin-vue-jsx@3.0.2(vite@5.0.2)(vue@3.3.8):
|
||||
/@vitejs/plugin-vue-jsx@3.0.2(vite@5.0.4)(vue@3.3.8):
|
||||
resolution: {integrity: sha512-obF26P2Z4Ogy3cPp07B4VaW6rpiu0ue4OT2Y15UxT5BZZ76haUY9guOsZV3uWh/I6xc+VeiW+ZVabRE82FyzWw==}
|
||||
engines: {node: ^14.18.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
@ -1942,20 +1942,20 @@ packages:
|
||||
'@babel/core': 7.23.2
|
||||
'@babel/plugin-transform-typescript': 7.22.15(@babel/core@7.23.2)
|
||||
'@vue/babel-plugin-jsx': 1.1.5(@babel/core@7.23.2)
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
vue: 3.3.8(typescript@5.2.2)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@vitejs/plugin-vue@4.4.1(vite@5.0.2)(vue@3.3.8):
|
||||
/@vitejs/plugin-vue@4.4.1(vite@5.0.4)(vue@3.3.8):
|
||||
resolution: {integrity: sha512-HCQG8VDFDM7YDAdcj5QI5DvUi+r6xvo9LgvYdk7LSkUNwdpempdB5horkMSZsbdey9Ywsf5aaU8kEPw9M5kREA==}
|
||||
engines: {node: ^14.18.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
vite: ^4.0.0
|
||||
vue: ^3.2.25
|
||||
dependencies:
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
vue: 3.3.8(typescript@5.2.2)
|
||||
dev: true
|
||||
|
||||
@ -7530,7 +7530,7 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/vite-plugin-compression@0.5.1(vite@5.0.2):
|
||||
/vite-plugin-compression@0.5.1(vite@5.0.4):
|
||||
resolution: {integrity: sha512-5QJKBDc+gNYVqL/skgFAP81Yuzo9R+EAf19d+EtsMF/i8kFUpNi3J/H01QD3Oo8zBQn+NzoCIFkpPLynoOzaJg==}
|
||||
peerDependencies:
|
||||
vite: '>=2.0.0'
|
||||
@ -7538,21 +7538,21 @@ packages:
|
||||
chalk: 4.1.2
|
||||
debug: 4.3.4
|
||||
fs-extra: 10.1.0
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/vite-plugin-ejs@1.7.0(vite@5.0.2):
|
||||
/vite-plugin-ejs@1.7.0(vite@5.0.4):
|
||||
resolution: {integrity: sha512-JNP3zQDC4mSbfoJ3G73s5mmZITD8NGjUmLkq4swxyahy/W0xuokK9U9IJGXw7KCggq6UucT6hJ0p+tQrNtqTZw==}
|
||||
peerDependencies:
|
||||
vite: '>=5.0.0'
|
||||
dependencies:
|
||||
ejs: 3.1.9
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
dev: true
|
||||
|
||||
/vite-plugin-eslint@1.8.1(eslint@8.52.0)(vite@5.0.2):
|
||||
/vite-plugin-eslint@1.8.1(eslint@8.52.0)(vite@5.0.4):
|
||||
resolution: {integrity: sha512-PqdMf3Y2fLO9FsNPmMX+//2BF5SF8nEWspZdgl4kSt7UvHDRHVVfHvxsD7ULYzZrJDGRxR81Nq7TOFgwMnUang==}
|
||||
peerDependencies:
|
||||
eslint: '>=7'
|
||||
@ -7562,10 +7562,10 @@ packages:
|
||||
'@types/eslint': 8.44.2
|
||||
eslint: 8.52.0
|
||||
rollup: 2.79.1
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
dev: true
|
||||
|
||||
/vite-plugin-imp@2.4.0(vite@5.0.2):
|
||||
/vite-plugin-imp@2.4.0(vite@5.0.4):
|
||||
resolution: {integrity: sha512-L/6/nvOw+MyNh4UxAlCZHsmKd5MitmHamqqAWB15sbUgVIEz/OQ8jpKr6kkQU0eA/AIe8fkCVbQBlP81ajrqWg==}
|
||||
peerDependencies:
|
||||
vite: '>= 2.0.0-beta.5'
|
||||
@ -7577,12 +7577,12 @@ packages:
|
||||
chalk: 4.1.2
|
||||
param-case: 3.0.4
|
||||
pascal-case: 3.1.2
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/vite-plugin-inspect@0.7.38(vite@5.0.2):
|
||||
/vite-plugin-inspect@0.7.38(vite@5.0.4):
|
||||
resolution: {integrity: sha512-+p6pJVtBOLGv+RBrcKAFUdx+euizg0bjL35HhPyM0MjtKlqoC5V9xkCmO9Ctc8JrTyXqODbHqiLWJKumu5zJ7g==}
|
||||
engines: {node: '>=14'}
|
||||
peerDependencies:
|
||||
@ -7600,13 +7600,13 @@ packages:
|
||||
open: 9.1.0
|
||||
picocolors: 1.0.0
|
||||
sirv: 2.0.3
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
transitivePeerDependencies:
|
||||
- rollup
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/vite-plugin-mock-dev-server@1.3.4(vite@5.0.2):
|
||||
/vite-plugin-mock-dev-server@1.3.4(vite@5.0.4):
|
||||
resolution: {integrity: sha512-50biXarRPdKYxR/q9an4vHMh2cbwFlEWHfLJdXg6gpS63CMMrCo9XQWYIkdytZNSEs/5AwykGB5Xo0ORMMttgQ==}
|
||||
engines: {node: ^14.18.0 || >=16}
|
||||
peerDependencies:
|
||||
@ -7627,7 +7627,7 @@ packages:
|
||||
mime-types: 2.1.35
|
||||
path-to-regexp: 6.2.1
|
||||
picocolors: 1.0.0
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
ws: 8.13.0
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
@ -7635,7 +7635,7 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: true
|
||||
|
||||
/vite-plugin-svg-icons@2.0.1(vite@5.0.2):
|
||||
/vite-plugin-svg-icons@2.0.1(vite@5.0.4):
|
||||
resolution: {integrity: sha512-6ktD+DhV6Rz3VtedYvBKKVA2eXF+sAQVaKkKLDSqGUfnhqXl3bj5PPkVTl3VexfTuZy66PmINi8Q6eFnVfRUmA==}
|
||||
peerDependencies:
|
||||
vite: '>=2.0.0'
|
||||
@ -7648,7 +7648,7 @@ packages:
|
||||
pathe: 0.2.0
|
||||
svg-baker: 1.7.0
|
||||
svgo: 2.8.0
|
||||
vite: 5.0.2(@types/node@20.4.7)(sass@1.69.5)
|
||||
vite: 5.0.4(@types/node@20.4.7)(sass@1.69.5)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
@ -7660,8 +7660,8 @@ packages:
|
||||
svgo: 3.0.2
|
||||
dev: true
|
||||
|
||||
/vite@5.0.2(@types/node@20.4.7)(sass@1.69.5):
|
||||
resolution: {integrity: sha512-6CCq1CAJCNM1ya2ZZA7+jS2KgnhbzvxakmlIjN24cF/PXhRMzpM/z8QgsVJA/Dm5fWUWnVEsmtBoMhmerPxT0g==}
|
||||
/vite@5.0.4(@types/node@20.4.7)(sass@1.69.5):
|
||||
resolution: {integrity: sha512-RzAr8LSvM8lmhB4tQ5OPcBhpjOZRZjuxv9zO5UcxeoY2bd3kP3Ticd40Qma9/BqZ8JS96Ll/jeBX9u+LJZrhVg==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
|
@ -50,7 +50,7 @@ export const SYSTEM_DEFAULT_LOCAL: TemplateLocale<LocalOptions> = 'zh-CN'
|
||||
*
|
||||
* 配置时应该与 LOCAL_OPTIONS 的 key 一致
|
||||
*/
|
||||
export const SYSTEM_FALLBACK_LOCALE = 'zh-CN'
|
||||
export const SYSTEM_FALLBACK_LOCALE: TemplateLocale<LocalOptions> = 'zh-CN'
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1,8 +1,11 @@
|
||||
import RChart from './src'
|
||||
import chartProps from './src/props'
|
||||
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
import type * as RChartType from './src/type'
|
||||
|
||||
export type ChartProps = ExtractPublicPropTypes<typeof chartProps>
|
||||
export type { RChartType }
|
||||
|
||||
export { RChart, chartProps }
|
||||
|
@ -2,7 +2,9 @@ import RCollapseGrid from './src'
|
||||
import collapseGridProps from './src/props'
|
||||
|
||||
import type * as RCollapseGridType from './src/type'
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type CollapseGridProps = ExtractPublicPropTypes<typeof collapseGridProps>
|
||||
export type { RCollapseGridType }
|
||||
|
||||
export { RCollapseGrid, collapseGridProps }
|
||||
|
@ -1,4 +1,8 @@
|
||||
import RIcon from './src'
|
||||
import iconProps from './src/props'
|
||||
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type IconProps = ExtractPublicPropTypes<typeof iconProps>
|
||||
|
||||
export { RIcon, iconProps }
|
||||
|
@ -2,7 +2,9 @@ import RIframe from './src'
|
||||
import iframeProps from './src/props'
|
||||
|
||||
import type * as RIframeType from './src/type'
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type IframeProps = ExtractPublicPropTypes<typeof iframeProps>
|
||||
export type { RIframeType }
|
||||
|
||||
export { RIframe, iframeProps }
|
||||
|
@ -1,4 +1,8 @@
|
||||
import RModal from './src/Modal'
|
||||
import modalProps from './src/props'
|
||||
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type ModalProps = ExtractPublicPropTypes<typeof modalProps>
|
||||
|
||||
export { RModal, modalProps }
|
||||
|
@ -1,4 +1,8 @@
|
||||
import RMoreDropdown from './src'
|
||||
import moreDropdownProps from './src/props'
|
||||
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type MoreDropdownProps = ExtractPublicPropTypes<typeof moreDropdownProps>
|
||||
|
||||
export { RMoreDropdown, moreDropdownProps }
|
||||
|
@ -2,7 +2,9 @@ import RQRCode from './src'
|
||||
import qrcodeProps from './src/props'
|
||||
|
||||
import type * as RQRCodeType from './src/type'
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type QRCodeProps = ExtractPublicPropTypes<typeof qrcodeProps>
|
||||
export type { RQRCodeType }
|
||||
|
||||
export { RQRCode, qrcodeProps }
|
||||
|
@ -2,7 +2,9 @@ import RTable from './src/Table'
|
||||
import tableProps from './src/props'
|
||||
|
||||
import type * as RTableType from './src/type'
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type TableProps = ExtractPublicPropTypes<typeof tableProps>
|
||||
export type { RTableType }
|
||||
|
||||
export { RTable, tableProps }
|
||||
|
@ -2,7 +2,11 @@ import RTransitionComponent from './src/index.vue'
|
||||
import transitionComponentProps from './src/props'
|
||||
|
||||
import type * as RTransitionComponentType from './src/type'
|
||||
import type { ExtractPublicPropTypes } from 'vue'
|
||||
|
||||
export type TransitionComponentProps = ExtractPublicPropTypes<
|
||||
typeof transitionComponentProps
|
||||
>
|
||||
export type { RTransitionComponentType }
|
||||
|
||||
export { RTransitionComponent, transitionComponentProps }
|
||||
|
@ -16,9 +16,11 @@ export function useAppSetting() {
|
||||
*
|
||||
* @param theme 当前主题色
|
||||
*
|
||||
* 当前主题仅有明暗两套
|
||||
* - true: 暗色
|
||||
* - false: 亮色
|
||||
* 当前主题有明暗两套
|
||||
*
|
||||
* @example
|
||||
* changeTheme(true) 切换至暗色主题
|
||||
* changeTheme(false) 切换至明色主题
|
||||
*/
|
||||
const changeTheme = (theme: boolean) => {
|
||||
const { changeSwitcher } = useSettingActions()
|
||||
|
@ -11,12 +11,75 @@
|
||||
|
||||
import { useMenuGetters, useMenuActions } from '@/store'
|
||||
import { redirectRouterToDashboard } from '@/router/helper/routerCopilot'
|
||||
import { useRootRoute } from '@/hooks/template'
|
||||
|
||||
import type { MenuTagOptions, Key } from '@/types/modules/app'
|
||||
|
||||
export type CloseMenuTag = Key | MenuTagOptions
|
||||
|
||||
/**
|
||||
*
|
||||
* @param target 标签页对象、索引、key
|
||||
* @param fc 触发函数
|
||||
*
|
||||
* 该方法用于统一获取目标标签页方法
|
||||
*/
|
||||
const normalMenuTagOption = (target: CloseMenuTag, fc: string) => {
|
||||
const { getMenuTagOptions } = useMenuGetters()
|
||||
|
||||
if (typeof target === 'number') {
|
||||
// 判断是否为 NaN
|
||||
if (isNaN(target)) {
|
||||
console.warn(`${fc}: The ${target} is NaN, expect number.`)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是否超出当前标签页列表最大长度或者是否为负数
|
||||
if (target > getMenuTagOptions.value.length || target < -1) {
|
||||
console.warn(
|
||||
`${fc}: The incoming index ${target} did not match the corresponding item.`,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return {
|
||||
option: getMenuTagOptions.value[target],
|
||||
index: target,
|
||||
}
|
||||
} else if (typeof target === 'string') {
|
||||
// 查找符合条件的 key
|
||||
const index = getMenuTagOptions.value.findIndex(
|
||||
(curr) => curr.key === target,
|
||||
)
|
||||
|
||||
return index > -1
|
||||
? {
|
||||
option: getMenuTagOptions.value[index],
|
||||
index,
|
||||
}
|
||||
: console.warn(
|
||||
`${fc}: The incoming key ${target} did not match the corresponding item.`,
|
||||
)
|
||||
} else {
|
||||
const { key } = target
|
||||
const index = getMenuTagOptions.value.findIndex((curr) => curr.key === key)
|
||||
|
||||
if (index === -1) {
|
||||
console.warn(
|
||||
`${fc}: The incoming menuTag option ${target.key} did not match the corresponding item.`,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return {
|
||||
option: target,
|
||||
index,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function useMenuTag() {
|
||||
const { getMenuTagOptions, getMenuKey } = useMenuGetters()
|
||||
const {
|
||||
@ -25,71 +88,6 @@ export function useMenuTag() {
|
||||
emptyMenuTagOptions,
|
||||
setMenuTagOptions,
|
||||
} = useMenuActions()
|
||||
const { getRootPath } = useRootRoute()
|
||||
|
||||
/**
|
||||
*
|
||||
* @param target 标签页对象、索引、key
|
||||
* @param fc 触发函数
|
||||
*
|
||||
* 该方法用于统一获取目标标签页方法
|
||||
*/
|
||||
const normalMenuTagOption = (target: CloseMenuTag, fc: string) => {
|
||||
if (typeof target === 'number') {
|
||||
// 判断是否为 NaN
|
||||
if (isNaN(target)) {
|
||||
console.warn(`${fc}: The ${target} is NaN, expect number.`)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是否超出当前标签页列表最大长度或者是否为负数
|
||||
if (target > getMenuTagOptions.value.length || target < -1) {
|
||||
console.warn(
|
||||
`${fc}: The incoming index ${target} did not match the corresponding item.`,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return {
|
||||
option: getMenuTagOptions.value[target],
|
||||
index: target,
|
||||
}
|
||||
} else if (typeof target === 'string') {
|
||||
// 查找符合条件的 key
|
||||
const index = getMenuTagOptions.value.findIndex(
|
||||
(curr) => curr.key === target,
|
||||
)
|
||||
|
||||
return index > -1
|
||||
? {
|
||||
option: getMenuTagOptions.value[index],
|
||||
index,
|
||||
}
|
||||
: console.warn(
|
||||
`${fc}: The incoming key ${target} did not match the corresponding item.`,
|
||||
)
|
||||
} else {
|
||||
const { key } = target
|
||||
const index = getMenuTagOptions.value.findIndex(
|
||||
(curr) => curr.key === key,
|
||||
)
|
||||
|
||||
if (index === -1) {
|
||||
console.warn(
|
||||
`${fc}: The incoming menuTag option ${target.key} did not match the corresponding item.`,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return {
|
||||
option: target,
|
||||
index,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -26,7 +26,7 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { LOCAL_OPTIONS } from '@/app-config/localConfig'
|
||||
import { getAppDefaultLanguage, getAppLocalMessages } from '@/locales/helper'
|
||||
import { SYSTEM_DEFAULT_LOCAL } from '@/app-config/localConfig'
|
||||
import { SYSTEM_FALLBACK_LOCALE } from '@/app-config/localConfig'
|
||||
|
||||
import type { App } from 'vue'
|
||||
import type { I18n, I18nOptions } from 'vue-i18n'
|
||||
@ -49,7 +49,7 @@ const createI18nOptions = async () => {
|
||||
sync: true,
|
||||
missingWarn: false,
|
||||
silentFallbackWarn: true,
|
||||
fallbackLocale: SYSTEM_DEFAULT_LOCAL,
|
||||
fallbackLocale: SYSTEM_FALLBACK_LOCALE,
|
||||
})
|
||||
|
||||
return i18nInstance
|
||||
|
@ -18,39 +18,21 @@
|
||||
*
|
||||
* 官网地址: https://prazdevs.github.io/pinia-plugin-persistedstate/zh/guide/
|
||||
*/
|
||||
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||
|
||||
// 该仓库导出,更多是为了 hooks 包中,在模板中尽量不直接操作 store 仓库
|
||||
import { piniaSettingStore } from './modules/setting'
|
||||
import { piniaMenuStore } from './modules/menu'
|
||||
import { piniaSigningStore } from './modules/signing'
|
||||
import { piniaKeepAliveStore } from './modules/keep-alive'
|
||||
|
||||
// 导出 getters, actions
|
||||
import { useMenuGetters, useMenuActions } from './hooks/useMenuStore'
|
||||
import { useSettingGetters, useSettingActions } from './hooks/useSettingStore'
|
||||
import { useSigningGetters, useSigningActions } from './hooks/useSigningStore'
|
||||
import {
|
||||
useKeepAliveGetters,
|
||||
useKeepAliveActions,
|
||||
} from './hooks/useKeepAliveStore'
|
||||
|
||||
import type { App } from 'vue'
|
||||
|
||||
export {
|
||||
piniaSettingStore,
|
||||
piniaMenuStore,
|
||||
piniaSigningStore,
|
||||
piniaKeepAliveStore,
|
||||
useMenuGetters,
|
||||
useMenuActions,
|
||||
useSettingGetters,
|
||||
useSettingActions,
|
||||
useSigningGetters,
|
||||
useSigningActions,
|
||||
useKeepAliveGetters,
|
||||
useKeepAliveActions,
|
||||
}
|
||||
// 该仓库导出,更多是为了 hooks 包中,在模板中尽量不直接操作 store 仓库
|
||||
export * from './modules/setting'
|
||||
export * from './modules/menu'
|
||||
export * from './modules/signing'
|
||||
export * from './modules/keep-alive'
|
||||
// 导出 getters, actions
|
||||
export * from './hooks/useMenuStore'
|
||||
export * from './hooks/useSettingStore'
|
||||
export * from './hooks/useSigningStore'
|
||||
export * from './hooks/useKeepAliveStore'
|
||||
|
||||
/**
|
||||
*
|
||||
|
2
src/types/global.d.ts
vendored
2
src/types/global.d.ts
vendored
@ -12,6 +12,8 @@ export declare global {
|
||||
[propName: string]: any
|
||||
}
|
||||
|
||||
declare const __DEV__: boolean
|
||||
|
||||
declare const __APP_CFG__: AppConfig
|
||||
|
||||
declare interface Window {
|
||||
|
@ -13,6 +13,11 @@ import type { BasicTarget, TargetValue } from '@/types/modules/vue'
|
||||
*
|
||||
* 获取当前项目环境
|
||||
*
|
||||
* 如果你只是想单纯的判断是否为开发环境,可以直接使用: __DEV__
|
||||
*
|
||||
* @example
|
||||
* 是否为开发环境: __DEV__
|
||||
*
|
||||
* @example
|
||||
* const { BASE_URL } = getAppEnvironment() 获取 BASE_URL
|
||||
* const { MODE } = getAppEnvironment() 获取 MODE,当前环境
|
||||
|
@ -21,7 +21,6 @@
|
||||
* - pattern default: `!#`(!: 货币符号代替, #: 货币金额代替)
|
||||
* - negativePattern default: `!#`(!: 货币符号代替, #: 货币金额代替)
|
||||
* - format default: `null`(默认格式化方法替代, 看文档)
|
||||
* - fromCents default: `false`
|
||||
* - fromCents default: `false`(尊重精度选项)
|
||||
* - errorOnInvalid default: `false`(传入 null undefined 直接抛出错误)
|
||||
* - increment default: `null`(四舍五入增量值)
|
||||
@ -30,6 +29,7 @@
|
||||
|
||||
import currency from 'currency.js'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { isValueType } from '@/utils/basic'
|
||||
|
||||
import type { Options } from 'currency.js'
|
||||
import type { AnyFC } from '@/types/modules/utils'
|
||||
@ -38,6 +38,29 @@ export type CurrencyArguments = string | number | currency
|
||||
|
||||
export type OriginalValueType = 'string' | 'number'
|
||||
|
||||
// currency.js 默认配置
|
||||
const defaultOptions: Partial<Options> = {
|
||||
precision: 8,
|
||||
decimal: '.',
|
||||
}
|
||||
// currency.js 原型属性集合
|
||||
const currencyPrototypeKeys = [
|
||||
's',
|
||||
'intValue',
|
||||
'p',
|
||||
'value',
|
||||
'toJSON',
|
||||
'add',
|
||||
'cents',
|
||||
'distribute',
|
||||
'divide',
|
||||
'dollars',
|
||||
'format',
|
||||
'multiply',
|
||||
'subtract',
|
||||
'toString',
|
||||
]
|
||||
|
||||
/**
|
||||
*
|
||||
* @param valueOptions 待计算参数列表
|
||||
@ -56,7 +79,7 @@ const basic = (
|
||||
}
|
||||
|
||||
if (valueOptions.length === 1) {
|
||||
return currency(valueOptions[0])
|
||||
return currency(valueOptions[0], defaultOptions)
|
||||
}
|
||||
|
||||
const result = valueOptions.reduce((pre, curr, idx, arr) => {
|
||||
@ -68,6 +91,31 @@ const basic = (
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value 待判断值
|
||||
*
|
||||
* 检查一个对象是否为 currency.js 的对象
|
||||
* 当该对象含有 s, intValue, p, value... 属性时, 则认为该对象为 currency.js 的对象
|
||||
*
|
||||
* @example
|
||||
* isCurrency(1.23) => false
|
||||
* isCurrency('1.23') => false
|
||||
* isCurrency({ s: 1, intValue: 1, p: 1, value: 1 }) => false
|
||||
* isCurrency(currency(1)) => true
|
||||
*/
|
||||
export const isCurrency = (value: unknown) => {
|
||||
if (typeof value === 'string' || typeof value === 'number') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (isValueType<object>(value, 'Object')) {
|
||||
return currencyPrototypeKeys.every((key) => Reflect.has(value, key))
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 格式化一个数据值, 并且返回其原始值
|
||||
@ -80,9 +128,10 @@ export const format = (
|
||||
options?: Options,
|
||||
type: OriginalValueType = 'number',
|
||||
) => {
|
||||
return type === 'number'
|
||||
? currency(value, options).value
|
||||
: currency(value, options).toString()
|
||||
const assignOptions = Object.assign({}, defaultOptions, options)
|
||||
const v = currency(value, assignOptions)
|
||||
|
||||
return type === 'number' ? v.value : v.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,8 +143,12 @@ export const format = (
|
||||
* format(add(0.2, 0.33)) => 0.53
|
||||
*/
|
||||
export const add = (...args: CurrencyArguments[]) => {
|
||||
if (args.length === 1) {
|
||||
return currency(args[0], defaultOptions).add(0)
|
||||
}
|
||||
|
||||
return basic(args, 0, (pre, curr) => {
|
||||
return currency(pre).add(curr)
|
||||
return currency(pre, defaultOptions).add(curr)
|
||||
})
|
||||
}
|
||||
|
||||
@ -108,10 +161,14 @@ export const add = (...args: CurrencyArguments[]) => {
|
||||
* format(subtract(0.2, 0.33)) => -0.13
|
||||
*/
|
||||
export const subtract = (...args: CurrencyArguments[]) => {
|
||||
if (args.length === 1) {
|
||||
return currency(args[0], defaultOptions).subtract(0)
|
||||
}
|
||||
|
||||
if (args.length === 2) {
|
||||
const [one, two] = args
|
||||
|
||||
return currency(one).subtract(two)
|
||||
return currency(one, defaultOptions).subtract(two)
|
||||
}
|
||||
|
||||
const cloneDeepArgs = cloneDeep(args)
|
||||
@ -122,7 +179,7 @@ export const subtract = (...args: CurrencyArguments[]) => {
|
||||
}
|
||||
|
||||
return basic(cloneDeepArgs, dividend, (pre, curr) => {
|
||||
return currency(pre).subtract(curr)
|
||||
return currency(pre, defaultOptions).subtract(curr)
|
||||
})
|
||||
}
|
||||
|
||||
@ -135,8 +192,12 @@ export const subtract = (...args: CurrencyArguments[]) => {
|
||||
* format(multiply(0.2, 0.33)) => 0.07
|
||||
*/
|
||||
export const multiply = (...args: CurrencyArguments[]) => {
|
||||
if (args.length === 1) {
|
||||
return currency(args[0], defaultOptions).multiply(1)
|
||||
}
|
||||
|
||||
return basic(args, 1, (pre, curr) => {
|
||||
return currency(pre).multiply(curr)
|
||||
return currency(pre, defaultOptions).multiply(curr)
|
||||
})
|
||||
}
|
||||
|
||||
@ -149,21 +210,21 @@ export const multiply = (...args: CurrencyArguments[]) => {
|
||||
* format(divide(0.2, 0.33)) => 0.61
|
||||
*/
|
||||
export const divide = (...args: CurrencyArguments[]) => {
|
||||
if (args.length === 1) {
|
||||
return currency(args[0], defaultOptions).divide(1)
|
||||
}
|
||||
|
||||
if (args.length === 2) {
|
||||
const [one, two] = args
|
||||
|
||||
return currency(one).divide(two)
|
||||
return currency(one, defaultOptions).divide(two)
|
||||
}
|
||||
|
||||
const cloneDeepArgs = cloneDeep(args)
|
||||
const dividend = cloneDeepArgs.shift() as CurrencyArguments
|
||||
|
||||
if (!cloneDeepArgs.length) {
|
||||
return dividend
|
||||
}
|
||||
|
||||
return basic(cloneDeepArgs, dividend, (pre, curr) => {
|
||||
return currency(pre).divide(curr)
|
||||
return currency(pre, defaultOptions).divide(curr)
|
||||
})
|
||||
}
|
||||
|
||||
@ -176,11 +237,7 @@ export const divide = (...args: CurrencyArguments[]) => {
|
||||
* distribute(0, 1) => [0]
|
||||
* distribute(0, 3) => [0, 0, 0]
|
||||
*/
|
||||
export const distribute = (
|
||||
value: CurrencyArguments,
|
||||
length: number,
|
||||
options?: Options,
|
||||
) => {
|
||||
export const distribute = (value: CurrencyArguments, length: number) => {
|
||||
if (length <= 1) {
|
||||
return [value ? value : 0]
|
||||
} else {
|
||||
@ -189,10 +246,10 @@ export const distribute = (
|
||||
}
|
||||
}
|
||||
|
||||
const result = currency(value, options)
|
||||
const result = currency(value, defaultOptions)
|
||||
.distribute(length)
|
||||
.map((curr) => {
|
||||
return format(curr, options)
|
||||
return format(curr)
|
||||
})
|
||||
|
||||
return result
|
||||
|
@ -39,7 +39,7 @@ const CalculatePrecision = defineComponent({
|
||||
divideOptions: divide,
|
||||
}
|
||||
|
||||
const copilotFunc = (value: string[], path: string) => {
|
||||
const copilotFunc = (value: string[], path: keyof typeof actionMap) => {
|
||||
const action = actionMap[path]
|
||||
const result = action(...value)
|
||||
|
||||
@ -66,13 +66,14 @@ const CalculatePrecision = defineComponent({
|
||||
return (
|
||||
<NLayout>
|
||||
<h2 style="margin: 0 0 20px 0">
|
||||
计算方法,默认都保留两位小数与四舍五入,可以根据 format 方法自行转换
|
||||
计算方法,默认都保留八位小数与四舍五入,可以根据 format 方法自行转换
|
||||
</h2>
|
||||
<h3 style="margin: 0 0 20px 0">
|
||||
示例方法都基于 currency.js
|
||||
封装,利用其精度处理能力封装了常用的一些计算方法,解决精度问题。如果需要其他的方法请阅读官方文档
|
||||
https://currency.js.org/#subtract
|
||||
</h3>
|
||||
|
||||
<NSpace vertical>
|
||||
<NCard title="加法">
|
||||
{{
|
||||
|
@ -50,7 +50,7 @@ export default defineComponent({
|
||||
参数为正整数时,会更具当前的菜单顺序进行自动导航匹配。但是此方法仅能导航一级菜单。并且如果导航菜单非根菜单项,会自动递归导航至一子菜单。
|
||||
</h3>
|
||||
<br />
|
||||
<NButton onClick={() => navigationTo(14)}>跳转至多级菜单</NButton>
|
||||
<NButton onClick={() => navigationTo(15)}>跳转至多级菜单</NButton>
|
||||
</NCard>
|
||||
<NCard title="useMainPage 主页面方法">
|
||||
<NCard title="reload 加载函数">
|
||||
|
@ -31,13 +31,35 @@ export default defineConfig(async ({ mode }) => {
|
||||
base: base || '/',
|
||||
define: {
|
||||
__APP_CFG__: JSON.stringify(__APP_CFG__),
|
||||
__DEV__: mode === 'development',
|
||||
},
|
||||
resolve: {
|
||||
alias: alias,
|
||||
},
|
||||
plugins: vitePlugins(mode),
|
||||
optimizeDeps: {
|
||||
include: ['vue', 'vue-router', 'pinia', 'vue-i18n', '@vueuse/core'],
|
||||
include: [
|
||||
'vue',
|
||||
'vue-router',
|
||||
'pinia',
|
||||
'vue-i18n',
|
||||
'naive-ui',
|
||||
'@vueuse/core',
|
||||
'vue-demi',
|
||||
'dayjs',
|
||||
'echarts',
|
||||
'xlsx',
|
||||
'axios',
|
||||
'print-js',
|
||||
'clipboard',
|
||||
'lodash-es',
|
||||
'vue-hooks-plus',
|
||||
'interactjs',
|
||||
'awesome-qr',
|
||||
'pinia-plugin-persistedstate',
|
||||
'currency.js',
|
||||
'mockjs',
|
||||
],
|
||||
},
|
||||
esbuild: {
|
||||
pure: ['console.log'],
|
||||
|
@ -33,7 +33,44 @@ import config from './cfg'
|
||||
|
||||
import type { PluginOption } from 'vite'
|
||||
|
||||
export default function (mode: string): PluginOption[] {
|
||||
// 仅适用于构建模式(任何构建模式:preview、build、report...)
|
||||
function onlyBuildOptions(mode: string) {
|
||||
return [
|
||||
visualizer({
|
||||
gzipSize: true, // 搜集 `gzip` 压缩包
|
||||
brotliSize: true, // 搜集 `brotli` 压缩包
|
||||
emitFile: false, // 生成文件在根目录下
|
||||
filename: 'visualizer.html',
|
||||
open: mode === 'report' ? true : false, // 以默认服务器代理打开文件
|
||||
}),
|
||||
viteCDNPlugin({
|
||||
// modules 顺序 vue, vue-demi 必须保持当前顺序加载,否则会出现加载错误问题
|
||||
modules: [
|
||||
'vue',
|
||||
'vue-demi',
|
||||
'pinia',
|
||||
'naive-ui',
|
||||
'vue-router',
|
||||
'vue-i18n',
|
||||
'dayjs',
|
||||
'echarts',
|
||||
'xlsx',
|
||||
'axios',
|
||||
'print-js',
|
||||
'clipboard',
|
||||
'lodash-es',
|
||||
],
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
// 仅适用于开发模式
|
||||
function onlyDevOptions(mode: string) {
|
||||
return []
|
||||
}
|
||||
|
||||
// 基础插件配置
|
||||
function baseOptions(mode: string) {
|
||||
const { title, appPrimaryColor, preloadingConfig } = config
|
||||
|
||||
return [
|
||||
@ -111,23 +148,6 @@ export default function (mode: string): PluginOption[] {
|
||||
},
|
||||
],
|
||||
}),
|
||||
{
|
||||
include: [
|
||||
'src/**/*.ts',
|
||||
'src/**/*.tsx',
|
||||
'src/**/*.vue',
|
||||
'src/*.ts',
|
||||
'src/*.tsx',
|
||||
'src/*.vue',
|
||||
],
|
||||
},
|
||||
visualizer({
|
||||
gzipSize: true, // 搜集 `gzip` 压缩包
|
||||
brotliSize: true, // 搜集 `brotli` 压缩包
|
||||
emitFile: false, // 生成文件在根目录下
|
||||
filename: 'visualizer.html',
|
||||
open: mode === 'report' ? true : false, // 以默认服务器代理打开文件
|
||||
}),
|
||||
viteEjsPlugin({
|
||||
preloadingConfig,
|
||||
appPrimaryColor,
|
||||
@ -154,23 +174,12 @@ export default function (mode: string): PluginOption[] {
|
||||
inject: 'body-last',
|
||||
customDomId: '__svg__icons__dom__',
|
||||
}),
|
||||
viteCDNPlugin({
|
||||
// modules 顺序 vue, vue-demi 必须保持当前顺序加载,否则会出现加载错误问题
|
||||
modules: [
|
||||
'vue',
|
||||
'vue-demi',
|
||||
'pinia',
|
||||
'naive-ui',
|
||||
'vue-router',
|
||||
'vue-i18n',
|
||||
'dayjs',
|
||||
'echarts',
|
||||
'xlsx',
|
||||
'axios',
|
||||
'print-js',
|
||||
'clipboard',
|
||||
'lodash-es',
|
||||
],
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
export default function (mode: string): PluginOption[] {
|
||||
const plugins =
|
||||
mode === 'development' ? onlyDevOptions(mode) : onlyBuildOptions(mode)
|
||||
|
||||
return [...baseOptions(mode), ...plugins]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user