This commit is contained in:
yuping
2022-12-14 17:07:10 +08:00
parent 76e64f8409
commit ae9ca0ad83
2 changed files with 31 additions and 36 deletions

View File

@@ -22,35 +22,28 @@
</router-link>
</div> -->
<main>
<router-view />
<router-view/>
</main>
</div>
</template>
<script>
import { computed, defineComponent } from "vue";
import { useRouter, useRoute } from "vue-router";
export default defineComponent({
setup() {
const router = useRouter();
const route = useRoute();
console.log("router", router.getRoutes(), route);
console.log(import.meta.env.DEV);
const routes = computed(() => {
return router.getRoutes().filter((e) => e.meta?.isLink);
});
<script setup>
const currentRouteName = computed(() => route.name);
import {boeRequest} from "@/api/request";
import {GET_USER_INFO} from "@/api/ThirdApi";
import { useStore } from "vuex";
import {onMounted} from "vue";
const store = useStore();
onMounted(()=>{
getUserInfo()
})
function getUserInfo(){
boeRequest(GET_USER_INFO).then(res=>{
store.commit("SET_USER", res.result);
})
}
// localStorage.setItem(
// "token",
// "eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NzA3NjExNzIsImV4cCI6MTY3MDc2ODM3MiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjZCMDQ5RkFGLUMzMTQtN0NDRi0wRDI4LTBEMjNGNEM0MjUzMSIsInVJZCI6Ijk2NTM0MjAyNzQ5NzYwNzE2OCIsInBlcm1pc3Npb24iOiIifQ==.9e8c4d3933c3a6d9b660e0b849940c813e1c245b3d17646ff7a793100640bc42"
// );
return {
routes,
name: currentRouteName,
};
},
});
</script>
<style lang="scss">
#app {
@@ -99,6 +92,7 @@ export default defineComponent({
}
}
}
main {
flex: 1;
width: 100%;

View File

@@ -1,14 +1,15 @@
import { createStore } from 'vuex'
import {createStore} from 'vuex'
export default createStore({
state: {
userInfo: {}
},
getters: {
},
getters: {},
mutations: {
SET_USER(state, userInfo) {
state.userInfo = userInfo
},
actions: {
},
modules: {
}
actions: {},
modules: {}
})