|
|
@@ -1,13 +1,29 @@
|
|
|
<script setup lang="ts">
|
|
|
- import { useRoute, useRouter } from 'vue-router'
|
|
|
+ import { useRoute } from 'vue-router'
|
|
|
import { useWarehouse } from './store'
|
|
|
- import { clearAuthInfo, clearOAuthTemp, getDisplayName } from './utils/auth'
|
|
|
+ import { clearAuthInfo, clearOAuthTemp, getDisplayName, getOAuthLogoutUrl, mockLogin } from './utils/auth'
|
|
|
import { House, Collection, Box, Download, Upload, Notebook, SwitchButton } from '@element-plus/icons-vue'
|
|
|
const faviconUrl = '/favicon.ico'
|
|
|
- const route = useRoute(); const router = useRouter()
|
|
|
+ const route = useRoute()
|
|
|
const warehouse = useWarehouse()
|
|
|
const links = [{ path: '/dashboard', name: '工作台', icon: House }, { path: '/master', name: '基础资料管理', icon: Collection }, { path: '/sku', name: '商品 / SKU 管理', icon: Box }, { path: '/inbound', name: '入库管理', icon: Download }, { path: '/outbound', name: '出库管理', icon: Upload }, { path: '/ledger', name: '库存台账', icon: Notebook }]
|
|
|
- function logout() { clearAuthInfo(); clearOAuthTemp(); sessionStorage.setItem('warehouse-auth-paused', '1'); router.push('/login') }
|
|
|
+ function logout() {
|
|
|
+ // 先清空本地所有缓存
|
|
|
+ sessionStorage.clear()
|
|
|
+ clearAuthInfo()
|
|
|
+ clearOAuthTemp()
|
|
|
+ // Mock 模式直接跳登录页;否则跳转到 OIDC 服务端登出,销毁 SSO 会话
|
|
|
+ if (mockLogin) {
|
|
|
+ location.hash = '#/login'
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ location.replace(getOAuthLogoutUrl())
|
|
|
+ } catch {
|
|
|
+ // 配置异常时回退到 forward.html
|
|
|
+ location.replace('/forward.html')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
const user = getDisplayName
|
|
|
const now = new Date()
|
|
|
const dateStr = new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: 'long', day: 'numeric' }).format(now)
|