index.tsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. import { defineComponent, reactive, ref } from 'vue';
  2. import { NImage, NModal } from 'naive-ui';
  3. import styles from './index.module.less';
  4. import icon1 from '../../images/addSource/icon1.png';
  5. import icon2 from '../../images/addSource/icon2.png';
  6. import icon3 from '../../images/addSource/icon3.png';
  7. import icon4 from '../../images/addSource/icon4.png';
  8. import icon5 from '../../images/addSource/icon5.png';
  9. import icon6 from '../../images/addSource/icon6.png';
  10. import icon7 from '../../images/addSource/icon7.png';
  11. import { useRouter } from 'vue-router';
  12. import SourceRhythm from '../source-rhythm';
  13. import SourceInstrument from '../source-instrument';
  14. import SourceKnowledge from '../source-knowledge';
  15. import SourceMusician from '../source-musician';
  16. import SourceMusic from '../source-music';
  17. export default defineComponent({
  18. name: 'add-other-source',
  19. emits: ['close', 'comfirm'],
  20. setup(props, { emit }) {
  21. const router = useRouter();
  22. const sourceList = ref([
  23. // {
  24. // image: icon1,
  25. // name: '听音练习',
  26. // index: 0
  27. // },
  28. {
  29. image: icon2,
  30. name: '节奏练习',
  31. index: 1
  32. },
  33. {
  34. image: icon3,
  35. name: '乐器百科',
  36. index: 2
  37. },
  38. {
  39. image: icon6,
  40. name: '名曲鉴赏',
  41. index: 3
  42. },
  43. {
  44. image: icon5,
  45. name: '音乐家',
  46. index: 4
  47. },
  48. {
  49. image: icon4,
  50. name: '乐理知识',
  51. index: 5
  52. },
  53. {
  54. image: icon7,
  55. name: '制作曲谱',
  56. index: 6
  57. }
  58. ]);
  59. const state = reactive({
  60. listenStatus: false, // 听音练习
  61. rhythmStatus: false, //节奏
  62. theoryStatus: false, //
  63. musicStatus: false, //
  64. instrumentStatus: false, //
  65. musicianStatus: false //
  66. });
  67. // LISTEN:听音,RHYTHM:节奏,THEORY:乐理知识,MUSIC_WIKI:曲目 INSTRUMENT:乐器 MUSICIAN:音乐家)
  68. const onDetail = (item: any) => {
  69. switch (item.index) {
  70. case 1:
  71. state.rhythmStatus = true;
  72. break;
  73. case 2:
  74. state.instrumentStatus = true;
  75. break;
  76. case 3:
  77. state.musicStatus = true;
  78. break;
  79. case 4:
  80. state.musicianStatus = true;
  81. break;
  82. case 5:
  83. state.theoryStatus = true;
  84. break;
  85. case 6:
  86. // 直接跳转到制谱页面 (临时存储数据)
  87. sessionStorage.setItem('notation-open-create', '1');
  88. router.push('/notation');
  89. break;
  90. default:
  91. break;
  92. }
  93. };
  94. return () => (
  95. <>
  96. <div class={styles.addOtherSource}>
  97. {sourceList.value.map(source => (
  98. <div class={styles.sourceItem} onClick={() => onDetail(source)}>
  99. <NImage
  100. class={styles.coverImg}
  101. src={source.image}
  102. previewDisabled
  103. />
  104. <p class={styles.name}>{source.name}</p>
  105. </div>
  106. ))}
  107. </div>
  108. {/*
  109. 百科: https://oss.dayaedu.com/ktqy/17101370093153448b2cd.png
  110. jianshang https://oss.dayaedu.com/ktqy/1710137009315eedcdeed.png
  111. jiezou https://oss.dayaedu.com/ktqy/171013700931689a322a6.png
  112. yinyuejia https://oss.dayaedu.com/ktqy/1710137009316fbd65d39.png
  113. yueli https://oss.dayaedu.com/ktqy/17101370093160d479afe.png
  114. */}
  115. {/* 节奏练习 */}
  116. <NModal
  117. v-model:show={state.rhythmStatus}
  118. preset="card"
  119. class={['modalTitle background', styles.addOtherSourceModal]}
  120. title={'节奏练习'}>
  121. <SourceRhythm
  122. onClose={() => (state.rhythmStatus = false)}
  123. onConfirm={(item: any) => {
  124. state.rhythmStatus = false;
  125. emit('comfirm', {
  126. materialId: null,
  127. coverImg: item.coverImg,
  128. dataJson: item.dataJson,
  129. title: '节奏练习',
  130. isCollect: false,
  131. isSelected: false,
  132. content: null,
  133. type: 'RHYTHM'
  134. });
  135. emit('close');
  136. }}
  137. />
  138. </NModal>
  139. {/* 乐器百科 */}
  140. <NModal
  141. v-model:show={state.instrumentStatus}
  142. preset="card"
  143. class={['modalTitle', styles.instrumentModal]}
  144. title={'乐器百科'}>
  145. <SourceInstrument
  146. onClose={() => (state.instrumentStatus = false)}
  147. onConfirm={(val: any) => {
  148. state.instrumentStatus = false;
  149. const value = val || [];
  150. const temp: any[] = [];
  151. value.forEach((item: any) => {
  152. temp.push({
  153. materialId: item.materialId,
  154. coverImg: item.coverImg,
  155. dataJson: null,
  156. title: item.title,
  157. isCollect: false,
  158. isSelected: false,
  159. content: item.content,
  160. type: 'INSTRUMENT'
  161. });
  162. });
  163. emit('comfirm', temp);
  164. emit('close');
  165. }}
  166. />
  167. </NModal>
  168. {/* 乐理知识 */}
  169. <NModal
  170. v-model:show={state.theoryStatus}
  171. preset="card"
  172. class={['modalTitle', styles.theoryModal]}
  173. title={'乐理知识'}>
  174. <SourceKnowledge
  175. onClose={() => (state.theoryStatus = false)}
  176. onConfirm={(val: any) => {
  177. state.theoryStatus = false;
  178. const value = val || [];
  179. const temp: any[] = [];
  180. value.forEach((item: any) => {
  181. temp.push({
  182. materialId: item.materialId,
  183. coverImg: item.coverImg,
  184. dataJson: null,
  185. title: item.title,
  186. isCollect: false,
  187. isSelected: false,
  188. content: item.content,
  189. type: 'THEORY'
  190. });
  191. });
  192. emit('comfirm', temp);
  193. emit('close');
  194. }}
  195. />
  196. </NModal>
  197. {/* 音乐家 */}
  198. <NModal
  199. v-model:show={state.musicianStatus}
  200. preset="card"
  201. class={['modalTitle', styles.instrumentModal]}
  202. title={'音乐家'}>
  203. <SourceMusician
  204. onClose={() => (state.musicianStatus = false)}
  205. onConfirm={(val: any) => {
  206. state.musicianStatus = false;
  207. const value = val || [];
  208. const temp: any[] = [];
  209. value.forEach((item: any) => {
  210. temp.push({
  211. materialId: item.materialId,
  212. coverImg: item.coverImg,
  213. dataJson: null,
  214. title: item.title,
  215. isCollect: false,
  216. isSelected: false,
  217. content: item.content,
  218. type: 'MUSICIAN'
  219. });
  220. });
  221. emit('comfirm', temp);
  222. emit('close');
  223. }}
  224. />
  225. </NModal>
  226. {/* 名曲鉴赏 */}
  227. <NModal
  228. v-model:show={state.musicStatus}
  229. preset="card"
  230. class={['modalTitle', styles.musicModal]}
  231. title={'名曲鉴赏'}>
  232. <SourceMusic
  233. onClose={() => (state.musicStatus = false)}
  234. onConfirm={(val: any) => {
  235. state.musicStatus = false;
  236. const value = val || [];
  237. const temp: any[] = [];
  238. value.forEach((item: any) => {
  239. temp.push({
  240. materialId: item.materialId,
  241. coverImg: item.coverImg,
  242. dataJson: null,
  243. title: item.title,
  244. isCollect: false,
  245. isSelected: false,
  246. content: item.content,
  247. type: 'MUSIC_WIKI'
  248. });
  249. });
  250. emit('comfirm', temp);
  251. emit('close');
  252. }}
  253. />
  254. </NModal>
  255. </>
  256. );
  257. }
  258. });