index.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {
  2. NBreadcrumb,
  3. NBreadcrumbItem,
  4. NSpace,
  5. NTabPane,
  6. NTabs
  7. } from 'naive-ui';
  8. import { defineComponent, nextTick, reactive } from 'vue';
  9. import styles from './index.module.less';
  10. import icon_back from '../../xiaoku-music/images/icon_back.png';
  11. // import icon_separator from '../../xiaoku-music/images/icon_separator.png';
  12. import { useRoute, useRouter } from 'vue-router';
  13. import List from './components/list';
  14. import { api_knowledgeWikiCategoryType_page } from '../api';
  15. import TheEmpty from '/src/components/TheEmpty';
  16. export default defineComponent({
  17. name: 'content-musician',
  18. setup() {
  19. const tabValue = sessionStorage.getItem('content-musician-tab');
  20. const router = useRouter();
  21. const state = reactive({
  22. tabValue: '',
  23. categoryList: [] as any,
  24. loading: false
  25. });
  26. const getCategoryList = async () => {
  27. state.loading = true;
  28. try {
  29. const { data } = await api_knowledgeWikiCategoryType_page({
  30. type: 'MUSICIAN',
  31. page: 1,
  32. rows: 99
  33. });
  34. state.categoryList = data.rows || [];
  35. if (state.categoryList.length) {
  36. nextTick(() => {
  37. state.tabValue = tabValue || 'name-' + state.categoryList[0].id;
  38. });
  39. }
  40. } catch {
  41. //
  42. }
  43. state.loading = false;
  44. };
  45. getCategoryList();
  46. return () => (
  47. <div class={styles.container}>
  48. <NSpace align="center" wrapItem={false} size={16}>
  49. <img
  50. style={{ cursor: 'pointer' }}
  51. src={icon_back}
  52. class={styles.iconBack}
  53. onClick={() => router.push({ path: '/' })}
  54. />
  55. <NBreadcrumb separator="">
  56. <NBreadcrumbItem>音乐家</NBreadcrumbItem>
  57. </NBreadcrumb>
  58. </NSpace>
  59. <div class={styles.wrap}>
  60. <div
  61. class={[
  62. styles.listWrap,
  63. !state.loading &&
  64. state.categoryList.length <= 0 &&
  65. styles.listWrapEmpty
  66. ]}>
  67. {!state.loading && state.categoryList.length <= 0 && (
  68. <TheEmpty description="暂无音乐家" />
  69. )}
  70. <NTabs
  71. defaultValue="myResources"
  72. paneClass={styles.paneTitle}
  73. justifyContent="center"
  74. // animated
  75. paneWrapperClass={styles.paneWrapperContainer}
  76. onUpdate:value={(val: any) => {
  77. sessionStorage.setItem('content-musician-tab', val);
  78. sessionStorage.removeItem('content-musician-catch')
  79. }}
  80. v-model:value={state.tabValue}>
  81. {state.categoryList.map((category: any) => (
  82. <NTabPane
  83. name={`name-${category.id}`}
  84. tab={category.name}
  85. // displayDirective="show:lazy"
  86. >
  87. <List
  88. categoryId={category.id}
  89. categoryChildList={category.childrenList}
  90. />
  91. </NTabPane>
  92. ))}
  93. </NTabs>
  94. </div>
  95. </div>
  96. </div>
  97. );
  98. }
  99. });