diff --git a/data.json b/data.json index 1cf3864..9f81a52 100644 --- a/data.json +++ b/data.json @@ -1,4 +1,5 @@ { "strict_mode": false, - "vaultDir": "D:\\iLanix\\Obsidian" + "vaultDir": "D:\\iLanix\\Obsidian\nD:\\github\\ObsidianZY", + "git_repo": "https://github.com/zigholding/ObsidianZ/tree/master\nhttps://gitee.com/zigholding/ObsidianZ/tree/master" } \ No newline at end of file diff --git a/main.ts b/main.ts index b5146ee..199d937 100644 --- a/main.ts +++ b/main.ts @@ -59,7 +59,7 @@ export default class NoteSyncPlugin extends Plugin { this.fsEditor.sync_tfile(file,dst,'mtime',true,false); }else if(file instanceof TFolder){ - this.fsEditor.sync_tfolder(file,dst,'mtime',true,false); + this.fsEditor.sync_tfolder(file,dst,'mtime',true,false,this.settings.strict_mode); } }); }); @@ -124,10 +124,11 @@ export default class NoteSyncPlugin extends Plugin { let assets = fm[this.yaml]?.Assets if(fm[this.yaml]?.UseGitLink && assets){ + ctx = ctx.replace( /\!\[\[(.*?)\]\]/g, (match, filename) => { - return `![](./${assets}/${filename})`; + return `![](./${assets}/${filename.replace(/ /g,'%20')})`; }) } await this.fsEditor.fs.writeFile( diff --git a/src/commands.ts b/src/commands.ts index c91a781..f4d5670 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -102,7 +102,7 @@ const cmd_export_plugin = (plugin:NoteSyncPlugin) => ({ let dst = `${target}/${item}`; let flag = plugin.fsEditor.copy_file(src,dst,'overwrite'); if(flag){ - new Notice(`Copy ${item} to ${target}`,5000) + console.log(`Copy ${item} to ${target}`,5000) } } } diff --git a/src/fseditor.ts b/src/fseditor.ts index 00b3329..34f4f4d 100644 --- a/src/fseditor.ts +++ b/src/fseditor.ts @@ -94,8 +94,11 @@ export class FsEditor{ } - abspath(tfile:TFile|TFolder){ - if(tfile){ + abspath(tfile:TFile|TFolder|string){ + if(typeof tfile == 'string'){ + return (this.root+'/'+tfile).replace(/\\/g,'/'); + } + else if(tfile){ return (this.root+'/'+tfile.path).replace(/\\/g,'/'); }else{ return null; @@ -179,17 +182,20 @@ export class FsEditor{ if(mode==='overwrite'){ fs.unlinkSync(dst); fs.copyFileSync(src,dst); + console.log('Overwrite: '+src+' to '+dst); return true; }else if(mode==='mtime'){ // dst 更新时间小于 src if(fs.statSync(dst).mtimeMs