@@ -114,23 +114,30 @@ def dealUserException(self, userExp: UserException):
114114 sysConfig .writeMainConfig ()
115115 print ("访问令牌已保存,请重新运行程序" )
116116 elif userExp .getErrorCode () == UserException .CODE_UPLOAD_ERROR :
117- currentImgService = sysConfig .getConfigParam (Config .PARAM_IMG_SERVICE )
118- print ("上传图片到" + str (currentImgService )+ "失败,请检查日志文件" , sysConfig .getErrorLogFilePath ())
117+ currentImgService = sysConfig .getConfigParam (
118+ Config .PARAM_IMG_SERVICE )
119+ print ("上传图片到" + str (currentImgService )+ "失败,请检查日志文件" ,
120+ sysConfig .getErrorLogFilePath ())
119121 elif userExp .getErrorCode () == UserException .CODE_TIMEOUT :
120122 print (userExp .getErrorMsg ())
123+ elif userExp .getErrorCode () == UserException .CODE_NO_YUJIAN_TOKEN :
124+ token = input ("缺少你的遇见图床访问令牌,请输入:" )
125+ sysConfig .setConfigParam (Config .PARAM_YUJIAN_TOKEN , token )
126+ sysConfig .writeMainConfig ()
127+ print ("访问令牌已保存,请重新运行程序" )
121128 else :
122129 print ("未定义错误,请联系开发者" )
123130 exit ()
124131
125- def main (self , refresh = False ):
132+ def main (self , refresh = False ):
126133 # 检索当前目录中的markdown文件
127134 for dir in os .listdir ():
128135 if os .path .isfile (dir ):
129136 if self .isOrigMdFile (dir ):
130137 # 如果副本存在,刷新模式下且原md文件更新过的,删除副本,重新生成,否则不处理
131138 copyFilePath = self .getCopyFilePath (dir )
132139 if os .path .exists (copyFilePath ):
133- if refresh and TimeHelper .compareTwoFilsLastModifyTime (dir ,copyFilePath ) > 0 :
140+ if refresh and TimeHelper .compareTwoFilsLastModifyTime (dir , copyFilePath ) > 0 :
134141 os .remove (copyFilePath )
135142 else :
136143 continue
@@ -189,7 +196,7 @@ def recoveryImgsInMarkdown(self, copyFilePath: 'copied markdown file path', orig
189196 return False
190197
191198 def changeImgService (self , selectedService ):
192- supportedService = {'smms' , 'ali' , 'rruu' , 'vimcn' }
199+ supportedService = {'smms' , 'ali' , 'rruu' , 'vimcn' , 'yujian' }
193200 if selectedService not in supportedService :
194201 print ('不支持的图床服务' , selectedService )
195202 return False
@@ -203,6 +210,9 @@ def changeImgService(self, selectedService):
203210 elif selectedService == 'vimcn' :
204211 sysConfig .setConfigParam (
205212 Config .PARAM_IMG_SERVICE , Config .IMG_SERVICE_VIMCN )
213+ elif selectedService == 'yujian' :
214+ sysConfig .setConfigParam (
215+ Config .PARAM_IMG_SERVICE , Config .IMG_SERVICE_YUJIAN )
206216 else :
207217 sysConfig .setConfigParam (
208218 Config .PARAM_IMG_SERVICE , Config .IMG_SERVICE_SMMS )
@@ -211,7 +221,7 @@ def changeImgService(self, selectedService):
211221 return True
212222
213223 def changeToken (self , imgService ):
214- tokenImgServices = {'rruu' , 'smms' }
224+ tokenImgServices = {'rruu' , 'smms' , 'yujian' }
215225 if imgService not in tokenImgServices :
216226 print ('不是合法的图床' , imgService )
217227 return False
@@ -221,6 +231,8 @@ def changeToken(self, imgService):
221231 sysConfig .setConfigParam (Config .PARAM_RRUU_TOKEN , token )
222232 elif imgService == 'smms' :
223233 sysConfig .setConfigParam (Config .PARAM_SMMS_TOKEN , token )
234+ elif imgService == 'yujian' :
235+ sysConfig .setConfigParam (Config .PARAM_YUJIAN_TOKEN , token )
224236 else :
225237 pass
226238 sysConfig .writeMainConfig ()
0 commit comments