appsnbcbweicheng 1.1.6 → 1.1.7

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": "appsnbcbweicheng",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/public/show.txt CHANGED
@@ -1,14 +1,15 @@
1
1
  function Show-Tree {
2
2
  param (
3
- [string]$Path = ".",
4
- [int]$Depth = 1
3
+ [string]$Path = ".", # 要展示的路径,默认为当前目录
4
+ [int]$Depth = 1 # 控制显示的深度
5
5
  )
6
6
 
7
7
  function Write-Tree {
8
8
  param (
9
9
  [System.IO.FileSystemInfo[]]$items,
10
10
  [string]$prefix = "",
11
- [bool]$isLastParent = $false
11
+ [bool]$isLastParent = $false,
12
+ [int]$currentDepth = 1 # 当前递归的深度
12
13
  )
13
14
 
14
15
  for ($i = 0; $i -lt $items.Count; $i++) {
@@ -18,23 +19,23 @@ function Show-Tree {
18
19
  # 根据层级输出前缀符号
19
20
  $currentPrefix = if ($isLastParent) { "$prefix " } else { "$prefix│ " }
20
21
 
21
- # 设置不同颜色:文件和文件夹
22
- if ($item.PSIsContainer) {
23
- Write-Host "$prefix├──" -NoNewline; Write-Host " $($item.Name)" -ForegroundColor Cyan
22
+ # 输出当前目录/文件
23
+ if ($isLastItem) {
24
+ Write-Host "$prefix└── $($item.Name)"
24
25
  } else {
25
- Write-Host "$prefix├──" -NoNewline; Write-Host " $($item.Name)" -ForegroundColor Green
26
+ Write-Host "$prefix├── $($item.Name)"
26
27
  }
27
28
 
28
- # 如果是目录且需要递归调用
29
- if ($item.PSIsContainer -and $Depth -gt 1) {
30
- Write-Tree (Get-ChildItem -Path $item.FullName) $currentPrefix $isLastItem
29
+ # 如果是目录且没有超过指定深度,则递归调用
30
+ if ($item.PSIsContainer -and $currentDepth -lt $Depth) {
31
+ Write-Tree (Get-ChildItem -Path $item.FullName) $currentPrefix $isLastItem ($currentDepth + 1)
31
32
  }
32
33
  }
33
34
  }
34
35
 
35
36
  # 获取初始层的项目并开始递归输出
36
37
  $items = Get-ChildItem -Path $Path
37
- Write-Tree -items $items
38
+ Write-Tree -items $items -currentDepth 1
38
39
  }
39
40
 
40
41
  # 执行函数,查看结果
package/readme.md CHANGED
@@ -1,3 +1,4 @@
1
+ 1.1.7 show-tree 优化层级
1
2
  1.1.6 show-tree
2
3
  1.1.5 readme
3
4
  1.1.4 vscode 1.92.2