Skip to content

Commit

Permalink
fix: sidebar with url scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
deot committed Sep 7, 2020
1 parent 543f133 commit 18fec98
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions packages/cli/src/client/components/sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,38 +96,42 @@ export default {
},
async loadNavs() {
const { sidebar } = this.$route.meta || {};
if (typeof sidebar === 'string') {
if (typeof sidebar !== 'string') {
this.navs = sidebar;
return;
}
let url = `${location.origin}${sidebar}`;
let data;
if (__DEV__) {
try {
data = (await this.$global.db.read(url) || {}).data;
} catch (e) {
console.log(e);
}
}
ajax({
url,
onAfter: ({ response }) => {
return {
status: 1,
data: response.data
};
},
localData: data
}).then((res) => {
this.navs = res.data;
__DEV__ && this.$global.db.update({
__id: url,
data: res
});
}).catch(e => {
let data;
let url = /[a-zA-z]+:\/\/[^\s]*/.test(sidebar)
? sidebar
: `${location.origin}${sidebar}`;
if (__DEV__) {
try {
data = (await this.$global.db.read(url) || {}).data;
} catch (e) {
console.log(e);
});
} else {
this.navs = sidebar;
}
}
ajax({
url,
onAfter: ({ response }) => {
return {
status: 1,
data: response.data
};
},
localData: data
}).then((res) => {
this.navs = res.data;
__DEV__ && this.$global.db.update({
__id: url,
data: res
});
}).catch(e => {
console.log(e);
});
}
}
};
Expand Down

0 comments on commit 18fec98

Please sign in to comment.