北京经济技术开发区经开区虚拟城市项目-【前端】-Web
lixuliang
2023-11-14 c8fddf98e955ffa92c8730b506b792e008c49043
ca登录
已修改5个文件
30 ■■■■■ 文件已修改
config/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/login.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/map/viewer.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/map/viewer1.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/index.js
@@ -13,7 +13,7 @@
    proxyTable: {},
    // Various Dev Server settings
    host: 'localhost', // can be overwritten by process.env.HOST
    host: '0.0.0.0', // can be overwritten by process.env.HOST
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
src/components/login.vue
@@ -204,6 +204,8 @@
          CAloading.close();
          if (res.code == 200) {
            let tokenData = res.token;
            let times = new Date().getTime();
            window.localStorage.setItem("TokenTime", times);
            window.localStorage.setItem("TokenKey", tokenData);
            this.$router.push("/index");
          } else {
@@ -231,6 +233,8 @@
          JBloading.close();
          if (res.code == 200) {
            let tokenData = res.token;
            let times = new Date().getTime();
            window.localStorage.setItem("TokenTime", times);
            window.localStorage.setItem("TokenKey", tokenData);
            this.$router.push("/index");
          } else {
src/components/map/viewer.vue
@@ -93,8 +93,8 @@
      window.sgworld = new SmartEarth.EarthCtrl(
        "sdkContainer",
        {
          StaticFileBaseUrl: "../../../static/CimSDK/",
          // StaticFileBaseUrl: "../../../SW/static/CimSDK/",
          // StaticFileBaseUrl: "../../../static/CimSDK/",
          StaticFileBaseUrl: "../../../SW/static/CimSDK/",
        },
        {},
        {},
src/components/map/viewer1.vue
@@ -298,8 +298,8 @@
      window.sgworld1 = new SmartEarth.EarthCtrl(
        "sdkContainer1",
        {
          StaticFileBaseUrl: "../../static/CimSDK/",
          // StaticFileBaseUrl: "../../../SW/static/CimSDK/",
          // StaticFileBaseUrl: "../../static/CimSDK/",
          StaticFileBaseUrl: "../../../SW/static/CimSDK/",
        },
        {},
        null,
src/router/index.js
@@ -31,25 +31,29 @@
const router = new Router({
  mode: "history",
  // base: '/YZXNCS',//正式版 打包时解开
  // base: '/SW',//测试版 打包时解开
  base: '/SW',//测试版 打包时解开
  routes,
});
router.beforeEach((to, from, next) => {
  // next();
  if (to.path === "/login") {    //去登录页,直接跳转
  // next();
  // 去登录页,直接跳转
  if (to.path === "/login") {
    next();
  } else { //去index,判断token
  } else {
    //去index,判断token
    let token = localStorage.getItem("TokenKey");
    if (token === null || token === "") { // 没有token,去登陆页
      next("/login");
    } else {   // 有token,判断超时
    } else {
      // 有token,判断超时
      let TokenTime = window.localStorage.getItem("TokenTime");
      let nowTime = new Date().getTime()
      if (nowTime - TokenTime > 60 * 60 * 1000) { // 超过60分钟,去登陆页
        next("/login");
        localStorage.removeItem("TokenKey");
        localStorage.removeItem("TokenTime");
      } else {  // 去index,有token,没过期,进入系统
      } else {
        // 去index,有token,没过期,进入系统
        next();
      }