ALIEZ hai 3 semanas
pai
achega
839610e82f
Modificáronse 5 ficheiros con 37 adicións e 11 borrados
  1. BIN=BIN
      dist.tar.gz
  2. 6 1
      src/api/request.ts
  3. 11 3
      src/api/types.ts
  4. 15 6
      src/views/LoginView.vue
  5. 5 1
      src/views/courses/GoodsVideoManageModal.vue

BIN=BIN
dist.tar.gz


+ 6 - 1
src/api/request.ts

@@ -74,7 +74,12 @@ function unwrapData<T>(response: AxiosResponse<unknown>): T {
       message.error(msg)
       return Promise.reject(new Error(msg)) as never
     }
-    return body.data as T
+    const data = body.data
+    const pageMeta = (body as { page?: unknown }).page
+    if (Array.isArray(data) && pageMeta !== null && typeof pageMeta === 'object') {
+      return { list: data, page: pageMeta } as T
+    }
+    return data as T
   }
   return body as T
 }

+ 11 - 3
src/api/types.ts

@@ -26,7 +26,14 @@ export function isApiEnvelope(x: unknown): x is ApiEnvelope {
 /** 业务成功码:按你的后端约定改,例如 0 / 200 */
 export const SUCCESS_CODES = new Set([0, 200])
 
-/** 兼容 list / records、total / totalCount 等常见分页字段 */
+function totalFromPageMeta(page: unknown, fallback: number): number {
+  if (page === null || typeof page !== 'object') return fallback
+  const p = page as Record<string, unknown>
+  const totalRaw = p.rowTotal ?? p.total ?? p.totalCount ?? p.totalElements
+  return typeof totalRaw === 'number' ? totalRaw : fallback
+}
+
+/** 兼容 list / records、total / totalCount、page.rowTotal 等常见分页字段 */
 export function unwrapPageList<T>(res: unknown): { list: T[]; total: number } {
   if (Array.isArray(res)) return { list: res as T[], total: res.length }
   if (res !== null && typeof res === 'object') {
@@ -34,8 +41,9 @@ export function unwrapPageList<T>(res: unknown): { list: T[]; total: number } {
     const rawList = o.list ?? o.records
     const list = Array.isArray(rawList) ? (rawList as T[]) : []
     const totalRaw = o.total ?? o.totalCount ?? o.totalElements
-    const total = typeof totalRaw === 'number' ? totalRaw : list.length
-    return { list, total }
+    if (typeof totalRaw === 'number') return { list, total: totalRaw }
+    if ('page' in o) return { list, total: totalFromPageMeta(o.page, list.length) }
+    return { list, total: list.length }
   }
   return { list: [], total: 0 }
 }

+ 15 - 6
src/views/LoginView.vue

@@ -11,8 +11,8 @@ const formRef = ref<FormInst | null>(null)
 const loading = ref(false)
 
 const form = reactive({
-  loginName: 'admin',
-  password: '123456',
+  loginName: '',
+  password: '',
 })
 
 const rules: FormRules = {
@@ -21,7 +21,11 @@ const rules: FormRules = {
 }
 
 async function handleSubmit() {
-  await formRef.value?.validate()
+  try {
+    await formRef.value?.validate()
+  } catch {
+    return
+  }
   loading.value = true
   try {
     const { token } = await login({
@@ -58,7 +62,12 @@ async function handleSubmit() {
       </div>
       <NForm ref="formRef" :model="form" :rules="rules" size="large" class="login-form">
         <NFormItem path="loginName" label="账号">
-          <NInput v-model:value="form.loginName" placeholder="登录名" autocomplete="username" />
+          <NInput
+            v-model:value="form.loginName"
+            placeholder="登录名"
+            autocomplete="off"
+            @keydown.enter.prevent="handleSubmit"
+          />
         </NFormItem>
         <NFormItem path="password" label="密码">
           <NInput
@@ -66,12 +75,12 @@ async function handleSubmit() {
             type="password"
             show-password-on="click"
             placeholder="密码"
-            autocomplete="current-password"
+            autocomplete="off"
             @keydown.enter.prevent="handleSubmit"
           />
         </NFormItem>
         <NFormItem>
-          <NButton type="primary" block :loading="loading" attr-type="button" @click="handleSubmit">
+          <NButton type="primary" block :loading="loading" @click="handleSubmit">
             登录
           </NButton>
         </NFormItem>

+ 5 - 1
src/views/courses/GoodsVideoManageModal.vue

@@ -487,6 +487,7 @@ const { visibleKeys: videoVisibleKeys, displayColumns: videoDisplayColumns, colu
           :loading="videoLoading"
           :bordered="false"
           :single-line="false"
+          flex-height
           class="data-table-fill"
           :scroll-x="1200"
         />
@@ -644,14 +645,17 @@ const { visibleKeys: videoVisibleKeys, displayColumns: videoDisplayColumns, colu
   flex-direction: column;
   gap: 12px;
   width: 100%;
+  height: min(72vh, 720px);
   min-height: 420px;
   max-height: min(72vh, 720px);
 }
 
 .video-manage-table {
   flex: 1;
-  min-height: 200px;
+  min-height: 0;
   overflow: hidden;
+  display: flex;
+  flex-direction: column;
 }
 
 .video-upload-hint {