修改底部菜单传递type

v1.4.0
于肖磊 2025-06-11 12:03:31 +08:00
parent 9048c71d95
commit 3a427ae888
1 changed files with 22 additions and 2 deletions

View File

@ -38,7 +38,7 @@ onMounted(() => {
});
const is_empty = ref(false);
const init = () => {
DiyAPI.getTabbar({ type: 'home' })
DiyAPI.getTabbar({ type: get_type() })
.then((res: any) => {
if (res.data) {
let data = res.data;
@ -78,7 +78,7 @@ const save_disabled = ref(false);
const save_event = () => {
const clone_form = cloneDeep(form.value);
const new_data = {
type: 'home',
type: get_type(),
config: clone_form,
};
save_disabled.value = true;
@ -93,6 +93,26 @@ const save_event = () => {
save_disabled.value = false;
});
};
const get_type = () => {
let new_type = 'home';
if (document.location.search.indexOf('/type/') != -1) {
new_type = document.location.search.substring(document.location.search.indexOf('/type/') + 6);
// 3
const result1 = splitAndGetFirst(new_type, '/');
const result2 = splitAndGetFirst(result1, '&');
return splitAndGetFirst(result2, '#');
} else {
return new_type;
}
};
function splitAndGetFirst(str: string, separator: string): string {
const data = str.split(separator);
if (data.length > 1) {
return data[0];
} else {
return str;
}
}
//#endregion ---------------------end
</script>