华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

367 lines
6.9 KiB

  1. <template>
  2. <div id="app">
  3. <router-view />
  4. <theme-picker />
  5. </div>
  6. </template>
  7. <script>
  8. import ThemePicker from "@/components/ThemePicker"
  9. import { checkStatus } from "@/api/system/user"
  10. export default {
  11. name: "App",
  12. components: { ThemePicker },
  13. data() {
  14. return {
  15. statusCheckTimer: null
  16. }
  17. },
  18. computed: {
  19. // // 监听登录状态
  20. // isLoggedIn() {
  21. // return this.$store.getters.token && this.$store.getters.token !== ''
  22. // }
  23. },
  24. watch: {
  25. // // 监听登录状态变化
  26. // isLoggedIn(newVal, oldVal) {
  27. // console.log('登录状态变化:', newVal, oldVal)
  28. // if (newVal) {
  29. // // 用户已登录,启动轮询
  30. // this.startStatusCheck()
  31. // } else {
  32. // // 用户已退出,停止轮询
  33. // this.stopStatusCheck()
  34. // }
  35. // },
  36. // 监听token
  37. '$store.getters.token': {
  38. handler(newToken, oldToken) {
  39. console.log('token变化:', newToken, oldToken)
  40. if (newToken) {
  41. // 有token,启动轮询
  42. this.startStatusCheck()
  43. } else {
  44. // token为空,停止轮询
  45. this.stopStatusCheck()
  46. }
  47. },
  48. immediate: true // 立即执行一次,这样在页面刷新时,如果已经有token,就会启动轮询
  49. }
  50. },
  51. mounted() {
  52. // // 页面加载时检查当前登录状态
  53. // if (this.isLoggedIn) {
  54. // this.startStatusCheck()
  55. // }
  56. },
  57. beforeDestroy() {
  58. this.stopStatusCheck()
  59. },
  60. methods: {
  61. startStatusCheck() {
  62. // 先停止可能存在的定时器
  63. this.stopStatusCheck()
  64. console.log('启动状态检查轮询')
  65. // 立即执行一次检查
  66. this.checkStatusImmediate()
  67. // 设置定时器每秒检查一次
  68. this.statusCheckTimer = setInterval(() => {
  69. this.checkStatus()
  70. }, 10000)
  71. },
  72. stopStatusCheck() {
  73. if (this.statusCheckTimer) {
  74. console.log('停止状态检查轮询')
  75. clearInterval(this.statusCheckTimer)
  76. this.statusCheckTimer = null
  77. }
  78. },
  79. // 立即检查(不等待)
  80. async checkStatusImmediate() {
  81. await this.checkStatus()
  82. },
  83. // 定时检查
  84. async checkStatus() {
  85. // 再次确认登录状态
  86. // if (!this.isLoggedIn) {
  87. // this.stopStatusCheck()
  88. // return
  89. // }
  90. try {
  91. console.log('开始checkStatus')
  92. checkStatus().then(response => {
  93. console.log(JSON.stringify(response))
  94. }).catch(err => {
  95. console.log(JSON.stringify(err))
  96. // if (err === '无效的会话,或者会话已过期,请重新登录。') {
  97. if (err === this.$t('system.timeOutTip')) {
  98. this.stopStatusCheck()
  99. }
  100. })
  101. } catch (error) {
  102. }
  103. },
  104. }
  105. }
  106. </script>
  107. <style rel="stylesheet/scss" lang="scss">
  108. #app .theme-picker {
  109. display: none;
  110. }
  111. .el-dialog__header {
  112. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1) !important;
  113. }
  114. .el-dialog__footer {
  115. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1) !important;
  116. }
  117. .el-dialog__body {
  118. padding: 10px 10px;
  119. }
  120. /*搜索区域样式 */
  121. .search-area {
  122. input {
  123. width: 150px;
  124. }
  125. }
  126. .el-tabs--border-card>.el-tabs__content {
  127. padding: 0px 0px;
  128. }
  129. /*详情 */
  130. .detail-container {
  131. background: #ffffff !important;
  132. .detail-top {
  133. background: #fff;
  134. padding: 10px 20px;
  135. margin-bottom: 10px;
  136. display: flex;
  137. flex-direction: row;
  138. align-items: center;
  139. justify-content: space-between;
  140. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  141. .left-top {
  142. flex-shrink: 0;
  143. display: flex;
  144. flex-direction: row;
  145. align-items: center;
  146. img {
  147. height: 16px;
  148. margin-right: 10px;
  149. cursor: pointer;
  150. }
  151. .right-top {}
  152. }
  153. }
  154. .detail-title {
  155. line-height: 60px;
  156. font-size: 16px;
  157. font-weight: bold;
  158. width: 100%;
  159. margin-top: 10px;
  160. display: flex;
  161. justify-content: center;
  162. }
  163. .detail-content {
  164. padding: 10px 10px;
  165. display: flex;
  166. justify-content: space-between;
  167. .content-right {
  168. width: 33%;
  169. margin-left: 2%;
  170. padding: 0px 10px;
  171. border-left: 1px solid #d0d0d0;
  172. }
  173. .content-left {
  174. width: 65%;
  175. }
  176. .content {
  177. width: 100%;
  178. }
  179. .content-title {
  180. width: 100%;
  181. background: #f9f9ff;
  182. font-size: 0.96rem;
  183. font-weight: bold;
  184. padding-left: 10px;
  185. height: 40px;
  186. line-height: 40px;
  187. display: flex;
  188. justify-content: flex-start;
  189. text-align: left;
  190. .line {
  191. width: 2px;
  192. float: left;
  193. height: 16px;
  194. margin-top: 12px;
  195. margin-right: 8px;
  196. border-left: #3178ff 3px solid;
  197. }
  198. .subtitle {
  199. height: 40px;
  200. line-height: 40px;
  201. color: #464647 !important;
  202. }
  203. }
  204. .pal {
  205. display: flex;
  206. justify-content: space-between;
  207. margin: 10px 0px;
  208. .left {
  209. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  210. margin: 5px 5px 5px 0px;
  211. width: 50%;
  212. padding: 10px 10px;
  213. border-radius: 5px 5px;
  214. .left-title {
  215. height: 40px;
  216. line-height: 40px;
  217. }
  218. }
  219. .right {
  220. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  221. margin: 5px 0px 5px 5px;
  222. width: 50%;
  223. padding: 10px 10px;
  224. border-radius: 5px 5px;
  225. .right-title {
  226. height: 40px;
  227. line-height: 40px;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. /*稽查轨迹list */
  234. .jcgjList {
  235. padding: 20px 0px;
  236. .jcgjList-keywords {
  237. width: 100%;
  238. }
  239. .jcgjList-jcgjlx {
  240. height: 50px;
  241. margin: 10px 0px;
  242. }
  243. .jcgjList-content {
  244. width: 100%;
  245. }
  246. .jcgjList-title {
  247. display: flex;
  248. justify-content: space-between;
  249. margin-top: -15px;
  250. .jcgjList-jcmc {
  251. font-size: 16px;
  252. font-weight: bold;
  253. }
  254. }
  255. .jcglList-jcnr {
  256. line-height: 25x;
  257. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  258. padding: 10px 10px;
  259. margin-top: 10px;
  260. }
  261. }
  262. /** 基础信息设置tab **/
  263. .edit-container {
  264. background: #ffffff !important;
  265. .edit-top {
  266. background: #fff;
  267. padding: 10px 20px;
  268. margin-bottom: 10px;
  269. display: flex;
  270. flex-direction: row;
  271. align-items: center;
  272. justify-content: space-between;
  273. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  274. .left-top {
  275. flex-shrink: 0;
  276. display: flex;
  277. flex-direction: row;
  278. align-items: center;
  279. img {
  280. height: 16px;
  281. margin-right: 10px;
  282. cursor: pointer;
  283. }
  284. }
  285. .center-top {
  286. display: flex;
  287. justify-content: space-between;
  288. height: 24px;
  289. .is-finish {
  290. background: #409eff;
  291. border: none;
  292. color: #fff;
  293. }
  294. .line {
  295. height: 0px;
  296. width: 100px;
  297. margin-top: 12px;
  298. margin-left: 5px;
  299. margin-right: 5px;
  300. border-top: 1px solid #d0d0d0;
  301. }
  302. }
  303. .right-top {}
  304. }
  305. }
  306. </style>