import { useRoute } from "vue-router";
import { reactive } from "vue";
import { getNavInfoApi } from "../api/manage.js";
import { useStore } from "vuex";

export default function useTitleInfo() {
    const route = useRoute()
    const store = useStore()
    const titleInfo = reactive({
        title: '',
        subTitle: ''
    })
    console.log(route, store)
    const getTitle = () => {
        getNavInfoApi({
            title: store.getters.navList.find(it => it.link === route.path)?.title ?? ''
        }).then(res => {
            console.log('res', res)
            if (res.data) {
                titleInfo.title = res.data.title;
                titleInfo.subTitle = res.data.description;
            }
        })
    }
    getTitle();
    return titleInfo

}
