diff --git a/.eslintrc.cjs b/.eslintrc.cjs index c21a8d82..7aeaa58d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -5,6 +5,7 @@ module.exports = { browser: true, node: true, }, + ignorePatterns: ['node_modules/', 'dist/'], extends: [ 'eslint-config-prettier', 'eslint:recommended', diff --git a/package.json b/package.json index 250bcd34..4376e173 100644 --- a/package.json +++ b/package.json @@ -5,17 +5,17 @@ "type": "module", "scripts": { "dev": "vite", - "build": "eslint src && vue-tsc --noEmit && vite build --mode production", + "build": "eslint src && eslint --fix . && vue-tsc --noEmit && vite build --mode production", "preview": "vite preview", - "test": "eslint src && vue-tsc --noEmit && vite build --mode test", - "dev-build": "eslint src && vue-tsc --noEmit && vite build --mode development", - "report": "eslint src && vue-tsc --noEmit && vite build --mode report", + "test": "eslint src && eslint --fix . && vue-tsc --noEmit && vite build --mode test", + "dev-build": "eslint src && eslint --fix . && vue-tsc --noEmit && vite build --mode development", + "report": "eslint src && eslint --fix . && vue-tsc --noEmit && vite build --mode report", "prepare": "husky install" }, "lint-staged": { "src/**/*.{vue,jsx,ts,tsx,json}": [ "prettier --write", - "eslint", + "eslint src", "git add" ] }, @@ -73,7 +73,7 @@ "husky": "^8.0.3", "lint-staged": "^13.1.0", "postcss": "^8.1.0", - "postcss-px-to-viewport": "^1.1.1", + "postcss-px-to-viewport-update": "1.2.0", "prettier": "^2.7.1", "rollup-plugin-visualizer": "^5.8.3", "svg-sprite-loader": "^6.0.11", diff --git a/postcss.config.cjs b/postcss.config.cjs index 320ef306..67c71ae0 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -11,7 +11,9 @@ module.exports = { ], grid: true, }, - // 'postcss-px-to-viewport': { + // 由于该库的作者很久没更新了,导致 exclude include 并没有生效,所以使用的是其一个 fork 版本 + // 'postcss-px-to-viewport-update': { + // inlinePxToViewport: true, // /** 视窗的宽度(设计稿的宽度) */ // viewportWidth: 1920, // /** 视窗的高度(设计稿高度, 一般无需指定) */ @@ -26,6 +28,8 @@ module.exports = { // minPixelValue: 1, // /** 允许在媒体查询中转换 px */ // mediaQuery: false, + // exclude: /(\/|\\)(node_modules)(\/|\\)/, // 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件 + // include: [/^src[/\\].*\.(vue|tsx|jsx|ts(?!d))$/], // }, }, } diff --git a/src/components/RayCollapseGrid/src/index.tsx b/src/components/RayCollapseGrid/src/index.tsx index b495b569..a6763cee 100644 --- a/src/components/RayCollapseGrid/src/index.tsx +++ b/src/components/RayCollapseGrid/src/index.tsx @@ -17,13 +17,12 @@ import { NCard, NGrid, NGridItem, NSpace } from 'naive-ui' import RayIcon from '@/components/RayIcon' import { call } from '@/utils/vue/index' -import { cloneDeep } from 'lodash-es' const RayCollapseGrid = defineComponent({ name: 'RayCollapseGrid', props: collapseGridProps, setup(props) { - const modelCollapsed = ref(cloneDeep(props.open)) + const modelCollapsed = ref(props.open) const handleCollapse = () => { modelCollapsed.value = !modelCollapsed.value diff --git a/src/components/RayTable/src/components/TableSize/index.tsx b/src/components/RayTable/src/components/TableSize/index.tsx index bdd04779..fe992cc3 100644 --- a/src/components/RayTable/src/components/TableSize/index.tsx +++ b/src/components/RayTable/src/components/TableSize/index.tsx @@ -14,24 +14,38 @@ import './index.scss' import { NPopover, NCard } from 'naive-ui' import RayIcon from '@/components/RayIcon/index' +import { call } from '@/utils/vue/index' + import type { TableSettingProvider } from '@/components/RayTable/src/type' import type { ComponentSize } from '@/types/modules/component' +import type { MaybeArray } from '@/types/modules/utils' const TableSize = defineComponent({ name: 'TableSize', + props: { + onChangeSize: { + type: [Function, Array] as PropType< + MaybeArray<(size: ComponentSize) => void> + >, + default: null, + }, + }, emits: ['changeSize'], - setup(_, { emit }) { + setup(props) { const tableSettingProvider = inject( 'tableSettingProvider', {} as TableSettingProvider, ) const popoverShow = ref(false) - const currentSize = ref(tableSettingProvider.size) const size = computed({ get: () => tableSettingProvider.size, set: (val) => { - currentSize.value = val + const { onChangeSize } = props + + if (onChangeSize) { + call(onChangeSize, val) + } }, }) const sizeOptions = ref([ @@ -55,15 +69,13 @@ const TableSize = defineComponent({ size.value = key popoverShow.value = false - - emit('changeSize', key) } }) } return { + size, sizeOptions, - currentSize, handleDropdownClick, popoverShow, } @@ -103,9 +115,7 @@ const TableSize = defineComponent({