Skip to content

Commit

Permalink
Merge pull request #11263 from vhwweng/issue_10938
Browse files Browse the repository at this point in the history
fix: 版本日志切换环境弹框弹出问题修复 #10938
  • Loading branch information
bkci-bot authored Nov 29, 2024
2 parents e026964 + d9aef08 commit 5e73e74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/frontend/devops-nav/src/components/SystemLog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@
async fetchData () {
const requestHandler = this.$i18n.locale === 'en-US' ? 'fetchVersionsLogListEn' : 'fetchVersionsLogList'
const res = await this.$store.dispatch(requestHandler)
this.list = res || []
this.list = res.data || []
this.latestVerSion = (this.list.length && this.list[0].version) || ''
const curVerSion = localStorage.getItem('bk_latest_version')
if (curVerSion !== this.latestVerSion && this.list.length) {
if (res.dialogVisible && curVerSion !== this.latestVerSion && this.list.length) {
localStorage.setItem('bk_latest_version', this.latestVerSion)
this.toggleShowLog(true)
}
Expand All @@ -113,6 +113,9 @@
</script>
<style lang='scss'>
.system-log-dialog {
.bk-dialog {
top: 15% !important;
}
.bk-dialog-tool,
.bk-dialog-header {
display: none;
Expand Down
9 changes: 7 additions & 2 deletions src/frontend/devops-nav/src/store/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ActionTree, ActionContext } from 'vuex'
import { AxiosRequestConfig } from 'axios'
import Request from '../utils/request'
import { transformObj } from '../utils/util'
import {
Expand Down Expand Up @@ -168,11 +169,15 @@ const actions: ActionTree<RootState, any> = {
},

fetchVersionsLogList () {
return Request.get(`${window.location.origin}/bundledVersionLog.json?t=${Date.now()}`)
return Request.get(`${window.location.origin}/bundledVersionLog.json?t=${Date.now()}`, {
originalResponse: true
} as AxiosRequestConfig & { originalResponse: boolean })
},

fetchVersionsLogListEn () {
return Request.get(`${window.location.origin}/bundledVersionLog_en.json?t=${Date.now()}`)
return Request.get(`${window.location.origin}/bundledVersionLog_en.json?t=${Date.now()}`, {
originalResponse: true
} as AxiosRequestConfig & { originalResponse: boolean })
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/frontend/devops-nav/src/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { showLoginPopup } from '@/utils/util'
import axios, { AxiosError, AxiosResponse, CreateAxiosDefaults } from 'axios'
import Vue from 'vue'

declare module 'axios' {
export interface AxiosRequestConfig {
originalResponse?: boolean;
}
}
const request = axios.create({
baseURL: API_URL_PREFIX,
maxRedirects: 0,
Expand All @@ -25,6 +29,7 @@ function errorHandler (error: AxiosError) {
}

request.interceptors.response.use((response: AxiosResponse) => {
const originalResponse = response.config.originalResponse || false
const { data: { code, data, message, status }, status: httpStatus } = response

if (httpStatus === 401) {
Expand All @@ -50,7 +55,7 @@ request.interceptors.response.use((response: AxiosResponse) => {
return Promise.reject(errorMsg)
}

return data
return originalResponse ? response.data : data
}, errorHandler)

Vue.prototype.$ajax = request
Expand Down

0 comments on commit 5e73e74

Please sign in to comment.