version: v5.2.3

This commit is contained in:
XiaoDaiGua-Ray 2025-10-26 21:16:27 +08:00
parent 49af61a339
commit bebd3d53bd
15 changed files with 1155 additions and 853 deletions

View File

@ -28,6 +28,7 @@
"commitmsg", "commitmsg",
"crossorigin", "crossorigin",
"datetimerange", "datetimerange",
"depcheckrc",
"domtoimage", "domtoimage",
"EDITMSG", "EDITMSG",
"iife", "iife",

View File

@ -1,3 +1,21 @@
## 5.2.3
## Feats
- 更新依赖为主流版本
- `RTablePro` 组件相关
- 新增 `takeoverAutoHeight` 配置项,允许接管表格的流体高度渲染,一旦启用该属性,`flexAutoHeight` 属性将强制启用
- 新增 `collapse` 插槽,配合 `takeoverAutoHeight` 配置项使用,允许自定义表格常见的顶部操作区域,当然也可以做点其他的,但是该插槽仅在启用 `takeoverAutoHeight` 配置项时生效
> 该属性可以让流体高度功能使用更加优雅,有点用处。
- 新增暴露 `setPage`, `setPageSize`, `getPage`, `getPageSize` 方法
- `naive-ui` 最新版本有依赖问题,暂时回退升级
- `echarts` 更新至 `6.0.0` 版本,并且完成适配
## Fixes
- 修复 `usePagination.resetPagination` 方法在重置分页时,没有正确触发 `pageChange`, `pageSizeChange` 回调函数的问题
- 修复 `resetTablePagination` 方法在重置分页时,没有正确触发 `onTablePaginationUpdate` 回调函数的问题
## 5.2.2 ## 5.2.2
## Feats ## Feats

View File

@ -1,7 +1,7 @@
{ {
"name": "ray-template", "name": "ray-template",
"private": false, "private": false,
"version": "5.2.2", "version": "5.2.3",
"type": "module", "type": "module",
"engines": { "engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0", "node": "^18.0.0 || ^20.0.0 || >=22.0.0",
@ -36,12 +36,12 @@
"@logicflow/core": "2.0.10", "@logicflow/core": "2.0.10",
"@logicflow/extension": "2.0.14", "@logicflow/extension": "2.0.14",
"@vueuse/core": "^13.1.0", "@vueuse/core": "^13.1.0",
"axios": "^1.9.0", "axios": "^1.10.0",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"crypto-js": "4.2.0", "crypto-js": "4.2.0",
"currency.js": "^2.0.4", "currency.js": "^2.0.4",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"echarts": "^5.6.0", "echarts": "^6.0.0",
"html-to-image": "1.11.13", "html-to-image": "1.11.13",
"interactjs": "1.10.27", "interactjs": "1.10.27",
"jsbarcode": "3.11.6", "jsbarcode": "3.11.6",
@ -51,44 +51,45 @@
"pinia": "^3.0.3", "pinia": "^3.0.3",
"pinia-plugin-persistedstate": "^4.4.1", "pinia-plugin-persistedstate": "^4.4.1",
"print-js": "^1.6.0", "print-js": "^1.6.0",
"vue": "^3.5.17", "vue": "^3.5.22",
"vue-demi": "0.14.10", "vue-demi": "0.14.10",
"vue-hooks-plus": "2.4.0", "vue-hooks-plus": "2.4.1",
"vue-i18n": "^9.13.1", "vue-i18n": "^9.13.1",
"vue-router": "^4.5.1", "vue-router": "^4.6.3",
"vue3-next-qrcode": "3.0.2" "vue3-next-qrcode": "3.0.2"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "19.7.1", "@commitlint/cli": "19.7.1",
"@commitlint/config-conventional": "19.7.1", "@commitlint/config-conventional": "19.7.1",
"@eslint/js": "9.28.0", "@eslint/eslintrc": "3.3.1",
"@eslint/js": "9.30.1",
"@interactjs/types": "1.10.27", "@interactjs/types": "1.10.27",
"@intlify/unplugin-vue-i18n": "4.0.0", "@intlify/unplugin-vue-i18n": "4.0.0",
"@types/crypto-js": "4.2.2", "@types/crypto-js": "4.2.2",
"@types/jsbarcode": "3.11.4", "@types/jsbarcode": "3.11.4",
"@types/lodash-es": "4.17.12", "@types/lodash-es": "4.17.12",
"@types/mockjs": "1.0.10", "@types/mockjs": "1.0.10",
"@typescript-eslint/eslint-plugin": "8.24.0", "@typescript-eslint/eslint-plugin": "8.36.0",
"@typescript-eslint/parser": "8.24.0", "@typescript-eslint/parser": "8.36.0",
"@vitejs/plugin-vue": "5.2.3", "@vitejs/plugin-vue": "6.0.1",
"@vitejs/plugin-vue-jsx": "4.1.2", "@vitejs/plugin-vue-jsx": "5.1.1",
"@vitest/ui": "2.1.8", "@vitest/ui": "3.0.5",
"@vue/eslint-config-prettier": "10.1.0", "@vue/eslint-config-prettier": "10.1.0",
"@vue/eslint-config-typescript": "14.2.0", "@vue/eslint-config-typescript": "14.2.0",
"@vue/test-utils": "2.4.6", "@vue/test-utils": "2.4.6",
"autoprefixer": "10.4.21", "autoprefixer": "10.4.21",
"depcheck": "1.4.7", "depcheck": "1.4.7",
"eslint": "9.20.1", "eslint": "9.31.0",
"eslint-config-prettier": "10.1.2", "eslint-config-prettier": "10.1.5",
"eslint-plugin-prettier": "5.2.6", "eslint-plugin-prettier": "5.5.1",
"eslint-plugin-vue": "9.32.0", "eslint-plugin-vue": "9.32.0",
"globals": "16.0.0", "globals": "16.3.0",
"happy-dom": "17.1.0", "happy-dom": "17.1.0",
"husky": "8.0.3", "husky": "8.0.3",
"lint-staged": "15.4.3", "lint-staged": "15.4.3",
"postcss": "8.5.4", "postcss": "8.5.6",
"postcss-px-to-viewport-8-with-include": "1.2.2", "postcss-px-to-viewport-8-with-include": "1.2.2",
"prettier": "3.5.3", "prettier": "3.6.2",
"rollup-plugin-gzip": "4.0.1", "rollup-plugin-gzip": "4.0.1",
"sass": "1.86.3", "sass": "1.86.3",
"svg-sprite-loader": "6.0.11", "svg-sprite-loader": "6.0.11",
@ -101,7 +102,7 @@
"vite-plugin-cdn2": "1.1.0", "vite-plugin-cdn2": "1.1.0",
"vite-plugin-ejs": "1.7.0", "vite-plugin-ejs": "1.7.0",
"vite-plugin-eslint": "1.8.1", "vite-plugin-eslint": "1.8.1",
"vite-plugin-inspect": "0.8.4", "vite-plugin-inspect": "0.10.6",
"vite-plugin-mock-dev-server": "1.8.3", "vite-plugin-mock-dev-server": "1.8.3",
"vite-plugin-svg-icons": "2.0.1", "vite-plugin-svg-icons": "2.0.1",
"vite-svg-loader": "5.1.0", "vite-svg-loader": "5.1.0",

1553
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -51,13 +51,13 @@ export const APP_THEME: AppTheme = {
dark: { dark: {
common: { common: {
borderRadius: '4px', borderRadius: '4px',
baseColor: 'rgb(18, 18, 18)', baseColor: 'rgba(18, 18, 18, 1)',
}, },
}, },
light: { light: {
common: { common: {
borderRadius: '4px', borderRadius: '4px',
baseColor: 'rgb(255, 255, 255)', baseColor: 'rgba(255, 255, 255, 1)',
}, },
}, },
}, },

View File

@ -19,7 +19,7 @@ import {
ScatterChart, ScatterChart,
PictorialBarChart, PictorialBarChart,
} from 'echarts/charts' // 系列类型(后缀都为 SeriesOption) } from 'echarts/charts' // 系列类型(后缀都为 SeriesOption)
import { LabelLayout, UniversalTransition } from 'echarts/features' // 标签自动布局, 全局过渡动画等特性 import { LegacyGridContainLabel, UniversalTransition } from 'echarts/features' // 标签自动布局, 全局过渡动画等特性
import { CanvasRenderer } from 'echarts/renderers' // echarts 渲染器 import { CanvasRenderer } from 'echarts/renderers' // echarts 渲染器
import { NCard } from 'naive-ui' import { NCard } from 'naive-ui'
@ -154,7 +154,7 @@ export default defineComponent({
ScatterChart, ScatterChart,
PictorialBarChart, PictorialBarChart,
]) // 注册 chart series type ]) // 注册 chart series type
use([LabelLayout, UniversalTransition]) // 注册布局, 过度效果 use([LegacyGridContainLabel, UniversalTransition]) // 注册布局, 过度效果
use([CanvasRenderer]) // 注册渲染器 use([CanvasRenderer]) // 注册渲染器
try { try {

View File

@ -1,4 +1,5 @@
import { RTable } from '../../../base/RTable' import { RTable } from '../../../base/RTable'
import { NFlex } from 'naive-ui'
import props from './props' import props from './props'
import useTable from '../../../base/RTable/src/hooks/useTable' import useTable from '../../../base/RTable/src/hooks/useTable'
@ -24,6 +25,8 @@ export default defineComponent({
setItemCount, setItemCount,
resetPagination, resetPagination,
getItemCount, getItemCount,
setPage,
setPageSize,
}, },
] = usePagination(void 0, { ] = usePagination(void 0, {
prefix: props.paginationPrefix, prefix: props.paginationPrefix,
@ -146,6 +149,10 @@ export default defineComponent({
runAsyncTableRequest: runResetPaginationRequestAsync, runAsyncTableRequest: runResetPaginationRequestAsync,
getCurrentTableRequestParams: combineRequestParams, getCurrentTableRequestParams: combineRequestParams,
resetTablePagination: resetPagination, resetTablePagination: resetPagination,
setPage,
setPageSize,
getPage,
getPageSize,
}) })
} }
}) })
@ -158,16 +165,44 @@ export default defineComponent({
}, },
render() { render() {
const { register, $props, paginationRef, $slots } = this const { register, $props, paginationRef, $slots } = this
const { onRegister, showPagination, ...rest } = $props const {
onRegister,
showPagination,
takeoverAutoHeight,
flexAutoHeight,
...rest
} = $props
const baseProps = {
onRegister: register,
pagination: showPagination ? paginationRef : void 0,
}
const { collapse, ...restSlots } = $slots
return ( if (takeoverAutoHeight) {
<RTable return (
{...rest} <NFlex vertical class="flex-vertical">
onRegister={register} {{
pagination={showPagination ? paginationRef : void 0} default: () => (
> <>
{$slots} {collapse?.()}
</RTable> <RTable {...baseProps} {...rest} flexAutoHeight>
) {{
...restSlots,
}}
</RTable>
</>
),
}}
</NFlex>
)
} else {
return (
<RTable {...baseProps} {...rest} flexAutoHeight={flexAutoHeight}>
{{
...restSlots,
}}
</RTable>
)
}
}, },
}) })

View File

@ -218,6 +218,40 @@ export const useTablePro = () => {
*/ */
const getTableProConfig = () => getTableProInstance().config const getTableProConfig = () => getTableProInstance().config
/**
*
* @description
*
*/
const getPage = () => getTableProInstance().getPage.call(null)
/**
*
* @description
/**
*
* @description
*
*/
const getPageSize = () => getTableProInstance().getPageSize.call(null)
/**
*
* @description
*
*/
const setPage = (page: number) =>
getTableProInstance().setPage.call(null, page)
/**
*
* @description
*
*/
const setPageSize = (pageSize: number) =>
getTableProInstance().setPageSize.call(null, pageSize)
return [ return [
register, register,
{ {
@ -236,6 +270,10 @@ export const useTablePro = () => {
resetTablePagination, resetTablePagination,
runAsyncTableRequest, runAsyncTableRequest,
getTableProConfig, getTableProConfig,
getPage,
getPageSize,
setPage,
setPageSize,
}, },
] as const ] as const
} }

View File

@ -118,6 +118,20 @@ const props = {
default: (info: Parameters<NonNullable<PaginationPrefix>>[0]) => default: (info: Parameters<NonNullable<PaginationPrefix>>[0]) =>
`${info.itemCount}`, `${info.itemCount}`,
}, },
/**
*
* @description
*
* flexAutoHeight true使 flexAutoHeight
*
* flexAutoHeight
*
* @default false
*/
takeoverAutoHeight: {
type: Boolean,
default: false,
},
} }
export default props export default props

View File

@ -159,6 +159,54 @@ export interface TableProInst extends Omit<RTableInst, 'getTableInstance'> {
* resetTablePagination() * resetTablePagination()
*/ */
resetTablePagination: () => void resetTablePagination: () => void
/**
*
* @description
*
*
* @example
* const [register, { setPage }] = useTablePro()
*
* // 设置表格分页页码为 2
* setPage(2)
*/
setPage: (page: number) => void
/**
*
* @description
*
*
* @example
* const [register, { setPageSize }] = useTablePro()
*
* // 设置表格分页每页条数为 20
* setPageSize(20)
*/
setPageSize: (pageSize: number) => void
/**
*
* @description
*
*
* @example
* const [register, { getPage }] = useTablePro()
*
* // 获取表格分页页码
* const page = getPage()
*/
getPage: () => number
/**
*
* @description
*
*
* @example
* const [register, { getPageSize }] = useTablePro()
*
* // 获取表格分页每页条数
* const pageSize = getPageSize()
*/
getPageSize: () => number
} }
export interface TableProFieldNames { export interface TableProFieldNames {
@ -166,18 +214,24 @@ export interface TableProFieldNames {
* *
* @description * @description
* *
*
* @default 'page'
*/ */
page: string page: string
/** /**
* *
* @description * @description
* *
*
* @default 'pageSize'
*/ */
pageSize: string pageSize: string
/** /**
* *
* @description * @description
* *
*
* @default 'itemCount'
*/ */
itemCount: string itemCount: string
} }

View File

@ -196,11 +196,16 @@ export const usePagination = <T extends AnyFC>(
* pageSizes 10 * pageSizes 10
*/ */
const resetPagination = () => { const resetPagination = () => {
const { pageSizes } = paginationRef.value const { pageSizes, pageChange, pageSizeChange } = mergedOptions.value
paginationRef.value.page = DEFAULT_OPTIONS.page paginationRef.value.page = DEFAULT_OPTIONS.page
paginationRef.value.pageSize = paginationRef.value.pageSize =
(pageSizes?.[0] as number) || DEFAULT_OPTIONS.pageSize (pageSizes?.[0] as number) || DEFAULT_OPTIONS.pageSize
callbackRef.value?.()
pageChange?.(paginationRef.value.page!)
pageSizeChange?.(paginationRef.value.pageSize!)
} }
effectDispose(() => { effectDispose(() => {

View File

@ -11,6 +11,7 @@ import type {
} from 'naive-ui' } from 'naive-ui'
import type { NativeElements, ReservedProps, VNode } from 'vue' import type { NativeElements, ReservedProps, VNode } from 'vue'
import type { Recordable } from './modules/helper' import type { Recordable } from './modules/helper'
import type { ECharts, EChartsCoreOption } from 'echarts/core'
export declare global { export declare global {
declare interface UnknownObjectKey { declare interface UnknownObjectKey {
@ -75,4 +76,8 @@ export declare global {
declare interface GlobalDataTableColumns<T> extends DataTableColumns<T> {} declare interface GlobalDataTableColumns<T> extends DataTableColumns<T> {}
declare type GlobalRecordable<T> = Recordable<T> declare type GlobalRecordable<T> = Recordable<T>
declare type GlobalECharts = ECharts
declare type GlobalEChartsCoreOption = EChartsCoreOption
} }

View File

@ -29,7 +29,7 @@ const Echart = defineComponent({
loading1: false, loading1: false,
}) })
const baseOptions = { const baseOptions: GlobalEChartsCoreOption = {
legend: {}, legend: {},
tooltip: {}, tooltip: {},
xAxis: { xAxis: {
@ -60,7 +60,7 @@ const Echart = defineComponent({
}, },
], ],
} }
const basePieOptions = { const basePieOptions: GlobalEChartsCoreOption = {
title: { title: {
text: 'Referer of a Website', text: 'Referer of a Website',
subtext: 'Fake Data', subtext: 'Fake Data',
@ -124,10 +124,13 @@ const Echart = defineComponent({
data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'], data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'],
}, },
grid: { grid: {
left: '3%', left: '4%',
right: '4%', right: '4%',
bottom: '3%', top: '2%',
containLabel: true, outerBounds: {
bottom: '10%',
},
outerBoundsMode: 'auto',
}, },
xAxis: [ xAxis: [
{ {

View File

@ -123,101 +123,95 @@ export default defineComponent({
const { mockPersonList, baseColumns, switchRef } = this const { mockPersonList, baseColumns, switchRef } = this
return ( return (
<NFlex vertical class="flex-vertical"> <RTablePro
<RCollapse bordered> takeoverAutoHeight
{{ data={mockPersonList}
default: () => ( v-model:columns={baseColumns}
<> showPagination
<NFormItemGi label="用户名"> paginationCount={mockPersonList.length}
<NInput clearable /> remote={false}
</NFormItemGi> title={
<NFormItemGi label="状态"> <NFlex>
<NSelect <NFlex align="center">
clearable <NButton text focusable={false}>
options={[
{ </NButton>
label: '成功', <NSwitch v-model:value={switchRef.footer} />
value: 'success',
},
{
label: '失败',
value: 'error',
},
]}
/>
</NFormItemGi>
<NFormItemGi label="登陆时间">
<NDatePicker type="datetimerange" clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
</>
),
action: () => (
<NFlex>
<NButton type="primary"></NButton>
</NFlex>
),
}}
</RCollapse>
<RTablePro
data={mockPersonList}
v-model:columns={baseColumns}
showPagination
paginationCount={mockPersonList.length}
remote={false}
flexAutoHeight={switchRef.flexAutoHeight}
title={
<NFlex>
<NFlex align="center">
<NButton text focusable={false}>
</NButton>
<NSwitch v-model:value={switchRef.flexAutoHeight} />
</NFlex>
<NFlex align="center">
<NButton text focusable={false}>
</NButton>
<NSwitch v-model:value={switchRef.footer} />
</NFlex>
<NFlex align="center">
<NButton text focusable={false}>
</NButton>
<NSwitch v-model:value={switchRef.action} />
</NFlex>
</NFlex> </NFlex>
} <NFlex align="center">
> <NButton text focusable={false}>
{{
tableFooter: () => </NButton>
switchRef.footer <NSwitch v-model:value={switchRef.action} />
? '表格的底部内容区域插槽,有时候你可能会用上' </NFlex>
: null, </NFlex>
tableAction: () => }
switchRef.action >
? '表格的操作区域内容插槽,有时候可能会用上' {{
: null, collapse: () => (
}} <RCollapse bordered open={false}>
</RTablePro> {{
</NFlex> default: () => (
<>
<NFormItemGi label="用户名">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="状态">
<NSelect
clearable
options={[
{
label: '成功',
value: 'success',
},
{
label: '失败',
value: 'error',
},
]}
/>
</NFormItemGi>
<NFormItemGi label="登陆时间">
<NDatePicker type="datetimerange" clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
<NFormItemGi label="演示折叠的条件框">
<NInput clearable />
</NFormItemGi>
</>
),
action: () => (
<NFlex>
<NButton type="primary"></NButton>
</NFlex>
),
}}
</RCollapse>
),
tableFooter: () =>
switchRef.footer
? '表格的底部内容区域插槽,有时候你可能会用上'
: null,
tableAction: () =>
switchRef.action
? '表格的操作区域内容插槽,有时候可能会用上'
: null,
}}
</RTablePro>
) )
}, },
}) })

View File

@ -119,6 +119,9 @@ export default defineComponent({
print, print,
downloadCsv, downloadCsv,
runAsyncTableRequest, runAsyncTableRequest,
setPage,
setPageSize,
resetTablePagination,
}, },
] = useTablePro() ] = useTablePro()
// 表格数据 // 表格数据
@ -306,6 +309,9 @@ export default defineComponent({
selectKey, selectKey,
register, register,
reset, reset,
setPage,
setPageSize,
resetTablePagination,
} }
}, },
render() { render() {
@ -329,10 +335,13 @@ export default defineComponent({
selectKey, selectKey,
register, register,
reset, reset,
setPage,
setPageSize,
resetTablePagination,
} = this } = this
return ( return (
<NFlex vertical> <NFlex vertical class="h-full">
<RCollapse open={this.collapseRef} onRegister={register}> <RCollapse open={this.collapseRef} onRegister={register}>
{{ {{
default: () => ( default: () => (
@ -422,6 +431,15 @@ export default defineComponent({
<NButton type="primary" onClick={() => downloadCsv()}> <NButton type="primary" onClick={() => downloadCsv()}>
csv csv
</NButton> </NButton>
<NButton type="primary" onClick={() => setPage(2)}>
2
</NButton>
<NButton type="primary" onClick={() => setPageSize(20)}>
20
</NButton>
<NButton type="primary" onClick={() => resetTablePagination()}>
</NButton>
</NFlex> </NFlex>
</NCard> </NCard>
<NCard title="useCheckedRowKeys 部分方法"> <NCard title="useCheckedRowKeys 部分方法">
@ -465,6 +483,7 @@ export default defineComponent({
</NFlex> </NFlex>
</NCard> </NCard>
<RTablePro <RTablePro
takeoverAutoHeight
onRegister={tableProRegister} onRegister={tableProRegister}
data={tableDataRef} data={tableDataRef}
v-model:columns={this.baseColumns} v-model:columns={this.baseColumns}