versions.ts 974 B

12345678910111213141516171819202122232425262728293031
  1. import { getVersions } from "@/services/login"
  2. import { Modal } from "antd"
  3. import React from 'react';
  4. //第一次登录
  5. async function versions() {
  6. let bdVersions = localStorage.getItem('versions') //本地
  7. let fwqVersions = ''//服务器版本
  8. let content = ''//版本更新内容
  9. await getVersions().then((res) => {
  10. if (res?.data) {
  11. fwqVersions = res?.data?.configValue
  12. content = res?.data?.remark?.replace(/\n/ig,'<br/>')
  13. }
  14. })
  15. if (fwqVersions && bdVersions !== fwqVersions) {//不一样
  16. //执行逻辑
  17. Modal.info({
  18. title: '版本更新!',
  19. content: React.createElement('div', { dangerouslySetInnerHTML: { __html: content } }),
  20. keyboard: false,
  21. cancelText: '稍后我自己刷新页面',
  22. okText: '现在就去刷新页面',
  23. onOk: () => {
  24. localStorage.setItem('versions', fwqVersions)//重新设置服务器版本
  25. location?.reload()
  26. },
  27. })
  28. }
  29. }
  30. export default versions