Update app.js

This commit is contained in:
Anyon 2021-12-01 11:09:29 +08:00
parent 411d8fb3b3
commit 12d7e68036

View File

@ -1,23 +1,19 @@
/*! 脚本应用根路径 */ /*! 项目应用根路径 */
window.appRoot = (function (src) { window.appRoot = (function (script) {
return src.pop(), src.pop(), src.join('/') + '/'; let src = script.src.split('/').slice(3);
})(document.scripts[document.scripts.length - 1].src.split('/')); return src.pop(), src.pop(), '/' + src.join('/') + '/';
})(document.querySelector('script[src][type=module]:last-child'));
console.log('baseRoot', appRoot)
;(async () => { ;(async () => {
const options = { const options = {
moduleCache: { moduleCache: {
vue: Vue, less: less vue: Vue,
less: less
}, },
getFile(url) { getFile(url) {
console.log('load.file', url) if (!/^(https?:)?\/\//.test(url)) {
if (!/^https?:\/\//.test(url)) { url = (appRoot + url).replace(/\/+.?\/+/g, '/');
url = appRoot + url;
} }
url = url.replace(/\/+.\/+/g, '/');
console.log(url)
return fetch(url).then(res => { return fetch(url).then(res => {
if (res.ok) { if (res.ok) {
return {getContentData: binary => binary ? res.arrayBuffer() : res.text()}; return {getContentData: binary => binary ? res.arrayBuffer() : res.text()};