Solve the problem that the front-end local test is OK, packaged and deployed to the production environment, but the logic is not updated.

Recently there is a need to implement single sign-on. The specific process is:

1. Log in to the main platform and get the ticket to log in to the sub-platform.

2. Log in to the sub-platform with the ticket and obtain permission to enter the sub-platform.

The occurrence of the problem is not directly related to the specific requirements. During the process of connecting with the backend, the post was changed to a get request, and the content-type in the request header was also modified. After the modification, local debugging is OK, but it is packaged and deployed to the production environment. , a strange thing happened: Although I have changed to get, and the request parameters have been changed from body to the content-type required by the background, the background of the production environment still receives the post and body parameters.

When I was at a loss, I asked a front-end boss friend for advice. He asked me if I had tried changing the function name, so I added a 1 to the function name of the calling interface, and then packaged it into the production environment... A miracle happened! problem solved!

It is speculated that the reason for this problem is that the deployment of the front-end package overwrites the original package. However, because the function names are the same, the logic of the production environment is not updated. This is really a sinkhole!

The following is the modified code, except that a '1' is added to 'ssoLogin'...

  methods: {
    ...mapActions(['Login', 'Logout']),

    ssoLogin1() {
      const {
        form: { validateFields },
        Login
      } = this
      Login(this.ticket)
        .then((res) => {
          // console.log('登录信息', res)
          this.loginSuccess(res)
        })
        .catch((err) => {
          console.log('login err', err)
          this.$message.error('跳转失败, 请重试')
        })
    },
    loginSuccess(res) {
      // console.info('登陆成功', res)
      this.$router.push({ path: '/oversystem/radar' })
      // 延迟 1 秒显示欢迎信息
      setTimeout(() => {
        this.$notification.success({
          message: '欢迎',
          description: `${timeFix()},欢迎回来`
        })
      }, 1000)
    },
  }

Although it is just a small trick, without enough development experience, the sinkholes I have stepped on are beyond my imagination. I lament the importance of experience!

Guess you like

Origin blog.csdn.net/hero8011/article/details/134825922