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,42 +22,35 @@
</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 {
// font-family: MicrosoftYaHei, Microsoft YaHei, Avenir, Helvetica, Arial,
// sans-serif;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
Microsoft YaHei, Arial, sans-serif;
Microsoft YaHei, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
@@ -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: {
},
getters: {
},
mutations: {
},
actions: {
},
modules: {
}
state: {
userInfo: {}
},
getters: {},
mutations: {
SET_USER(state, userInfo) {
state.userInfo = userInfo
},
},
actions: {},
modules: {}
})