[fix] 子目录部署 loadScript, search (#264)

* 优化子目录部署资源问题

---------

Co-authored-by: 钟意 <thatcoder@163.com>
This commit is contained in:
钟意 2023-02-13 10:03:17 +08:00 committed by GitHub
parent d883483ec4
commit e0ee1d8198
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -62,6 +62,9 @@
// 从 butterfly 和 volantis 获得灵感
loadScript: (src, opt) => new Promise((resolve, reject) => {
var script = document.createElement('script');
if (src.startsWith('/')){
src = stellar.config.root + src.substring(1);
}
script.src = src;
if (opt) {
for (let key of Object.keys(opt)) {
@ -100,6 +103,7 @@
day: '<%- __('meta.date_suffix.day') %>',
month: '<%- __('meta.date_suffix.month') %>',
},
root : '<%- config.root %>',
};
// required plugins (only load if needs)

View File

@ -334,9 +334,10 @@ if (stellar.search.service) {
var $resultArea = document.querySelector("div#search-result");
$inputArea.focus(function() {
var path = stellar.search[stellar.search.service]?.path || '/search.json';
if (!path.startsWith('/')) {
path = '/' + path;
if (path.startsWith('/')) {
path = path.substring(1);
}
path = stellar.config.root + path;
const filter = $inputArea.attr('data-filter') || '';
searchFunc(path, filter, 'search-input', 'search-result');
});