arco-design / arco-design-pro

An out-of-the-box solution to quickly build enterprise-level applications based on Arco Design.
https://pro.arco.design
MIT License
460 stars 91 forks source link

官方模板无法构建 #94

Open Nash-x9 opened 1 year ago

Nash-x9 commented 1 year ago

Basic Info

Extra info

可否提供推荐开发环境及版本? 我目前环境如下: node -v v14.21.1 npm -v 9.1.2 yarn -v 1.22.18

What is expected?

正常构建

Steps to reproduce

使用arco cli 下载的模板无法build

"dependencies": {
    "@arco-design/web-vue": "^2.37.4",
    "@vueuse/core": "^9.3.0",
    "arco-design-pro-vue": "^2.5.14",
    "axios": "^0.24.0",
    "dayjs": "^1.11.5",
    "echarts": "^5.4.0",
    "lodash": "^4.17.21",
    "mitt": "^3.0.0",
    "nprogress": "^0.2.0",
    "pinia": "^2.0.23",
    "query-string": "^7.1.1",
    "sortablejs": "^1.15.0",
    "vue": "^3.2.40",
    "vue-echarts": "^6.2.3",
    "vue-i18n": "^9.2.2",
    "vue-router": "^4.0.14"
  }

yarn build 提示

src/components/global-setting/index.vue:2:56 - error TS2322: Type '() => void' is not assignable to type 'MouseEvent'.

2   <div v-if="!appStore.navbar" class="fixed-settings" @click="setVisible">
                                                         ~~~~~

src/components/tab-bar/tab-item.vue:10:8 - error TS2322: Type '($event: any) => void' is not assignable to type 'MouseEvent'.

10       @click="goto(itemData)"
          ~~~~~

src/components/tab-bar/tab-item.vue:17:10 - error TS2322: Type '($event: any) => void' is not assignable to type 'MouseEvent'.

17         @click.stop="tagClose(itemData, index)"
            ~~~~~

src/components/message-box/list.vue:17:31 - error TS2322: Type '($event: any) => void' is not assignable to type 'MouseEvent'.

17       <div class="item-wrap" @click="onItemClick(item)">
                                 ~~~~~

src/views/list/search-table/index.vue:131:39 - error TS2322: Type '() => void' is not assignable to type 'MouseEvent'.

131             <div class="action-icon" @click="search"
                                          ~~~~~

src/router/index.ts:26:5 - error TS2322: Type 'RouteRecordNormalized | AppRouteRecordRaw | { path: string; name: string; component: () => Promise<typeof import("/path/arco-design-pro-templates/src/views/not-found/index.vue")>; }' is not assignable to type 'RouteRecordRaw'.
  Type 'AppRouteRecordRaw' is not assignable to type 'RouteRecordRaw'.
    Type 'AppRouteRecordRaw' is not assignable to type 'RouteRecordRedirect'.
      Types of property 'redirect' are incompatible.
        Type 'string | undefined' is not assignable to type 'RouteRecordRedirectOption'.
          Type 'undefined' is not assignable to type 'RouteRecordRedirectOption'.

26     ...appRoutes,
       ~~~~~~~~~~~~

src/router/index.ts:27:5 - error TS2322: Type 'AppRouteRecordRaw' is not assignable to type 'RouteRecordRaw'.

27     REDIRECT_MAIN,
       ~~~~~~~~~~~~~

src/router/index.ts:28:5 - error TS2322: Type 'RouteRecordNormalized | AppRouteRecordRaw | { path: string; name: string; component: () => Promise<typeof import("/path/arco-design-pro-templates/src/views/not-found/index.vue")>; }' is not assignable to type 'RouteRecordRaw'.

28     NOT_FOUND_ROUTE,
       ~~~~~~~~~~~~~~~

Found 8 errors in 5 files.

Errors  Files
     1  src/components/global-setting/index.vue:2
     2  src/components/tab-bar/tab-item.vue:10
     1  src/components/message-box/list.vue:17
     1  src/views/list/search-table/index.vue:131
     3  src/router/index.ts:26
jiabochao commented 1 year ago
  1. 可将 "vue": "^3.2.40" 升级为 "vue": "^3.2.41" 来解决 error TS2322: Type '() => void' is not assignable to type 'MouseEvent'
  2. 另外可临时将 REDIRECT_MAIN 类型暂时去除来解决类型不匹配的问题:https://github.com/arco-design/arco-design-pro-vue/blob/main/arco-design-pro-vite/src/router/routes/base.ts#L6
export const REDIRECT_MAIN: AppRouteRecordRaw = {
  path: '/redirect',
  name: 'redirectWrapper',
  component: DEFAULT_LAYOUT,
  meta: {
    requiresAuth: true,
    hideInMenu: true,
  },
  children: [
    {
      path: '/redirect/:path',
      name: REDIRECT_ROUTE_NAME,
      component: () => import('@/views/redirect/index.vue'),
      meta: {
        requiresAuth: true,
        hideInMenu: true,
      },
    },
  ],
};

改为

export const REDIRECT_MAIN = {
  path: '/redirect',
  name: 'redirectWrapper',
  component: DEFAULT_LAYOUT,
  meta: {
    requiresAuth: true,
    hideInMenu: true,
  },
  children: [
    {
      path: '/redirect/:path',
      name: REDIRECT_ROUTE_NAME,
      component: () => import('@/views/redirect/index.vue'),
      meta: {
        requiresAuth: true,
        hideInMenu: true,
      },
    },
  ],
};
icetech233 commented 1 year ago

vite.config.dev.ts 和 vite.config.prod.ts 内容差距好大

我用 vite.config.dev.ts 去vite build 没有问题

vite刚出来没多久,没有想到会有用的,看不懂