index.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import {
  2. NButton,
  3. NCard,
  4. NIcon,
  5. NLayout,
  6. NLayoutContent,
  7. NLayoutSider,
  8. NModal,
  9. NRadio,
  10. NRadioGroup,
  11. NScrollbar,
  12. NSpace,
  13. NTabPane,
  14. NTable,
  15. NTabs,
  16. useMessage,
  17. } from "naive-ui";
  18. import { defineComponent, reactive, watch } from "vue";
  19. import { Close } from "@vicons/ionicons5";
  20. import styles from "./index.module.less";
  21. import { getImage } from "../../images";
  22. import { settings } from "../../runtime";
  23. export default defineComponent({
  24. name: "TheSetting",
  25. props: {
  26. show: {
  27. type: Boolean,
  28. default: false,
  29. },
  30. },
  31. emits: ["update:show"],
  32. setup(props, { emit }) {
  33. const message = useMessage();
  34. const data = reactive({
  35. show: false,
  36. btns: [
  37. {
  38. label: "播放设置",
  39. key: "1",
  40. icon: getImage("icon_28_1.png"),
  41. },
  42. {
  43. label: "快捷键",
  44. key: "3",
  45. icon: getImage("icon_28_3.png"),
  46. },
  47. ],
  48. active: "3",
  49. });
  50. watch(
  51. () => props.show,
  52. () => {
  53. data.show = props.show;
  54. }
  55. );
  56. const keys = [
  57. {
  58. label: "音符向上",
  59. value: "↑",
  60. },
  61. {
  62. label: "音符向下",
  63. value: "↓",
  64. },
  65. {
  66. label: "音符C",
  67. value: "C",
  68. },
  69. {
  70. label: "音符D",
  71. value: "D",
  72. },
  73. {
  74. label: "音符E",
  75. value: "E",
  76. },
  77. {
  78. label: "音符F",
  79. value: "F",
  80. },
  81. {
  82. label: "音符G",
  83. value: "G",
  84. },
  85. {
  86. label: "音符A",
  87. value: "A",
  88. },
  89. {
  90. label: "音符B",
  91. value: "B",
  92. },
  93. {
  94. label: "删除音符",
  95. value: "BackSpace",
  96. },
  97. {
  98. label: "撤回",
  99. value: "Ctrl + z",
  100. },
  101. {
  102. label: "多选",
  103. value: "Shift",
  104. },
  105. ];
  106. return () => (
  107. <NModal autoFocus={false} show={props.show} onUpdate:show={(val) => emit("update:show", val)}>
  108. <div class={styles.setbox}>
  109. <div class={styles.head}>
  110. <div>设置</div>
  111. <NButton
  112. class={styles.close}
  113. quaternary
  114. circle
  115. size="small"
  116. onClick={() => emit("update:show", false)}
  117. >
  118. <NIcon component={Close} size={18} />
  119. </NButton>
  120. </div>
  121. <div class={styles.content}>
  122. <div class={styles.slide}>
  123. <NSpace vertical align="center" wrapItem={false}>
  124. {data.btns.map((item) => (
  125. <NButton
  126. quaternary
  127. block
  128. class={[styles.btn, data.active === item.key && styles.activeBtn]}
  129. onClick={() => (data.active = item.key)}
  130. >
  131. {{
  132. icon: () => <img class={styles.btnIcon} src={item.icon} />,
  133. default: () => item.label,
  134. }}
  135. </NButton>
  136. ))}
  137. </NSpace>
  138. </div>
  139. <div class={styles.box}>
  140. <NTabs v-model:value={data.active}>
  141. <NTabPane name="1" tab="1">
  142. <div class={styles.keyBox}>
  143. <NCard title="光标设置" bordered={false}>
  144. <NRadioGroup v-model:value={settings.cursorType}>
  145. <NSpace>
  146. <NRadio value="beat" disabled>光标跟随节拍</NRadio>
  147. <NRadio value="note">光标跟随音符</NRadio>
  148. </NSpace>
  149. </NRadioGroup>
  150. </NCard>
  151. </div>
  152. </NTabPane>
  153. <NTabPane name="3" tab="3">
  154. <NScrollbar>
  155. <div class={styles.keyBox}>
  156. <NTable class={styles.table} striped>
  157. <thead>
  158. <tr>
  159. <th>命令</th>
  160. <th>快捷键</th>
  161. </tr>
  162. </thead>
  163. <tbody>
  164. {keys.map((item) => (
  165. <tr>
  166. <td>{item.label}</td>
  167. <td>{item.value}</td>
  168. </tr>
  169. ))}
  170. </tbody>
  171. </NTable>
  172. </div>
  173. </NScrollbar>
  174. </NTabPane>
  175. </NTabs>
  176. </div>
  177. </div>
  178. </div>
  179. </NModal>
  180. );
  181. },
  182. });