index.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. import { defineComponent, onMounted, reactive, ref } from 'vue';
  2. import styles from './index.module.less';
  3. import { NImage, NModal } from 'naive-ui';
  4. import defultHeade from '@/components/layout/images/teacherIcon.png';
  5. import teacherMan from './img/teacher-man.png';
  6. import teacherWoman from './img/teacher-woman.png';
  7. import iconEchats from './img/icon-echats.png';
  8. import t1 from './img/t1.png';
  9. import t11 from './img/t1-1.png';
  10. import t12 from './img/t1-4.png';
  11. import t2 from './img/t2.png';
  12. import t21 from './img/t2-1.png';
  13. import t22 from './img/t2-4.png';
  14. import f1 from './img/f1.png';
  15. import f11 from './img/f1-1.png';
  16. import f2 from './img/f2.png';
  17. import f21 from './img/f2-1.png';
  18. import f3 from './img/f3.png';
  19. import f31 from './img/f3-1.png';
  20. import f4 from './img/f4.png';
  21. import f41 from './img/f4-1.png';
  22. import { useRouter } from 'vue-router';
  23. import { useUserStore } from '/src/store/modules/users';
  24. // import SelectClass from './modals/selectClass';
  25. import dayjs from 'dayjs';
  26. import UpdatePassword from '/src/components/layout/modals/update-password';
  27. import AttendClass from '../prepare-lessons/model/attend-class';
  28. import { useResizeObserver } from '@vueuse/core';
  29. import PlaceholderTone from '/src/components/layout/modals/placeholderTone';
  30. import PreviewWindow from '../preview-window';
  31. import { state } from '/src/state';
  32. import SubjectModal from './modals/subject-modal';
  33. import { vaildMusicScoreUrl } from '/src/utils/urlUtils';
  34. import HomeGuide from '/src/custom-plugins/guide-page/home-guide';
  35. // import { state } from '/src/state';
  36. export const formatDateToDay = () => {
  37. const hours = dayjs().hour();
  38. if (hours < 12) {
  39. return '早上好'; //如果小时数小于12则输出“早上好!”
  40. } else if (hours > 12 && hours < 18) {
  41. return '下午好'; //如果小时数大于12并且小于18,输入“下午好!”
  42. } else {
  43. return '晚上好'; //如果上面两个条件都不符合,则输出“晚上好!”
  44. }
  45. };
  46. export default defineComponent({
  47. name: 'home-page',
  48. setup() {
  49. const router = useRouter();
  50. const userStore = useUserStore();
  51. const showUpdatePassword = ref(false);
  52. const showModalTone = ref(false);
  53. const forms = reactive({
  54. previewModal: false,
  55. previewParams: {} as any,
  56. showAttendClass: false,
  57. loading: false,
  58. message: '',
  59. list: [] as any,
  60. unit: null,
  61. classLoading: false,
  62. showGuide: false,
  63. homeLeftHeight: 'auto',
  64. subjectSyncVisiable: false
  65. });
  66. onMounted(async () => {
  67. useResizeObserver(
  68. document.querySelector('#homeInfoLeft-home') as any,
  69. (entries: any) => {
  70. const entry = entries[0];
  71. const { height } = entry.contentRect;
  72. forms.homeLeftHeight = height + 'px';
  73. }
  74. );
  75. forms.classLoading = true;
  76. if (!userStore.getUserInfo.account.updatePasswordFlag) {
  77. showUpdatePassword.value = true;
  78. } else {
  79. forms.showGuide = true;
  80. }
  81. forms.classLoading = false;
  82. });
  83. return () => (
  84. <div class={styles.homeWrap}>
  85. <div id="home-0"></div>
  86. <div class={styles.homeSection}>
  87. <div class={styles.homeLeft}>
  88. <i class={styles.homeWindow}></i>
  89. <div class={styles.homeUserInfo}>
  90. <i class={styles.homeTag}></i>
  91. <div class={styles.homeUsers}>
  92. <NImage
  93. src={userStore.getUserInfo?.avatar || defultHeade}
  94. class={styles.userImg}
  95. />
  96. <p class={styles.userName}>
  97. Hi,{userStore.getUserInfo?.nickname} {formatDateToDay()}~
  98. </p>
  99. </div>
  100. <p class={styles.desc}>
  101. 点击下方按钮,您可以根据声部进行备课或是直接选择班级开始上课,更好的规划教学哦!
  102. </p>
  103. <div class={styles.homeBtnGroup}>
  104. <div
  105. class={styles.btnBk}
  106. onClick={() => {
  107. // 备课
  108. router.push({
  109. path: '/prepare-lessons'
  110. });
  111. }}></div>
  112. <div
  113. id="home-4"
  114. class={styles.btnClass}
  115. onClick={() => {
  116. forms.showAttendClass = true;
  117. }}></div>
  118. </div>
  119. <img src={iconEchats} class={styles.homeEchats} />
  120. </div>
  121. {userStore.getUserInfo.gender === 1 ? (
  122. <div>
  123. <img src={teacherMan} class={styles.teacherMan} />
  124. <span class={styles.teacherBook}></span>
  125. </div>
  126. ) : (
  127. <img src={teacherWoman} class={styles.teacherWoman} />
  128. )}
  129. </div>
  130. <div class={styles.homeRight}>
  131. <div class={styles.rightTop}>
  132. <div
  133. class={[styles.topSection, styles.topSection1]}
  134. onClick={() => {
  135. forms.subjectSyncVisiable = true;
  136. }}>
  137. <img src={t1} class={styles.tFun} />
  138. <img src={t11} class={styles.tTxt} />
  139. <img src={t12} class={styles.tTitle} />
  140. </div>
  141. <div
  142. class={[styles.topSection, styles.topSection2]}
  143. onClick={() => {
  144. const origin = /(localhost|192)/.test(location.host)
  145. ? 'https://test.lexiaoya.cn'
  146. : location.origin;
  147. const src = `${origin}/classroom-app/#/tempo-practice?Authorization=${userStore.getToken}&win=pc&platform=modal&back=show`;
  148. if (window.matchMedia('(display-mode: standalone)').matches) {
  149. state.application = window.matchMedia(
  150. '(display-mode: standalone)'
  151. ).matches;
  152. forms.previewModal = true;
  153. forms.previewParams.src = src + '&backBtnType=microapp';
  154. } else {
  155. window.open(src);
  156. }
  157. }}>
  158. <img src={t2} class={styles.tFun} />
  159. <img src={t21} class={styles.tTxt} />
  160. <img src={t22} class={styles.tTitle} />
  161. </div>
  162. </div>
  163. <div class={styles.rightBottom}>
  164. <div
  165. class={styles.bottomSection}
  166. onClick={() => {
  167. router.push('/content-instruments');
  168. }}>
  169. <img src={f1} class={styles.bFun} />
  170. <img src={f11} class={styles.bTxt} />
  171. </div>
  172. <div
  173. class={styles.bottomSection}
  174. onClick={() => {
  175. router.push('/content-music');
  176. }}>
  177. <img src={f2} class={styles.bFun} />
  178. <img src={f21} class={styles.bTxt} />
  179. </div>
  180. <div
  181. class={styles.bottomSection}
  182. onClick={() => {
  183. router.push('/content-musician');
  184. }}>
  185. <img src={f3} class={styles.bFun} />
  186. <img src={f31} class={[styles.bTxt, styles.bTxt2]} />
  187. </div>
  188. <div
  189. class={styles.bottomSection}
  190. onClick={() => {
  191. router.push('/content-knowledge');
  192. }}>
  193. <img src={f4} class={styles.bFun} />
  194. <img src={f41} class={[styles.bTxt, styles.bTxt3]} />
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. {forms.showGuide ? <HomeGuide></HomeGuide> : null}
  200. <NModal class={['background']} v-model:show={showModalTone.value}>
  201. <div>
  202. <PlaceholderTone
  203. message={forms.message}
  204. onClose={() => {
  205. showModalTone.value = false;
  206. }}></PlaceholderTone>
  207. </div>
  208. </NModal>
  209. <NModal
  210. v-model:show={showUpdatePassword.value}
  211. class={['modalTitle', styles.showUpdatePassword]}
  212. style="--n-title-font-weight: 600;"
  213. preset="card"
  214. title={'修改密码'}
  215. closable={false}
  216. maskClosable={false}
  217. closeOnEsc={false}>
  218. <UpdatePassword
  219. onSubmit={() => {
  220. // 密码更新成功
  221. showUpdatePassword.value = true;
  222. forms.showGuide = true;
  223. userStore.logout().then(() => {
  224. // 移除标签页
  225. router
  226. .replace({
  227. name: 'login'
  228. })
  229. .finally(() => location.reload());
  230. });
  231. }}
  232. />
  233. </NModal>
  234. <NModal
  235. v-model:show={forms.showAttendClass}
  236. preset="card"
  237. showIcon={false}
  238. class={['modalTitle background', styles.attendClassModal]}
  239. title={'选择班级'}
  240. blockScroll={false}>
  241. <AttendClass
  242. onClose={() => (forms.showAttendClass = false)}
  243. type="change"
  244. onConfirm={(item: any) => {
  245. router.push({
  246. path: '/prepare-lessons',
  247. query: {
  248. ...item
  249. }
  250. });
  251. }}
  252. />
  253. </NModal>
  254. <PreviewWindow
  255. v-model:show={forms.previewModal}
  256. type="music"
  257. params={forms.previewParams}
  258. />
  259. {/* 完成编辑时,选择声部 */}
  260. <NModal
  261. v-model:show={forms.subjectSyncVisiable}
  262. preset="card"
  263. class={['modalTitle background', styles.subjectSyncModal]}
  264. title={'选择乐器'}>
  265. <SubjectModal
  266. onClose={() => (forms.subjectSyncVisiable = false)}
  267. onConfirm={async (item: any) => {
  268. // musicsrc = `${origin}/instrument?modelType=practise&id=${
  269. // data.list[data.listActive].xmlFileUrl
  270. // }&Authorization=${userStore.getToken}/#/preview`;
  271. // const origin = /(localhost|192)/.test(location.host)
  272. // ? 'https://test.lexiaoya.cn'
  273. // : location.origin;
  274. // view-figner?subjectCode=pan-flute
  275. const src = `${vaildMusicScoreUrl()}/instrument/#/view-figner?Authorization=${
  276. userStore.getToken
  277. }&code=${item.code}&platform=pc&type=listenMode`;
  278. // const src = `http://192.168.3.220:3000/instrument.html#/view-figner?Authorization=${userStore.getToken}&code=${item.code}`;
  279. if (window.matchMedia('(display-mode: standalone)').matches) {
  280. state.application = window.matchMedia(
  281. '(display-mode: standalone)'
  282. ).matches;
  283. forms.previewModal = true;
  284. forms.previewParams.src = src + '&matchMedia=1';
  285. } else {
  286. window.open(src);
  287. }
  288. forms.subjectSyncVisiable = false;
  289. }}
  290. />
  291. </NModal>
  292. </div>
  293. );
  294. }
  295. });