qx
3 天以前 3c1061b55683f3b6ff10dc8259c0b0179e2846e2
src/views/login.vue
@@ -1,7 +1,7 @@
<template>
  <div class="login">
    <!-- <div style="padding-top: 130px;"> -->
      <div style="font-weight: 700;font-size: 50px;">智能健康体检管理系统</div>
    <div style="font-weight: 700;font-size: 50px;">智能健康体检管理系统</div>
    <!-- </div> -->
@@ -58,17 +58,19 @@
    <!--  底部  -->
    <div class="el-login-footer">
      <span>Copyright © 2023-2024 All Rights Reserved.</span>
      <span>Copyright © 2024-2025 All Rights Reserved.</span>
      <!-- <span>Copyright © 2022-2023龙美网络 All Rights Reserved.</span> -->
    </div>
  </div>
</template>
<script>
import { getCodeImg, getconfigKey } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
import ini from 'ini';
import fs from 'fs'; // Node.js 文件系统模块
export default {
  name: "Login",
  data() {
@@ -78,6 +80,7 @@
        username: "",
        password: "",
        mobile: false,
        hospId: "",
        // username:"13800138008",
        // password:"888888",
        rememberMe: false,
@@ -136,6 +139,7 @@
  created() {
    this.getstate();
    this.getCookie();
    this.loadAll();
  },
  methods: {
    getstate() {
@@ -149,7 +153,34 @@
      })
    },
    loadAll() {
      const env = process.env.VUE_APP_ENV;
      const port = window.location.port;
      // yuanqu.ini加载hospId
      fetch('/yuanqu.ini')
        .then(response => {
          if (!response.ok) {
            throw new Error('Failed to fetch config.ini');
          }
          return response.text();
        })
        .then(text => {
          const config = ini.parse(text);
          if (config[env] && config[env][port]) {
            this.loginForm.hospId = config[env][port];
            Cookies.set("hospId", this.loginForm.hospId);
          } else {
            console.error(`No hospId found for environment ${env} and port ${port}`);
            this.$message.error(`配置错误:未找到环境 ${env} 和端口 ${port} 对应的医院ID`);
          }
        })
        .catch(error => {
          console.error('Error fetching or parsing config.ini:', error);
          this.$message.error('无法加载配置文件,请联系管理员');
        });
    },
    hide() {
      // this.loginForm.username = "10001";
      // this.loginForm.password = "admin123";
@@ -233,6 +264,7 @@
                }
              }
              this.$router.push({ path: this.redirect || "/" }).catch(() => { });
              location.reload();
            }
          }).catch(() => {