<template>
    <div id="app" ref="app">
        <router-view></router-view>
    </div>
</template>

<script>
import user from "@/http/api/user";
import { setToken } from "@/utils/auth";
import { encrypt } from "@/utils/jsencrypt";
export default {
    name: "App",
    mounted() {
        // // INFO: 本地调试，自动登录
        if (process.env.NODE_ENV === 'development') {
            this.SubmitLogin();
        }
    },
    methods: {
        SubmitLogin() {
            const username = '50002100001';
            const password = '50002100001';
            const type = '2';
            sessionStorage.setItem('schoolType', type);
            user.loginEmailPass({
                username: username,
                password: encrypt(password),
            }).then((res) => {
                if (res.code === 200) {
                    this.$store.dispatch("user/CLEAR_LOCAL_STORAGE");//清空本地存储
                    setToken(res.data.tokenValue);
                    this.$store.dispatch("user/SET_TOKEN", res.data.tokenValue);
                    this.$store.dispatch("user/SET_SCHOOL_LOGO", res.data.schoolLogoUrl);//设置学校logo
                    this.$store.dispatch("user/SET_SCHOOL_WEB_SITE_ID", res.data.cloudMonitorSiteId || '');//设置学校网站id
                    this.$store.dispatch("user/getUserInfoByToken");//获取用户登录信息
                    this.$router.push("/studentAnalysisReport/list");
                }
            });
        },
    }
};
</script>

<style lang="scss">
@use "@/styles/setting.scss";

#app {
    height: 100%;
    width: 100%;
}
</style>
