fix: 登录后保存role,API请求携带X-User-Role头
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -6,6 +6,7 @@ const request = (url, method, query = {}, data = {}) => {
|
||||
const token = uni.getStorageSync('token')
|
||||
const userId = uni.getStorageSync('userId') || ''
|
||||
const username = uni.getStorageSync('username') || ''
|
||||
const role = uni.getStorageSync('role') || ''
|
||||
|
||||
// 特殊情况:入库和库存调整需要 form-urlencoded 格式
|
||||
const useFormData = (url.includes('/stock/in') || url.includes('/stock/adjust')) && Object.keys(data).length > 0
|
||||
@@ -27,7 +28,8 @@ const request = (url, method, query = {}, data = {}) => {
|
||||
'Content-Type': useFormData ? 'application/x-www-form-urlencoded' : 'application/json',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
'X-User-Id': userId,
|
||||
'X-Username': username
|
||||
'X-Username': username,
|
||||
'X-User-Role': role
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.code === 0) {
|
||||
|
||||
Reference in New Issue
Block a user