feat: R1 重构对称迁移 + 升级依赖 + 配置文件分离
- 命名重构:tenant → customer(对齐后端 R1 重构) - Tenant → Customer / tenant_id → customerId - tenantStore → customerStore / getTenant/setTenant → getCustomer/setCustomer - cookie key tenant → customer, HTTP header tenantId → customerId - 后端契约更新:AuthResponse 加 sub 字段 - 接口 URL 修复:/auth/oidc/callback → /api/v1/auth/oidc/callback - 依赖升级:vue 3.5 / element-plus 2.8 / vite 5 / typescript 5.6 / sass 1.79 - 删 node-sass / scss / sass-loader / moment / mock/index.ts - 配置文件拆分:.env.development / .env.production / .env.example - 删除冗余 view/auth/auth/callback.vue 副本 - .gitignore 增加 dist / .opencode / tmp - 新增 AGENT.md 与后端风格对齐
This commit is contained in:
+8
-8
@@ -1,24 +1,24 @@
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
const getToken = () => {
|
||||
const getToken = (): string | undefined => {
|
||||
return Cookies.get('token')
|
||||
}
|
||||
|
||||
const setToken = (token: String) => {
|
||||
const setToken = (token: string) => {
|
||||
Cookies.set('token', token)
|
||||
}
|
||||
|
||||
const setTenant = (tenant: object) => {
|
||||
Cookies.set('tenant', JSON.stringify(tenant))
|
||||
const setCustomer = (customer: object) => {
|
||||
Cookies.set('customer', JSON.stringify(customer))
|
||||
}
|
||||
|
||||
const getTenant = () => {
|
||||
return Cookies.get('tenant')
|
||||
const getCustomer = (): string | undefined => {
|
||||
return Cookies.get('customer')
|
||||
}
|
||||
|
||||
const resetToken = () => {
|
||||
Cookies.remove('token')
|
||||
Cookies.remove('tenant')
|
||||
Cookies.remove('customer')
|
||||
}
|
||||
|
||||
export { getToken, setToken, resetToken, setTenant, getTenant }
|
||||
export { getToken, setToken, resetToken, setCustomer, getCustomer }
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import router from '../router'
|
||||
import { getToken, getTenant, resetToken } from '../utils/auth'
|
||||
import { getToken, getCustomer, resetToken } from '../utils/auth'
|
||||
|
||||
// violin-wiki
|
||||
const service = axios.create(
|
||||
@@ -15,9 +15,9 @@ service.interceptors.request.use(
|
||||
if (typeof getToken() === 'string') {
|
||||
(config as any).headers['Authorization'] = 'Bearer:' + getToken()
|
||||
}
|
||||
const tenant = getTenant()
|
||||
if (typeof tenant === 'string') {
|
||||
(config as any).headers['tenantId'] = JSON.parse(tenant).tenant_id
|
||||
const customer = getCustomer()
|
||||
if (typeof customer === 'string') {
|
||||
(config as any).headers['customerId'] = JSON.parse(customer).customerId
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
Reference in New Issue
Block a user