@zhin.js/console 2.0.4 → 2.0.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @zhin.js/console
2
2
 
3
+ ## 2.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - ba30934: fix: web 优化
8
+ - Updated dependencies [ba30934]
9
+ - @zhin.js/http@1.0.58
10
+ - @zhin.js/agent@0.1.5
11
+ - zhin.js@1.0.63
12
+ - @zhin.js/core@1.1.5
13
+
3
14
  ## 2.0.4
4
15
 
5
16
  ### Patch Changes
@@ -2,7 +2,6 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "display": "Zhin Console — 适配器 / 插件「浏览器端 client/」推荐基线",
4
4
  "compilerOptions": {
5
- "baseUrl": ".",
6
5
  "declaration": true,
7
6
  "module": "ESNext",
8
7
  "moduleResolution": "bundler",
@@ -1,4 +1,4 @@
1
- import { useEffect, useState, useMemo, useCallback } from 'react'
1
+ import { useEffect, useState, useMemo, useCallback, useRef } from 'react'
2
2
  import {
3
3
  Search, Package, Download, ExternalLink, AlertCircle,
4
4
  ArrowUpDown, RefreshCw, ShieldCheck, Globe,
@@ -78,6 +78,8 @@ export default function MarketplacePage() {
78
78
  const [loading, setLoading] = useState(true)
79
79
  const [error, setError] = useState<string | null>(null)
80
80
  const [search, setSearch] = useState('')
81
+ const [debouncedSearch, setDebouncedSearch] = useState('')
82
+ const debounceRef = useRef<ReturnType<typeof setTimeout>>()
81
83
  const [category, setCategory] = useState<Category>('')
82
84
  const [officialOnly, setOfficialOnly] = useState(false)
83
85
  const [sortKey, setSortKey] = useState<SortKey>('name')
@@ -94,7 +96,7 @@ export default function MarketplacePage() {
94
96
  setError(null)
95
97
  try {
96
98
  const params = new URLSearchParams()
97
- if (search) params.set('q', search)
99
+ if (debouncedSearch) params.set('q', debouncedSearch)
98
100
  if (category) params.set('category', category)
99
101
  if (officialOnly) params.set('official', 'true')
100
102
  params.set('limit', '50')
@@ -112,7 +114,14 @@ export default function MarketplacePage() {
112
114
  } finally {
113
115
  setLoading(false)
114
116
  }
115
- }, [search, category, officialOnly])
117
+ }, [debouncedSearch, category, officialOnly])
118
+
119
+ // Debounce search input (350ms)
120
+ useEffect(() => {
121
+ clearTimeout(debounceRef.current)
122
+ debounceRef.current = setTimeout(() => setDebouncedSearch(search), 350)
123
+ return () => clearTimeout(debounceRef.current)
124
+ }, [search])
116
125
 
117
126
  useEffect(() => {
118
127
  fetchPlugins()
@@ -138,7 +147,7 @@ export default function MarketplacePage() {
138
147
  setDetailLoading(true)
139
148
  setDetail(null)
140
149
  try {
141
- const res = await fetch(`/pub/marketplace/detail/${encodeURIComponent(name)}`)
150
+ const res = await fetch(`/pub/marketplace/detail/${name}`)
142
151
  if (res.ok) {
143
152
  const data = await res.json()
144
153
  if (data.success) setDetail(data.data)
@@ -322,7 +331,7 @@ export default function MarketplacePage() {
322
331
 
323
332
  {/* Detail Dialog */}
324
333
  <Dialog open={detailOpen} onOpenChange={setDetailOpen}>
325
- <DialogContent className="max-w-lg max-h-[80vh] overflow-y-auto">
334
+ <DialogContent className="max-w-2xl max-h-[80vh] overflow-y-auto">
326
335
  {detailLoading ? (
327
336
  <div className="space-y-3">
328
337
  <Skeleton className="h-6 w-48" />
@@ -427,7 +436,7 @@ export default function MarketplacePage() {
427
436
  </div>
428
437
  </div>
429
438
 
430
- <DialogFooter className="gap-2">
439
+ <DialogFooter className="gap-2 flex-wrap">
431
440
  {detail.homepage && (
432
441
  <Button variant="outline" size="sm" asChild>
433
442
  <a href={detail.homepage} target="_blank" rel="noopener noreferrer">
@@ -435,17 +444,15 @@ export default function MarketplacePage() {
435
444
  </a>
436
445
  </Button>
437
446
  )}
438
- {detail.npm || (
439
- <Button variant="outline" size="sm" asChild>
440
- <a
441
- href={`https://www.npmjs.com/package/${detail.name}`}
442
- target="_blank"
443
- rel="noopener noreferrer"
444
- >
445
- <Download className="w-3 h-3 mr-1" /> npm
446
- </a>
447
- </Button>
448
- )}
447
+ <Button variant="outline" size="sm" asChild>
448
+ <a
449
+ href={detail.npm || `https://www.npmjs.com/package/${detail.name}`}
450
+ target="_blank"
451
+ rel="noopener noreferrer"
452
+ >
453
+ <Download className="w-3 h-3 mr-1" /> npm
454
+ </a>
455
+ </Button>
449
456
  <DialogClose asChild>
450
457
  <Button variant="secondary" size="sm">关闭</Button>
451
458
  </DialogClose>