File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,18 @@ export function DocsDestinationForm({ onChange }: DocsDestinationFormProps) {
3434 setTree ( data . tree || [ ] ) ;
3535 }
3636 } catch {
37- const res = await fetch ( "/docs-tree.json" ) . catch ( ( ) => null ) ;
38- const data = await res ?. json ( ) ;
39- if ( mounted && data ?. ok ) {
40- setTree ( data . tree || [ ] ) ;
37+ // API 失败是预期行为(开发环境常见),静默回退到静态文件
38+ try {
39+ const res = await fetch ( "/docs-tree.json" ) ;
40+ if ( ! res . ok ) throw new Error ( `HTTP ${ res . status } ` ) ;
41+ const data = await res . json ( ) ;
42+ if ( mounted && data ?. ok ) {
43+ setTree ( data . tree || [ ] ) ;
44+ }
45+ } catch ( fallbackError ) {
46+ // 静态文件也失败才是真正的问题
47+ console . error ( "无法加载文档目录树:" , fallbackError ) ;
48+ // 用户仍可继续使用,但无法选择目录
4149 }
4250 } finally {
4351 if ( mounted ) setLoading ( false ) ;
You can’t perform that action at this time.
0 commit comments