Browse Source

资源添加接口

lex 1 year ago
parent
commit
25824821b9

+ 82 - 0
src/store/modules/catchData.ts

@@ -0,0 +1,82 @@
+import { defineStore } from 'pinia';
+import { store } from '@/store';
+import { storage } from '@/utils/storage';
+import { userLogin, getUserInfo } from '@/api/user';
+
+export const useCatchStore = defineStore('catch-store', {
+  state: () => ({
+    bookVersionList: [] as any[], // 其它类型
+    musicTypeList: [] as any[], // 乐谱分类
+    subjectList: [] as any[] // 声部列表
+  }),
+  getters: {
+    getBookVersion(): any[] {
+      return this.bookVersionList;
+    },
+    getMusicType(): any[] {
+      return this.musicTypeList;
+    },
+    getSubjects(): any[] {
+      return this.subjectList;
+    }
+  },
+  actions: {
+    setBookVersion(books: any[]) {
+      this.bookVersionList = books;
+    },
+    setMusicType(musics: any[]) {
+      this.musicTypeList = musics;
+    },
+    setSubjects(subjects: any[]) {
+      this.subjectList = subjects;
+    }
+    //
+    // 登录
+    // async login(userInfo: any) {
+    //   try {
+    //     const { data } = await userLogin(userInfo);
+    //     console.log(data, 'data');
+    //     const userToken = data.token_type + ' ' + data.access_token;
+    //     const ex = 7 * 24 * 60 * 60 * 1000;
+    //     storage.set(ACCESS_TOKEN, userToken, ex);
+    //     // storage.get(IM_TOKEN, data.imToken);
+
+    //     this.setToken(userToken);
+    //     // this.setImToken(data.imToken);
+    //     return Promise.resolve();
+    //   } catch (e) {
+    //     return Promise.reject(e);
+    //   }
+    // },
+
+    // // 获取用户信息
+    // async getInfo() {
+    //   return new Promise((resolve, reject) => {
+    //     getUserInfo()
+    //       .then((res: any) => {
+    //         const result = res.data;
+    //         this.setUserInfo(result);
+    //         this.setAvatar(result.account.avatar);
+    //         this.setUsername(result.nickname);
+    //         resolve(true);
+    //       })
+    //       .catch((error: any) => {
+    //         reject(error);
+    //       });
+    //   });
+    // },
+
+    // // 登出
+    // async logout() {
+    //   this.setUserInfo('');
+    //   storage.remove(ACCESS_TOKEN);
+    //   storage.remove(CURRENT_USER);
+    //   return Promise.resolve('');
+    // }
+  }
+});
+
+// Need to be used outside the setup
+export function useCatchStoreWidthOut() {
+  return useCatchStore(store);
+}

+ 2 - 2
src/utils/contants.ts

@@ -23,8 +23,8 @@ export const instrument = {
  * @description: 资源类型
  */
 export const resourceType = {
-  VIDEO: '视频',
+  MUSIC: '乐谱',
   IMG: '图片',
   SONG: '音频',
-  MUSIC: '曲目'
+  VIDEO: '视频'
 };

+ 18 - 3
src/views/natural-resources/components/my-resources /index.tsx

@@ -4,8 +4,9 @@ import CardType from '/src/components/card-type';
 import Pagination from '/src/components/pagination';
 import SearchGroupResources from './search-group-resources';
 import { materialQueryPage } from '../../api';
-import { NEmpty, NSpin } from 'naive-ui';
+import { NModal, NSpin } from 'naive-ui';
 import TheEmpty from '/src/components/TheEmpty';
+import UploadModal from './upload-modal';
 
 export default defineComponent({
   name: 'share-resources',
@@ -25,7 +26,8 @@ export default defineComponent({
         subjectId: null,
         sourceType: 3
       },
-      tableList: [] as any
+      tableList: [] as any,
+      uploadStatus: false
     });
     const getList = async () => {
       try {
@@ -54,7 +56,10 @@ export default defineComponent({
     });
     return () => (
       <>
-        <SearchGroupResources onSearch={(item: any) => onSearch(item)} />
+        <SearchGroupResources
+          onSearch={(item: any) => onSearch(item)}
+          onUpdate={() => (state.uploadStatus = true)}
+        />
 
         <NSpin v-model:show={state.loading}>
           <div class={styles.list}>
@@ -82,6 +87,16 @@ export default defineComponent({
           v-model:pageTotal={state.pageTotal}
           onList={getList}
         />
+
+        <NModal
+          v-model:show={state.uploadStatus}
+          preset="card"
+          showIcon={false}
+          class={['modalTitle background', styles.attendClassModal]}
+          title={'选择班级'}
+          blockScroll={false}>
+          <UploadModal />
+        </NModal>
       </>
     );
   }

+ 17 - 14
src/views/natural-resources/components/my-resources /search-group-resources.tsx

@@ -43,20 +43,23 @@ export default defineComponent({
       <div class={styles.searchGroup}>
         <div class={styles.searchCatatory}>
           <NSpace size="small" class={styles.btnType}>
-            {resourceList.value.map((item: any) => (
-              <NButton
-                type={forms.type === item.value ? 'primary' : 'default'}
-                secondary={forms.type === item.value ? false : true}
-                round
-                size="small"
-                focusable={false}
-                onClick={() => {
-                  forms.type = item.value;
-                  onSearch();
-                }}>
-                {item.label}
-              </NButton>
-            ))}
+            {resourceList.value.map(
+              (item: any) =>
+                item.value !== 'MUSIC' && (
+                  <NButton
+                    type={forms.type === item.value ? 'primary' : 'default'}
+                    secondary={forms.type === item.value ? false : true}
+                    round
+                    size="small"
+                    focusable={false}
+                    onClick={() => {
+                      forms.type = item.value;
+                      onSearch();
+                    }}>
+                    {item.label}
+                  </NButton>
+                )
+            )}
           </NSpace>
 
           <NSpace>

+ 0 - 0
src/views/natural-resources/components/my-resources /upload-modal/index.module.less


+ 8 - 0
src/views/natural-resources/components/my-resources /upload-modal/index.tsx

@@ -0,0 +1,8 @@
+import { defineComponent } from 'vue';
+
+export default defineComponent({
+  name: 'upload-modal',
+  setup() {
+    return () => <>上传</>;
+  }
+});

+ 2 - 2
src/views/natural-resources/components/share-resources/index.tsx

@@ -4,7 +4,7 @@ import CardType from '/src/components/card-type';
 import Pagination from '/src/components/pagination';
 import SearchGroupResources from './search-group-resources';
 import { materialQueryPage } from '../../api';
-import { NEmpty, NSpin } from 'naive-ui';
+import { NSpin } from 'naive-ui';
 import TheEmpty from '/src/components/TheEmpty';
 
 export default defineComponent({
@@ -19,7 +19,7 @@ export default defineComponent({
         rows: 20
       },
       searchGroup: {
-        type: '', //
+        type: 'MUSIC', //
         keyword: '',
         bookVersionId: null,
         subjectId: null,

+ 2 - 12
src/views/natural-resources/components/share-resources/search-group-resources.tsx

@@ -9,9 +9,8 @@ export default defineComponent({
   name: 'search-group',
   emits: ['search'],
   setup(props, { emit }) {
-    const resourceList = ref([] as any[]);
     const forms = reactive({
-      type: '', //
+      type: 'MUSIC', //
       keyword: '',
       bookVersionId: null,
       subjectId: null
@@ -21,20 +20,11 @@ export default defineComponent({
       emit('search', forms);
     };
 
-    onMounted(() => {
-      resourceList.value = [
-        {
-          label: '全部',
-          value: ''
-        },
-        ...resourceTypeArray
-      ];
-    });
     return () => (
       <div class={styles.searchGroup}>
         <div class={styles.searchCatatory}>
           <NSpace size="small" class={styles.btnType}>
-            {resourceList.value.map((item: any) => (
+            {resourceTypeArray.map((item: any) => (
               <NButton
                 type={forms.type === item.value ? 'primary' : 'default'}
                 secondary={forms.type === item.value ? false : true}

+ 1 - 0
src/views/natural-resources/index.tsx

@@ -13,6 +13,7 @@ export default defineComponent({
           defaultValue="myResources"
           paneClass={styles.paneTitle}
           justifyContent="center"
+          animated
           paneWrapperClass={styles.paneWrapperContainer}>
           <NTabPane
             name="shareResources"