Commit 7b76945bff004e969bf409de1b7fed594a119b6d

Authored by 周旭
Committed by GitHub
1 parent 540423ec

chore: perf TableAction.vue、build/utils.ts、prettier.config.js (#868)

* perf: 优化 build 时 vite 模式判断

* perf: 优化 TableAction, 仅在 action.tooltip 存在的情况下 才使用 Tooltip 组件

* docs: 仅在 action.tooltip 存在的情况下 才使用 Tooltip 组件

* fix: 在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题

* docs: 修复在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题
CHANGELOG.zh_CN.md
... ... @@ -5,9 +5,11 @@
5 5 - 修复树形表格的带有展开图标的单元格的内容对齐问题
6 6 - 新增`headerTop`插槽
7 7 - **AppSearch** 修复可能会搜索隐藏菜单的问题
  8 +- **TableAction** 仅在 action.tooltip 存在的情况下 才包裹 Tooltip 组件
8 9 - **其它**
9 10 - 修复菜单默认折叠的配置不起作用的问题
10 11 - 修复`safari`浏览器报错导致网站打不开
  12 + - 修复在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题
11 13  
12 14 ### 🎫 Chores
13 15  
... ...
build/utils.ts
... ... @@ -44,7 +44,7 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
44 44 */
45 45 function getConfFiles() {
46 46 const script = process.env.npm_lifecycle_script;
47   - const reg = new RegExp('--mode ([a-z]+) ');
  47 + const reg = new RegExp('--mode ([a-z]+)');
48 48 const result = reg.exec(script as string) as any;
49 49 if (result) {
50 50 const mode = result[1] as string;
... ...
prettier.config.js
... ... @@ -15,6 +15,6 @@ module.exports = {
15 15 requirePragma: false,
16 16 proseWrap: 'never',
17 17 htmlWhitespaceSensitivity: 'strict',
18   - endOfLine: 'lf',
  18 + endOfLine: 'auto',
19 19 rangeStart: 0,
20 20 };
... ...
src/components/Table/src/components/TableAction.vue
1 1 <template>
2 2 <div :class="[prefixCls, getAlign]" @click="onCellClick">
3 3 <template v-for="(action, index) in getActions" :key="`${index}-${action.label}`">
4   - <Tooltip v-bind="getTooltip(action.tooltip)">
  4 + <Tooltip v-if="action.tooltip" v-bind="getTooltip(action.tooltip)">
5 5 <PopConfirmButton v-bind="action">
6 6 <Icon :icon="action.icon" class="mr-1" v-if="action.icon" />
7 7 {{ action.label }}
8 8 </PopConfirmButton>
9 9 </Tooltip>
  10 + <PopConfirmButton v-else v-bind="action">
  11 + <Icon :icon="action.icon" class="mr-1" v-if="action.icon" />
  12 + {{ action.label }}
  13 + </PopConfirmButton>
10 14 <Divider
11 15 type="vertical"
12 16 class="action-divider"
... ... @@ -126,15 +130,13 @@
126 130 return actionColumn?.align ?? 'left';
127 131 });
128 132  
129   - const getTooltip = computed(() => {
130   - return (data: string | TooltipProps): TooltipProps => {
131   - if (isString(data)) {
132   - return { title: data, placement: 'bottom' };
133   - } else {
134   - return Object.assign({ placement: 'bottom' }, data);
135   - }
136   - };
137   - });
  133 + function getTooltip(data: string | TooltipProps): TooltipProps {
  134 + if (isString(data)) {
  135 + return { title: data, placement: 'bottom' };
  136 + } else {
  137 + return Object.assign({ placement: 'bottom' }, data);
  138 + }
  139 + }
138 140  
139 141 function onCellClick(e: MouseEvent) {
140 142 if (!props.stopButtonPropagation) return;
... ...