Bläddra i källkod

文件管理模块

王飞 1 år sedan
förälder
incheckning
11da2af2f0

+ 2 - 2
src/api/login/types.ts

@@ -1,10 +1,10 @@
 export type UserLoginType = {
-  username: string
+  account: string
   password: string
 }
 
 export type UserType = {
-  username: string
+  account: string
   password: string
   role: string
   roleId: string

+ 1 - 1
src/api/manage/file.ts

@@ -6,7 +6,7 @@ export const getTableListApi = (data: any) => {
 }
 
 export const delTableListApi = (id: string | number): Promise<IResponse> => {
-  return request.post({ url: `/sysApk/deleteApkById/${id}` })
+  return request.post({ url: `/api/sysApk/deleteApkById/${id}` })
 }
 
 export const saveTableApi = (data: any) => {

+ 8 - 2
src/components/TableSetting/src/TableSetting.vue

@@ -26,10 +26,16 @@ const columns: TableColumn[] = [
   },
   {
     field: 'table.hidden',
-    label: '隐藏',
+    label: '展示',
     slots: {
       default: (data: any) => {
-        return <ElSwitch v-model={data[0].row.table.hidden}></ElSwitch>
+        return (
+          <ElSwitch
+            v-model={data.row.table.hidden}
+            activeValue={false}
+            inactiveValue={true}
+          ></ElSwitch>
+        )
       }
     }
   }

+ 2 - 1
src/config/axios/config.ts

@@ -36,7 +36,7 @@ const config: AxiosConfig = {
   /**
    * 接口成功返回状态码
    */
-  code: 0,
+  code: '200',
 
   /**
    * 接口请求超时时间
@@ -91,6 +91,7 @@ const defaultRequestInterceptors = (config: InternalAxiosRequestConfig) => {
 }
 
 const defaultResponseInterceptors = (response: AxiosResponse<any>) => {
+  console.log(response)
   if (response?.config?.responseType === 'blob') {
     // 如果是文件流,直接过
     return response

+ 1 - 1
src/config/axios/service.ts

@@ -27,7 +27,7 @@ axiosInstance.interceptors.response.use(
   (res: AxiosResponse) => {
     const url = res.config.url || ''
     abortControllerMap.delete(url)
-    return res.data
+    return res
   },
   (err: any) => err
 )

+ 1 - 1
src/config/axios/types/index.ts

@@ -22,7 +22,7 @@ interface AxiosConfig<T = AxiosResponse> {
     pro: string
     test: string
   }
-  code: number
+  code: number|string
   defaultHeaders: AxiosHeaders
   timeout: number
   interceptors: RequestInterceptors<T>

+ 2 - 2
src/views/Login/components/LoginForm.vue

@@ -48,7 +48,7 @@ const schema = reactive<FormSchema[]>([
     }
   },
   {
-    field: 'username',
+    field: 'account',
     label: t('login.username'),
     value: 'admin',
     component: 'Input',
@@ -62,7 +62,7 @@ const schema = reactive<FormSchema[]>([
   {
     field: 'password',
     label: t('login.password'),
-    value: 'admin',
+    value: '123456',
     component: 'InputPassword',
     colProps: {
       span: 24

+ 32 - 19
src/views/Manage/File/FilePage.vue

@@ -2,7 +2,7 @@
 import { ContentWrap } from '@/components/ContentWrap'
 import { Search } from '@/components/Search'
 import { useI18n } from '@/hooks/web/useI18n'
-import { ElButton, ElTooltip } from 'element-plus'
+import { ElButton, ElTooltip, ElMessage, ElButtonGroup } from 'element-plus'
 import { Table } from '@/components/Table'
 import { getTableListApi, delTableListApi, saveTableApi } from '@/api/manage/file'
 import { useTable } from '@/hooks/web/useTable'
@@ -18,7 +18,6 @@ import { FileData } from '@/api/manage/types'
 import Write from './components/Write.vue'
 import { useIcon } from '@/hooks/web/useIcon'
 import { Qrcode } from '@/components/Qrcode'
-
 defineOptions({
   name: 'FilePage'
 })
@@ -47,7 +46,7 @@ const { tableRegister, tableState, tableMethods } = useTable({
     })
     return {
       list: res.data.list,
-      total: res.data.total
+      total: res.data.totalCount
     }
   },
   fetchDelApi: async () => {
@@ -77,7 +76,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'name',
     label: '名称',
-
+    minWidth: 100,
     table: {
       hidden: false
     },
@@ -90,6 +89,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'version',
     label: '版本号',
+    minWidth: 100,
     search: {
       hidden: true
     },
@@ -100,6 +100,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'code',
     label: '版本序列号',
+    minWidth: 100,
     table: {
       hidden: false
     },
@@ -113,6 +114,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'fileName',
     label: '文件名',
+    minWidth: 120,
     table: {
       hidden: false
     },
@@ -123,7 +125,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'virtualPath',
     label: '文件链接',
-
+    minWidth: 120,
     search: {
       hidden: true
     },
@@ -138,7 +140,7 @@ const crudSchemas: CrudSchema[] = [
       componentProps: {
         action: '/api/sysApk/uploadFile',
         limit: 1,
-        class: 'productUploader',
+        class: 'filePageUploader',
         headers: {
           token: getStorage('token')
         },
@@ -163,6 +165,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'filePath',
     label: '文件路径',
+    minWidth: 120,
     search: {
       hidden: true
     },
@@ -176,6 +179,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'content',
     label: '版本更新说明',
+    minWidth: 120,
     search: {
       hidden: true
     },
@@ -194,6 +198,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'remark',
     label: '备注',
+    minWidth: 120,
     search: {
       hidden: true
     },
@@ -212,6 +217,7 @@ const crudSchemas: CrudSchema[] = [
   {
     field: 'createTime',
     label: '创建时间',
+    minWidth: 160,
     table: {
       hidden: false
     },
@@ -224,7 +230,7 @@ const crudSchemas: CrudSchema[] = [
   },
   {
     field: 'action',
-    width: '250px',
+    width: '200px',
     label: '操作',
     search: {
       hidden: true
@@ -237,26 +243,22 @@ const crudSchemas: CrudSchema[] = [
     },
     table: {
       hidden: false,
+      fixed: 'right',
       slots: {
         default: (data: any) => {
           return (
-            <>
+            <ElButtonGroup>
               <ElTooltip content="二维码">
-                <ElButton text icon={QRIcon} onClick={() => showQrCode(data)}></ElButton>
+                <ElButton text icon={QRIcon} onClick={() => showQrCode(data.row)} />
               </ElTooltip>
               <ElTooltip content="下载">
-                <ElButton text icon={DownLoadIcon} onClick={() => downloadFile(data)}></ElButton>
+                <ElButton text icon={DownLoadIcon} onClick={() => downloadFile(data.row)} />
               </ElTooltip>
               <ElTooltip content="复制链接">
-                <ElButton text icon={copyIcon}></ElButton>
+                <ElButton text icon={copyIcon} onClick={() => onCopy(data.row)} />
               </ElTooltip>
-              <ElButton
-                icon={DeleteIcon}
-                text
-                type="danger"
-                onClick={() => delData(data[0].row)}
-              ></ElButton>
-            </>
+              <ElButton icon={DeleteIcon} text type="danger" onClick={() => delData(data.row)} />
+            </ElButtonGroup>
           )
         }
       }
@@ -330,9 +332,17 @@ const showQrCode = (row: FileData) => {
 }
 
 const downloadFile = (row: FileData) => {
-  console.log(row)
   window.open(row.virtualPath)
 }
+
+const onCopy = (row: FileData) => {
+  navigator.clipboard.writeText(row.virtualPath).then(() => {
+    ElMessage({
+      message: '复制成功!',
+      type: 'success'
+    })
+  })
+}
 </script>
 
 <template>
@@ -388,4 +398,7 @@ const downloadFile = (row: FileData) => {
   display: inline-block;
   margin-right: 12px;
 }
+.filePageUploader {
+  width: 100%;
+}
 </style>

+ 3 - 3
src/views/Manage/News/NewsPage.vue

@@ -252,13 +252,13 @@ const crudSchemas: CrudSchema[] = [
         default: (data: any) => {
           return (
             <>
-              <ElButton type="primary" onClick={() => action(data[0].row, 'edit')}>
+              <ElButton type="primary" onClick={() => action(data.row, 'edit')}>
                 {t('exampleDemo.edit')}
               </ElButton>
-              <ElButton type="success" onClick={() => action(data[0].row, 'detail')}>
+              <ElButton type="success" onClick={() => action(data.row, 'detail')}>
                 {t('exampleDemo.detail')}
               </ElButton>
-              <ElButton type="danger" onClick={() => delData(data[0].row)}>
+              <ElButton type="danger" onClick={() => delData(data.row)}>
                 {t('exampleDemo.del')}
               </ElButton>
             </>

+ 3 - 3
src/views/Manage/Product/ProductPage.vue

@@ -174,13 +174,13 @@ const crudSchemas: CrudSchema[] = [
         default: (data: any) => {
           return (
             <>
-              <ElButton type="primary" onClick={() => action(data[0].row, 'edit')}>
+              <ElButton type="primary" onClick={() => action(data.row, 'edit')}>
                 {t('exampleDemo.edit')}
               </ElButton>
-              <ElButton type="success" onClick={() => action(data[0].row, 'detail')}>
+              <ElButton type="success" onClick={() => action(data.row, 'detail')}>
                 {t('exampleDemo.detail')}
               </ElButton>
-              <ElButton type="danger" onClick={() => delData(data[0].row)}>
+              <ElButton type="danger" onClick={() => delData(data.row)}>
                 {t('exampleDemo.del')}
               </ElButton>
             </>