[fix] 子目录部署 loadScript, search (#264)
* 优化子目录部署资源问题 --------- Co-authored-by: 钟意 <thatcoder@163.com>
This commit is contained in:
parent
d883483ec4
commit
e0ee1d8198
|
@ -62,6 +62,9 @@
|
||||||
// 从 butterfly 和 volantis 获得灵感
|
// 从 butterfly 和 volantis 获得灵感
|
||||||
loadScript: (src, opt) => new Promise((resolve, reject) => {
|
loadScript: (src, opt) => new Promise((resolve, reject) => {
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
|
if (src.startsWith('/')){
|
||||||
|
src = stellar.config.root + src.substring(1);
|
||||||
|
}
|
||||||
script.src = src;
|
script.src = src;
|
||||||
if (opt) {
|
if (opt) {
|
||||||
for (let key of Object.keys(opt)) {
|
for (let key of Object.keys(opt)) {
|
||||||
|
@ -100,6 +103,7 @@
|
||||||
day: '<%- __('meta.date_suffix.day') %>',
|
day: '<%- __('meta.date_suffix.day') %>',
|
||||||
month: '<%- __('meta.date_suffix.month') %>',
|
month: '<%- __('meta.date_suffix.month') %>',
|
||||||
},
|
},
|
||||||
|
root : '<%- config.root %>',
|
||||||
};
|
};
|
||||||
|
|
||||||
// required plugins (only load if needs)
|
// required plugins (only load if needs)
|
||||||
|
|
|
@ -334,9 +334,10 @@ if (stellar.search.service) {
|
||||||
var $resultArea = document.querySelector("div#search-result");
|
var $resultArea = document.querySelector("div#search-result");
|
||||||
$inputArea.focus(function() {
|
$inputArea.focus(function() {
|
||||||
var path = stellar.search[stellar.search.service]?.path || '/search.json';
|
var path = stellar.search[stellar.search.service]?.path || '/search.json';
|
||||||
if (!path.startsWith('/')) {
|
if (path.startsWith('/')) {
|
||||||
path = '/' + path;
|
path = path.substring(1);
|
||||||
}
|
}
|
||||||
|
path = stellar.config.root + path;
|
||||||
const filter = $inputArea.attr('data-filter') || '';
|
const filter = $inputArea.attr('data-filter') || '';
|
||||||
searchFunc(path, filter, 'search-input', 'search-result');
|
searchFunc(path, filter, 'search-input', 'search-result');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue