Update md_theme plugin

This commit is contained in:
LucasYuNju
2016-12-26 23:17:17 +08:00
parent d8fa5ff67f
commit 4ef593c62e

View File

@@ -27,20 +27,19 @@ define(function() {
_themes: [], _themes: [],
getThemes: function() { getThemes: function() {
var me = this; var me = this;
// 遍历主题目录, 得到主题列表
// 遍历主题目录, 得到主题 var themeFolder = __dirname + "/public/themes/markdown";
var themeBasePath = __dirname + "/public/md/themes/themes"; Api.nodeFs.readdirSync(themeFolder)
var dirs = Api.nodeFs.readdirSync(themeBasePath); .filter(function(theme) {
for(var i = 0; i < dirs.length; ++i) { return Api.nodeFs.statSync(themeFolder + "/" + theme).isDirectory();
var dir = dirs[i]; // 名称 })
.forEach(function(theme) {
me._themeMap[dir] = { me._themeMap[theme] = {
name: dir, // 主题名称 name: theme, // 主题名称
dir: dir dir: theme
}; };
me._themes.push(me._themeMap[theme]);
me._themes.push(me._themeMap[dir]); });
}
}, },
// 改变主题 // 改变主题
@@ -48,7 +47,7 @@ define(function() {
var me = this; var me = this;
themeDir || (themeDir = 'default'); themeDir || (themeDir = 'default');
themeDir = themeDir.toLowerCase(); themeDir = themeDir.toLowerCase();
$('#md-theme').attr('href', 'public/md/themes/themes/' + themeDir + '/theme.css'); $('#md-theme').attr('href', 'public/themes/markdown/' + themeDir + '/index.css');
Config.mdTheme = themeDir; Config.mdTheme = themeDir;
var ok = Api.writeConfig(Config); var ok = Api.writeConfig(Config);