vue2server7 7.0.2 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "7.0.2",
3
+ "version": "7.0.4",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",
package/test/11111111.tx CHANGED
@@ -1,12 +1,24 @@
1
- import type { App } from 'vue'
1
+ import type { App, Component } from 'vue'
2
2
  import NumberInput from './NumberInput.vue'
3
3
 
4
- const components = [NumberInput]
4
+ // 组件列表类型声明
5
+ const components: Component[] = [NumberInput]
5
6
 
7
+ // ✅ 插件类型
8
+ const install = (app: App): void => {
9
+ components.forEach((comp) => {
10
+ app.component(
11
+ // @ts-ignore 兼容 name 类型
12
+ comp.name as string,
13
+ comp
14
+ )
15
+ })
16
+ }
17
+
18
+ // ✅ 导出(支持 app.use)
6
19
  export default {
7
- install(app: App) {
8
- components.forEach((comp) => {
9
- app.component(comp.name || 'NumberInput', comp)
10
- })
11
- }
12
- }
20
+ install
21
+ }
22
+
23
+ // ✅ 也可以单独导出组件(可选)
24
+ export { NumberInput }
package/test/320 ADDED
@@ -0,0 +1,25 @@
1
+ interface TreeNode {
2
+ value: string | number
3
+ label: string
4
+ children?: TreeNode[]
5
+ }
6
+
7
+ function findLabelByValue(
8
+ list: TreeNode[],
9
+ targetValue: string | number
10
+ ): string | null {
11
+ for (const item of list) {
12
+ // 当前节点命中
13
+ if (item.value === targetValue) {
14
+ return item.label
15
+ }
16
+
17
+ // 递归子节点
18
+ if (item.children && item.children.length) {
19
+ const result = findLabelByValue(item.children, targetValue)
20
+ if (result) return result
21
+ }
22
+ }
23
+
24
+ return null
25
+ }