Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update vue/core to v3.5.10 #3206

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"vite-plugin-vue-devtools": "^7.2.1",
"vitest": "^2.0.1",
"vitest-canvas-mock": "^0.3.3",
"vue": "^3.4.31",
"vue": "^3.5.10",
"vue-tsc": "^1.8.27"
},
"engines": {
Expand Down
303 changes: 238 additions & 65 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion publish/nutui-taro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
| [@nutui/icons-vue](https://github.com/jdf2e/nutui-icons) | `@nutui/nutui` 使用的图标库 | ![nutui](https://img.shields.io/npm/v/@nutui/icons-vue.svg?label=%20) |
| [@nutui/icons-vue-taro](https://github.com/jdf2e/nutui-icons) | `@nutui/nutui-taro` 使用的图标库 | ![nutui](https://img.shields.io/npm/v/@nutui/icons-vue-taro.svg?label=%20) |
| [@nutui/touch-emulator](packages/nutui-touch-emulator) | 在桌面端使用 NutUI 的辅助库 | ![nutui](https://img.shields.io/npm/v/@nutui/touch-emulator.svg?label=%20) |
| [@nutui/auto-import-resolver](packages/nutui-auto-import-resolver) | `unplugin-auto-import` 插件的 reolver 配置 | ![nutui](https://img.shields.io/npm/v/@nutui/auto-import-resolver.svg?label=%20) |
| [@nutui/auto-import-resolver](packages/nutui-auto-import-resolver) | `unplugin-auto-import` 插件的 resolver 配置 | ![nutui](https://img.shields.io/npm/v/@nutui/auto-import-resolver.svg?label=%20) |
| [@nutui/playground](packages/nutui-playground) | NutUI 在线 Playground | - |
| [nutui-demo](https://github.com/jdf2e/nutui-demo) | NutUI 官方示例合集 | - |

Expand Down
2 changes: 1 addition & 1 deletion publish/nutui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
| [@nutui/icons-vue](https://github.com/jdf2e/nutui-icons) | `@nutui/nutui` 使用的图标库 | ![nutui](https://img.shields.io/npm/v/@nutui/icons-vue.svg?label=%20) |
| [@nutui/icons-vue-taro](https://github.com/jdf2e/nutui-icons) | `@nutui/nutui-taro` 使用的图标库 | ![nutui](https://img.shields.io/npm/v/@nutui/icons-vue-taro.svg?label=%20) |
| [@nutui/touch-emulator](packages/nutui-touch-emulator) | 在桌面端使用 NutUI 的辅助库 | ![nutui](https://img.shields.io/npm/v/@nutui/touch-emulator.svg?label=%20) |
| [@nutui/auto-import-resolver](packages/nutui-auto-import-resolver) | `unplugin-auto-import` 插件的 reolver 配置 | ![nutui](https://img.shields.io/npm/v/@nutui/auto-import-resolver.svg?label=%20) |
| [@nutui/auto-import-resolver](packages/nutui-auto-import-resolver) | `unplugin-auto-import` 插件的 resolver 配置 | ![nutui](https://img.shields.io/npm/v/@nutui/auto-import-resolver.svg?label=%20) |
| [@nutui/playground](packages/nutui-playground) | NutUI 在线 Playground | - |
| [nutui-demo](https://github.com/jdf2e/nutui-demo) | NutUI 官方示例合集 | - |

Expand Down
13 changes: 2 additions & 11 deletions src/packages/__VUE/comment/components/CmtImages.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<view class="nut-comment-images__play"></view>
</view>
<!-- images -->
<template v-for="(itI, index) in images" :key="itI.id">
<template v-for="(itI, index) in images" :key="index">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

建议使用唯一标识符作为 key

在 v-for 指令中,将 key 从 itI.id 更改为 index 可能会导致性能问题和意外行为,特别是在列表项被添加、删除或重新排序时。

建议:

  1. 如果 itI 对象中有唯一标识符(如 id),请使用该标识符作为 key。
  2. 如果没有唯一标识符,考虑在数据源中添加一个。
  3. 如果无法修改数据源,可以考虑使用复合键,例如:
<template v-for="(itI, index) in images" :key="`${itI.imgUrl}-${index}`">

这种方法比单独使用索引更可靠,但仍不如使用真正的唯一标识符。

<view
v-if="(type == 'multi' && videos.length + index < 9) || type != 'multi'"
class="nut-comment-images__item nut-comment-images__item--imgbox"
Expand All @@ -37,16 +37,7 @@ import { createComponent } from '@/packages/utils/create'
const { create } = createComponent('comment-images')
import { Right } from '@nutui/icons-vue-taro'

interface VideosType {
id?: number | string
mainUrl: string
videoUrl: string
}
interface ImagesType {
smallImgUrl: string
bigImgUrl: string
imgUrl: string
}
import { VideosType, ImagesType } from '../type'
export default create({
props: {
type: {
Expand Down
13 changes: 2 additions & 11 deletions src/packages/__VUE/comment/components/CmtImages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<view class="nut-comment-images__play"></view>
</view>
<!-- images -->
<template v-for="(itI, index) in images" :key="itI.id">
<template v-for="(itI, index) in images" :key="index">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

考虑使用唯一标识符作为 v-for 的 key

在 v-for 指令中,使用索引(index)作为 key 可能会导致一些渲染问题,特别是当列表项目顺序发生变化时。建议使用每个图片项目的唯一标识符作为 key,如果有的话。

如果确实需要使用索引,请考虑添加注释解释原因,以便其他开发者理解这个决定。

建议修改如下:

- <template v-for="(itI, index) in images" :key="index">
+ <template v-for="(itI, index) in images" :key="itI.id || index">

如果 itI.id 不可用,请确保解释为什么使用索引是安全的。

Committable suggestion was skipped due to low confidence.

<view
v-if="(type == 'multi' && videos.length + index < 9) || type != 'multi'"
class="nut-comment-images__item nut-comment-images__item--imgbox"
Expand All @@ -37,16 +37,7 @@ import { createComponent } from '@/packages/utils/create'
const { create } = createComponent('comment-images')
import { Right } from '@nutui/icons-vue'

interface VideosType {
id?: number | string
mainUrl: string
videoUrl: string
}
interface ImagesType {
smallImgUrl: string
bigImgUrl: string
imgUrl: string
}
import { VideosType, ImagesType } from '../type'
export default create({
props: {
type: {
Expand Down
12 changes: 1 addition & 11 deletions src/packages/__VUE/comment/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,7 @@ import CommentHeader from './components/CmtHeader.taro.vue'
import CommentImages from './components/CmtImages.taro.vue'
import CommentBottom from './components/CmtBottom.taro.vue'
import { useLocale } from '@/packages/utils/useLocale'

interface VideosType {
id?: number | string
mainUrl: string
videoUrl: string
}
interface ImagesType {
smallImgUrl: string
bigImgUrl: string
imgUrl: string
}
import { VideosType, ImagesType } from './type'

const { create } = createComponent('comment')
const cN = 'NutComment'
Expand Down
12 changes: 1 addition & 11 deletions src/packages/__VUE/comment/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,7 @@ import CommentHeader from './components/CmtHeader.vue'
import CommentImages from './components/CmtImages.vue'
import CommentBottom from './components/CmtBottom.vue'
import { useLocale } from '@/packages/utils/useLocale'

interface VideosType {
id?: number | string
mainUrl: string
videoUrl: string
}
interface ImagesType {
smallImgUrl: string
bigImgUrl: string
imgUrl: string
}
import { VideosType, ImagesType } from './type'

const { create } = createComponent('comment')
const cN = 'NutComment'
Expand Down
10 changes: 10 additions & 0 deletions src/packages/__VUE/comment/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface VideosType {
id?: number | string
mainUrl: string
videoUrl: string
}
Comment on lines +1 to +5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

考虑对 VideosType 接口进行以下改进:

  1. 接口名称使用单数形式可能更合适,例如 VideoType,因为它代表单个视频项。

  2. id 属性的类型灵活性可能导致类型相关的问题。考虑是否可以将其限制为单一类型。

  3. mainUrlvideoUrl 没有 URL 有效性验证。考虑添加自定义类型或验证函数来确保这些是有效的 URL。

  4. 可以添加 JSDoc 注释来解释每个属性的用途,特别是 mainUrlvideoUrl 的区别。

建议的改进示例:

/**
 * 表示单个视频项的接口
 */
export interface VideoType {
  /** 视频的唯一标识符 */
  id?: string
  /** 视频的主要显示URL */
  mainUrl: URL
  /** 视频的播放URL */
  videoUrl: URL
}

使用 URL 类型可以在运行时提供额外的 URL 有效性检查。

export interface ImagesType {
smallImgUrl: string
bigImgUrl: string
imgUrl: string
}
Comment on lines +6 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议对 ImagesType 接口进行以下优化:

  1. 接口名称使用单数形式可能更合适,例如 ImageType,因为它代表单个图片项的不同尺寸。

  2. 所有 URL 属性缺少有效性验证。考虑使用 URL 类型或添加验证函数。

  3. imgUrl 的用途不清晰,建议澄清其与 smallImgUrlbigImgUrl 的关系,或考虑移除。

  4. 可以添加 JSDoc 注释来解释每个属性的具体用途。

建议的改进示例:

/**
 * 表示单个图片项的不同尺寸URL
 */
export interface ImageType {
  /** 小尺寸图片URL */
  smallImgUrl: URL
  /** 大尺寸图片URL */
  bigImgUrl: URL
  /** 
   * 原始尺寸图片URL
   * @deprecated 考虑使用 originalImgUrl 作为更清晰的命名
   */
  imgUrl: URL
}

这个改进版本使用了更具描述性的名称,并添加了注释以提高可读性和可维护性。

10 changes: 2 additions & 8 deletions src/packages/__VUE/sku/components/SkuSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@
<script lang="ts">
import { ref, watch, onMounted } from 'vue'
import { createComponent } from '@/packages/utils/create'
const { create } = createComponent('sku-select')
import { SkuInfo } from '../type'

interface SkuInfo {
name: string
id: number
active: boolean
disable: boolean
[props: string]: any
}
const { create } = createComponent('sku-select')
export default create({
props: {
sku: {
Expand Down
2 changes: 0 additions & 2 deletions src/packages/__VUE/sku/components/SkuStepper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { ref, onMounted } from 'vue'
import { createComponent } from '@/packages/utils/create'
import NutInputNumber from '../../inputnumber'
const { create } = createComponent('sku-stepper')

export default create({
props: {
// 购买数量最大值
Expand All @@ -47,7 +46,6 @@ export default create({
}
},
emits: ['click', 'changeSku', 'changeStepper', 'clickBtnOptions', 'overLimit', 'reduce', 'add'],

components: {
NutInputNumber
},
Expand Down
7 changes: 7 additions & 0 deletions src/packages/__VUE/sku/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface SkuInfo {
name: string
id: number
active: boolean
disable: boolean
[props: string]: any
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议重新考虑使用 any 类型

使用 [props: string]: any 作为索引签名虽然提供了灵活性,但可能导致类型安全问题。考虑使用更具体的类型或联合类型来增强类型安全性。

例如,如果可能的话,您可以尝试以下方法之一:

  1. 使用更具体的类型:

    [props: string]: string | number | boolean
  2. 如果确实需要高度的灵活性,可以使用 unknown 代替 any

    [props: string]: unknown
  3. 如果可能的额外属性是已知的,可以使用联合类型:

    [props: string]: string | number | boolean | SomeOtherType

这些建议可以帮助在保持灵活性的同时提高类型安全性。

🧰 Tools
🪛 GitHub Check: CodeFactor

[warning] 6-6: src/packages/__VUE/sku/type.ts#L6
Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)

}

Check warning on line 7 in src/packages/__VUE/sku/type.ts

View check run for this annotation

codefactor.io / CodeFactor

src/packages/__VUE/sku/type.ts#L7

Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)