diff --git a/packages/devops-admin/src/api/func.js b/packages/devops-admin/src/api/func.js index 7870c4b545..94896f82bc 100644 --- a/packages/devops-admin/src/api/func.js +++ b/packages/devops-admin/src/api/func.js @@ -5,9 +5,12 @@ import request from '@/utils/request' */ export function launchFunction(functionName, data, debug = false) { return request({ - url: `/app/func/invoke/${functionName}?debug=${debug}`, + url: `/app/func/invoke/${functionName}`, method: 'post', - data: data + data: data, + headers: { + 'debug-token': debug + } }) } diff --git a/packages/devops-admin/src/store/modules/user.js b/packages/devops-admin/src/store/modules/user.js index 449a933a49..e55c96d35a 100644 --- a/packages/devops-admin/src/store/modules/user.js +++ b/packages/devops-admin/src/store/modules/user.js @@ -1,5 +1,5 @@ import { login, getInfo } from '@/api/user' -import { getToken, setToken, removeToken } from '@/utils/auth' +import { getToken, setToken, removeToken, setDebugToken, removeDebugToken } from '@/utils/auth' import router, { resetRouter } from '@/router' const state = { @@ -41,6 +41,9 @@ const actions = { const { data } = response commit('SET_TOKEN', data.access_token) setToken(data.access_token, data.expire) + if (data.debug_token) { + setDebugToken(data.debug_token) + } resolve() }).catch(error => { reject(error) @@ -88,6 +91,7 @@ const actions = { commit('SET_PERMISSIONS', []) removeToken() + removeDebugToken() resetRouter() // reset visited views and cached views diff --git a/packages/devops-admin/src/utils/auth.js b/packages/devops-admin/src/utils/auth.js index 4f6eb4fa53..6073b4f7e1 100644 --- a/packages/devops-admin/src/utils/auth.js +++ b/packages/devops-admin/src/utils/auth.js @@ -8,6 +8,7 @@ export function getToken() { if (!expire || expire <= Date.now() / 1000) { removeToken() + removeDebugToken() } return token @@ -22,3 +23,19 @@ export function removeToken() { localStorage.removeItem(kExpire) return localStorage.removeItem(kToken) } + +/** + * 获取调试云函数的 token + */ +export function getDebugToken() { + const token = localStorage.getItem('debug_token') + return token +} + +export function setDebugToken(token) { + return localStorage.setItem('debug_token', token) +} + +export function removeDebugToken() { + return localStorage.removeItem('debug_token') +} diff --git a/packages/devops-admin/src/views/database/policy.vue b/packages/devops-admin/src/views/database/policy.vue index 63bc2ccdb2..b468b36a7f 100644 --- a/packages/devops-admin/src/views/database/policy.vue +++ b/packages/devops-admin/src/views/database/policy.vue @@ -17,7 +17,7 @@