xiangpei
2024-11-12 79b9c73e0717c244391ab1e15c6f6da9975f2610
打包bug
6个文件已修改
1 文件已重命名
37 ■■■■■ 已修改文件
.eslintrc.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.prettierrc.cjs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.html 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/ddlogin.js 补丁 | 查看 | 原始文档 | blame | 历史
src/permission.ts 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.ts 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dingdingLogin.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.eslintrc.js
@@ -19,6 +19,7 @@
  },
  plugins: ['vue', '@typescript-eslint'],
  rules: {
    "vue/comment-directive": "off",
    'vue/multi-word-component-names': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
.prettierrc.cjs
@@ -42,5 +42,13 @@
  // 然而在 Linux 和 Unix 中只使用简单的换行分隔符 (LF)。
  // 对应的控制字符为 "\n" (LF) 和 "\r\n"(CRLF)。auto意为保持现有的行尾
  // 换行符使用 lf 结尾是 可选值"<auto|lf|crlf|cr>"
  endOfLine: 'auto'
  endOfLine: 'auto',
  overrides: [
    {
      "files": "*.html",
      "options": {
        "parser": "html"
      }
    }
  ]
};
index.html
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
@@ -203,9 +202,6 @@
    }
  </style>
</head>
<script src="./src/assets/ddlogin.js"></script>
<!-- <script src="https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script> -->
<body>
  <div id="app">
    <div id="loader-wrapper">
@@ -217,5 +213,5 @@
  </div>
  <script type="module" src="/src/main.ts"></script>
</body>
  <script src="public/ddlogin.js"></script>
</html>
public/ddlogin.js
src/permission.ts
@@ -52,7 +52,7 @@
    }
  } else {
    // 没有token
    console.log("没有token");
    console.log('没有token');
    if (whiteList.indexOf(to.path) !== -1) {
      // 在免登录白名单,直接进入
      next();
@@ -67,14 +67,14 @@
  NProgress.done();
});
const judge = (token: string) => {
const judge = (token: string | null) => {
  if (token) {
    var data = JSON.parse(token)
    const data = JSON.parse(token);
    if (data != null) {
      if (data.expirse != null && new Date().getTime() - data.expirse < 60 * 60 * 1000) {
        return true
        return true;
      }
    }
  }
  return false
}
  return false;
};
src/utils/request.ts
@@ -47,6 +47,7 @@
    }
    // get请求映射params参数
    if (config.method === 'get' && config.params) {
      console.log(config.params, '请求参数');
      let url = config.url + '?' + tansParams(config.params);
      url = url.slice(0, -1);
      config.params = {};
@@ -78,6 +79,7 @@
    }
    // 当开启参数加密
    if (isEncrypt && (config.method === 'post' || config.method === 'put' || config.method === 'get')) {
      console.log('开启了参数加密');
      // 生成一个 AES 密钥
      const aesKey = generateAesKey();
      config.headers['encrypt-key'] = encrypt(encryptBase64(aesKey));
@@ -90,7 +92,7 @@
    return config;
  },
  (error: any) => {
    console.log(error);
    console.log(error, 'wcs');
    return Promise.reject(error);
  }
);
src/views/dingdingLogin.vue
@@ -26,7 +26,7 @@
        setToken(JSON.stringify(data));
        window.location.href = '/index';
      } else {
        ElMessage({ message: '登录失败', type: 'error' });
        ElMessage({ message: '无权访问', type: 'error' });
        setTimeout(() => {
          window.location.href = '/login';
        }, 3000);
@@ -47,7 +47,7 @@
  } else {
    var mode = 'openid corpid';
    window.location.href =
      'https://login.dingtalk.com/oauth2/auth?redirect_uri=http://127.0.0.1:81/login&response_type=code&client_id=dingl5dxahaj3uzfug66&scope=' +
      'https://login.dingtalk.com/oauth2/auth?redirect_uri=http://171.221.173.53:8801/login&response_type=code&client_id=dingl5dxahaj3uzfug66&scope=' +
      encodeURIComponent(mode) +
      '&state=dddd&prompt=consent';
    // // STEP3:在需要的时候,调用 window.DTFrameLogin 方法构造登录二维码,并处理登录成功或失败的回调。