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> </router-link>
</div> --> </div> -->
<main> <main>
<router-view /> <router-view/>
</main> </main>
</div> </div>
</template> </template>
<script> <script setup>
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);
});
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> </script>
<style lang="scss"> <style lang="scss">
#app { #app {
@@ -99,6 +92,7 @@ export default defineComponent({
} }
} }
} }
main { main {
flex: 1; flex: 1;
width: 100%; width: 100%;

View File

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