acdr-ui/dist/dev/mp-weixin/store/routers.js
2024-10-01 09:15:35 +08:00

57 lines
1.7 KiB
JavaScript

"use strict";
const common_vendor = require("../common/vendor.js");
const useRoutersStore = common_vendor.defineStore(
"routers",
() => {
const tabList = common_vendor.ref([
{
text: "首页",
iconPath: "/static/tabbar/home.png",
selectedIconPath: "/static/tabbar/homeL.png",
pagePath: "/pages/index/index"
},
{
iconPath: "/static/tabbar/space.png",
selectedIconPath: "/static/tabbar/spaceL.png",
pagePath: "/modules/pet/space/index",
text: "互动空间"
},
{
iconPath: "/static/tabbar/24gl-paperPlane.png",
selectedIconPath: "/static/tabbar/24gl-paperPlaneL.png",
pagePath: "/modules/pet/push/index",
text: "发布"
},
{
iconPath: "/static/tabbar/message.png",
selectedIconPath: "/static/tabbar/messageL.png",
pagePath: "/modules/pet/message/index",
text: "消息"
},
{
iconPath: "/static/tabbar/my.png",
selectedIconPath: "/static/tabbar/myL.png",
pagePath: "/modules/pet/my/index",
text: "我的"
}
]);
const selected = common_vendor.ref(0);
const currentTab = common_vendor.ref(tabList.value[0].pagePath);
const setCurrentTab = (pagePath) => {
currentTab.value = pagePath;
selected.value = getCurrentTabIndex.value;
};
const getCurrentTabIndex = common_vendor.computed(() => {
return tabList.value.findIndex((item) => item.pagePath === currentTab.value);
});
return {
tabList,
currentTab,
setCurrentTab,
selected
};
},
{ persist: true }
);
exports.useRoutersStore = useRoutersStore;