Browse Source

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 而保错问题
周旭 3 years ago
parent
commit
7b76945bff
4 changed files with 16 additions and 12 deletions
  1. 2 0
      CHANGELOG.zh_CN.md
  2. 1 1
      build/utils.ts
  3. 1 1
      prettier.config.js
  4. 12 10
      src/components/Table/src/components/TableAction.vue

+ 2 - 0
CHANGELOG.zh_CN.md

@@ -5,9 +5,11 @@
   - 修复树形表格的带有展开图标的单元格的内容对齐问题
   - 新增`headerTop`插槽
 - **AppSearch** 修复可能会搜索隐藏菜单的问题
+- **TableAction** 仅在 action.tooltip 存在的情况下 才包裹 Tooltip 组件
 - **其它**
   - 修复菜单默认折叠的配置不起作用的问题
   - 修复`safari`浏览器报错导致网站打不开
+  - 修复在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题
 
 ### 🎫 Chores
 

+ 1 - 1
build/utils.ts

@@ -44,7 +44,7 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
  */
 function getConfFiles() {
   const script = process.env.npm_lifecycle_script;
-  const reg = new RegExp('--mode ([a-z]+) ');
+  const reg = new RegExp('--mode ([a-z]+)');
   const result = reg.exec(script as string) as any;
   if (result) {
     const mode = result[1] as string;

+ 1 - 1
prettier.config.js

@@ -15,6 +15,6 @@ module.exports = {
   requirePragma: false,
   proseWrap: 'never',
   htmlWhitespaceSensitivity: 'strict',
-  endOfLine: 'lf',
+  endOfLine: 'auto',
   rangeStart: 0,
 };

+ 12 - 10
src/components/Table/src/components/TableAction.vue

@@ -1,12 +1,16 @@
 <template>
   <div :class="[prefixCls, getAlign]" @click="onCellClick">
     <template v-for="(action, index) in getActions" :key="`${index}-${action.label}`">
-      <Tooltip v-bind="getTooltip(action.tooltip)">
+      <Tooltip v-if="action.tooltip" v-bind="getTooltip(action.tooltip)">
         <PopConfirmButton v-bind="action">
           <Icon :icon="action.icon" class="mr-1" v-if="action.icon" />
           {{ action.label }}
         </PopConfirmButton>
       </Tooltip>
+      <PopConfirmButton v-else v-bind="action">
+        <Icon :icon="action.icon" class="mr-1" v-if="action.icon" />
+        {{ action.label }}
+      </PopConfirmButton>
       <Divider
         type="vertical"
         class="action-divider"
@@ -126,15 +130,13 @@
         return actionColumn?.align ?? 'left';
       });
 
-      const getTooltip = computed(() => {
-        return (data: string | TooltipProps): TooltipProps => {
-          if (isString(data)) {
-            return { title: data, placement: 'bottom' };
-          } else {
-            return Object.assign({ placement: 'bottom' }, data);
-          }
-        };
-      });
+      function getTooltip(data: string | TooltipProps): TooltipProps {
+        if (isString(data)) {
+          return { title: data, placement: 'bottom' };
+        } else {
+          return Object.assign({ placement: 'bottom' }, data);
+        }
+      }
 
       function onCellClick(e: MouseEvent) {
         if (!props.stopButtonPropagation) return;