@@ -2,6 +2,7 @@ import { ItemView, WorkspaceLeaf, App, TextComponent, DropdownComponent, ButtonC
22import { DatabaseTable } from './databaseParser' ;
33import DatabasePlugin from './main' ;
44import { FuzzySuggestModal , TFolder } from 'obsidian' ;
5+ import { debug , info , warn , error } from './utils/logger' ;
56
67export const DATABASE_VIEW_TYPE = 'database-view' ;
78
@@ -47,7 +48,7 @@ export class DatabaseView extends ItemView {
4748 this . tableStates = tables . map ( ( table , index ) => ( { table, id : index + 1 , searchTerm : '' } ) ) ;
4849 this . renderView ( ) ;
4950 } else {
50- console . error ( ' setTables 收到无效数据:' , tables ) ;
51+ error ( ` setTables 收到无效数据: ${ JSON . stringify ( tables ) . substring ( 0 , 100 ) } ...` ) ;
5152 }
5253 }
5354
@@ -234,7 +235,7 @@ export class DatabaseView extends ItemView {
234235 : [ this . tableStates [ parseInt ( selectedValue ) ] ?. table ] . filter ( Boolean ) ;
235236
236237 if ( tablesToExport . length === 0 ) {
237- console . error ( 'No tables to export' ) ;
238+ error ( 'No tables to export' ) ;
238239 return ;
239240 }
240241
@@ -307,10 +308,10 @@ export class DatabaseView extends ItemView {
307308 try {
308309 await this . app . vault . create ( `${ folderPath } /${ fileName } ` , content ) ;
309310 new Notice ( `已创建数据库笔记: ${ fileName } ` ) ;
310- } catch ( error ) {
311- console . error ( ' 创建数据库笔记时出错:' , error ) ;
312- if ( isError ( error ) ) {
313- new Notice ( `创建数据库笔记失败: ${ error . message } ` ) ;
311+ } catch ( err ) {
312+ error ( ` 创建数据库笔记时出错: ${ err instanceof Error ? err . message : String ( err ) } ` ) ;
313+ if ( err instanceof Error ) {
314+ new Notice ( `创建数据库笔记失败: ${ err . message } ` ) ;
314315 } else {
315316 new Notice ( '创建数据库笔记失败: 未知错误' ) ;
316317 }
@@ -389,7 +390,7 @@ export class DatabaseView extends ItemView {
389390 }
390391
391392 public insertContent ( content : string ) {
392- console . log ( " Inserting content into DatabaseView:" , content ) ;
393+ debug ( ` Inserting content into DatabaseView: ${ content . substring ( 0 , 100 ) } ...` ) ;
393394 const newTables = this . parseCSVContent ( content ) ;
394395 if ( newTables . length > 0 ) {
395396 newTables . forEach ( newTable => {
@@ -402,6 +403,7 @@ export class DatabaseView extends ItemView {
402403 this . renderView ( ) ;
403404 new Notice ( `已在数据库视图中插入 ${ newTables . length } 个新表格` ) ;
404405 } else {
406+ warn ( '无法解析导入的内容' ) ;
405407 new Notice ( '无法解析导入的内容' ) ;
406408 }
407409 }
0 commit comments