diff --git a/plugins/GravatarCache.js b/plugins/GravatarCache.js index fa6a245..77a35d7 100644 --- a/plugins/GravatarCache.js +++ b/plugins/GravatarCache.js @@ -1,5 +1,4 @@ import fs from 'fs' -import path from 'path' import axios from 'axios' import crypto from 'crypto' @@ -31,20 +30,11 @@ function getGravatar(email, size=128) { } } -function 检查并创建目录(dirname) { - if (fs.existsSync(dirname)) { - return true - } else if (检查并创建目录(path.dirname(dirname))) { - fs.mkdirSync(dirname) - return true - } - return false -} - export default { // 激活插件方法 activate() { - 检查并创建目录('./data/avatar/') + const dirname = './data/avatar/' + fs.mkdirSync(dirname, { recursive: true }) }, // 禁用插件方法 @@ -55,7 +45,3 @@ export default { // 向头像获取方法插入替换 getGravatar, // 获取头像(如果不存在自动从网络下载) } - -// test -// 检查并创建目录('./data/avatar/') -// getGravatar('huan0016@gmail.com', 128)