fix(admin): restore session via /auth/me in router guard (refresh no longer logs out); simplify member price table (no title/source/action columns)
This commit is contained in:
@@ -32,10 +32,15 @@ const router = createRouter({
|
||||
routes,
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
router.beforeEach(async (to) => {
|
||||
const authStore = useAuthStore()
|
||||
const isPublic = to.meta?.public === true
|
||||
|
||||
// 会话在 HttpOnly cookie 里:刷新后先经 /auth/me 恢复登录态,再判定是否放行
|
||||
if (!authStore.isLoggedIn && !isPublic) {
|
||||
await authStore.ensureSessionChecked()
|
||||
}
|
||||
|
||||
if (!authStore.isLoggedIn && !isPublic) {
|
||||
return { path: '/login', replace: true }
|
||||
}
|
||||
|
||||
@@ -264,20 +264,6 @@ async function saveMemberPrices(row: { id: string }) {
|
||||
} finally { memberPriceSaving.value = '' }
|
||||
}
|
||||
|
||||
async function resetMemberPrice(row: { id: string }, cell: any) {
|
||||
memberPriceSaving.value = row.id
|
||||
try {
|
||||
await productFamiliesApi.deleteOverrides(editFamilyId.value, [
|
||||
{ sizeId: cell.sizeId, colorId: cell.colorId, craft: cell.craft, logistics: cell.logistics },
|
||||
])
|
||||
ElMessage.success('已恢复推导价')
|
||||
await loadEditFamily()
|
||||
emit('changed')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || '恢复失败')
|
||||
} finally { memberPriceSaving.value = '' }
|
||||
}
|
||||
|
||||
function initEditFamily(family: { familyId?: string; familyCode?: string | null } | null) {
|
||||
editFamilyId.value = family?.familyId ?? ''
|
||||
editFamilyCode.value = family?.familyCode ?? null
|
||||
@@ -610,7 +596,6 @@ async function handleDeleteGood() {
|
||||
</div>
|
||||
<div v-if="row.craftLabel && row.logisticsLabel" class="member-price-block">
|
||||
<div class="member-price-head">
|
||||
<span class="md-label">尺码 × 颜色 → 价格</span>
|
||||
<el-button size="small" type="primary" :loading="memberPriceSaving === row.id" @click="saveMemberPrices(row)">保存价格</el-button>
|
||||
</div>
|
||||
<el-table :data="memberPrices[row.id] ?? []" border size="small" max-height="240">
|
||||
@@ -621,17 +606,6 @@ async function handleDeleteGood() {
|
||||
<el-input v-model="cell.editPrice" size="small" @input="cell.editPrice = String(cell.editPrice)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="来源" width="120">
|
||||
<template #default="{ row: cell }">
|
||||
<el-tag v-if="cell.manual" size="small" type="warning">人工改价</el-tag>
|
||||
<span v-else class="md-val">链接价</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80">
|
||||
<template #default="{ row: cell }">
|
||||
<el-button v-if="cell.manual" size="small" link :loading="memberPriceSaving === row.id" @click="resetMemberPrice(row, cell)">还原</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div v-if="row.source === 'SDS'" class="member-extra">
|
||||
@@ -836,7 +810,7 @@ async function handleDeleteGood() {
|
||||
.member-tags-edit { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
|
||||
.member-tags-edit .md-label { flex-shrink: 0; }
|
||||
.member-price-block { border-top: 1px dashed #e4e7ed; padding-top: 8px; }
|
||||
.member-price-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
|
||||
.member-price-head { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 6px; }
|
||||
.member-extra { border-top: 1px dashed #e4e7ed; padding-top: 8px; }
|
||||
.md-empty {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 8px;
|
||||
|
||||
Reference in New Issue
Block a user