Skip to content

Commit

Permalink
🐞 fix: 修复动态插件加载顺序问题
Browse files Browse the repository at this point in the history
  • Loading branch information
白云苍狗 committed Jan 5, 2023
1 parent 2f78869 commit 6245f97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package/hexo-theme-async/layout/_third-party/plugin.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ isSearch = theme.search.enable && theme.search.type === 'local'
%>
<%- js({src: theme.assets.plugin.katex.js,'data-swup-reload-script': true }) %>
<% if(theme.katex.copy_tex) {%>
<%- js({src: theme.assets.plugin.katex.copy_tex.js,'data-swup-reload-script': true }) %>
<%- js({src: theme.assets.plugin.katex.copy_tex,'data-swup-reload-script': true }) %>
<% } %>
<%- js({src: theme.assets.plugin.katex.auto_render,'data-swup-reload-script': true }) %>
<script data-swup-reload-script>
Expand Down
17 changes: 15 additions & 2 deletions package/hexo-theme-async/source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,24 @@
scriptBlock.push(item.innerText)
})

Promise.all(scriptCDN.map(item => this.loadScript(item))).then(_ => {
const run = async (cdns, blocks) => {
try {
var data = [];
for (var i = 0; i < cdns.length; i++) {
data.push(await this.loadScript(cdns[i]));
}
blocks.forEach(code => {
this.runScriptBlock(code)
})
} catch (e) {
}
}
run()
/* Promise.all(scriptCDN.map(item => this.loadScript(item))).then(_ => {
scriptBlock.forEach(code => {
this.runScriptBlock(code)
})
})
}) */
}
};

Expand Down

0 comments on commit 6245f97

Please sign in to comment.