explanationSettings.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div class="explanation-settings" app-border dir-left>
  3. <template v-if="currentScene.type !== '4dkk'">
  4. <div class="title">
  5. {{$i18n.t("explanation.explanation_settings")}}
  6. <i class="iconfont icon-help_i tool-tip-for-editor" v-tooltip="$i18n.t('explanation.explanation_tips')"/>
  7. </div>
  8. <button
  9. v-if="!currentScene.explanation.audioId"
  10. class="ui-button submit"
  11. :class="{
  12. disable: !currentScene || currentScene.type ==='4dkk',
  13. }"
  14. @click="isShowSelectionWindow = true"
  15. >
  16. <i class="iconfont icon-editor_add"></i>
  17. {{$i18n.t("explanation.add_audio")}}
  18. </button>
  19. <template v-else>
  20. <div class="music-display" @click.self="onClickCurrentMusic">
  21. <Audio ref="my-audio" class="audio-control" :backgroundColor="'#1A1B1D'" :myAudioUrl="currentScene.explanation.audioUrl"></Audio>
  22. <div class="name" :key="currentScene.explanation.audioName" v-title="currentScene.explanation.audioName" @click="onClickCurrentMusic">{{currentScene.explanation.audioName}}</div>
  23. <i class="iconfont icon-editor_list_delete" @click.stop="onClickDeleteMusicBtn"></i>
  24. </div>
  25. <button class="ui-button" @click="isShowSelectionWindow = true">
  26. <i class="iconfont icon-editor_update"></i>
  27. {{$i18n.t("explanation.change_audio")}}
  28. </button>
  29. </template>
  30. <div class="switch-wrapper">
  31. <span class="label">{{$i18n.t("explanation.default_open")}}</span>
  32. <Switcher
  33. :disable="!currentScene || currentScene.type ==='4dkk'"
  34. :value="currentScene.explanation.openByDefault" @change="currentScene.explanation.openByDefault = !currentScene.explanation.openByDefault"
  35. />
  36. </div>
  37. <div class="switch-wrapper">
  38. <span class="label">{{$i18n.t("explanation.loop")}}</span>
  39. <Switcher
  40. :disable="!currentScene || currentScene.type ==='4dkk'"
  41. :value="currentScene.explanation.repeat" @change="currentScene.explanation.repeat = !currentScene.explanation.repeat"
  42. />
  43. </div>
  44. <div class="dialog" style="z-index: 2000" v-if="isShowSelectionWindow">
  45. <MaterialSelector
  46. :title="$i18n.t('gather.select_material')"
  47. @cancle="isShowSelectionWindow = false"
  48. @submit="handleSubmitFromMaterialSelector"
  49. :selectableType="['audio']"
  50. initialMaterialType="audio"
  51. />
  52. </div>
  53. </template>
  54. <!-- <div class="disabled-tip" v-if="currentScene.type === '4dkk'">
  55. {{$i18n.t('explanation.disabled_tip')}}
  56. </div> -->
  57. </div>
  58. </template>
  59. <script>
  60. import { mapGetters } from "vuex";
  61. import Switcher from "@/components/shared/Switcher";
  62. import MaterialSelector from "@/components/materialSelector.vue";
  63. import Audio from "@/components/audio/audioButton.vue";
  64. export default {
  65. components: {
  66. Switcher,
  67. MaterialSelector,
  68. Audio,
  69. },
  70. computed: {
  71. ...mapGetters({
  72. info: "info",
  73. currentScene: "scene/currentScene",
  74. }),
  75. },
  76. data() {
  77. return {
  78. isShowSelectionWindow: false,
  79. }
  80. },
  81. methods: {
  82. onClickCurrentMusic() {
  83. if (this.$refs['my-audio']) {
  84. this.$refs['my-audio'].switchPlayPause()
  85. }
  86. },
  87. onClickDeleteMusicBtn() {
  88. this.currentScene.explanation.audioId = ''
  89. this.currentScene.explanation.audioUrl = ''
  90. this.currentScene.explanation.audioName = ''
  91. },
  92. handleSubmitFromMaterialSelector(selected) {
  93. this.currentScene.explanation.audioId = selected[0].id
  94. this.currentScene.explanation.audioName = selected[0].name
  95. this.currentScene.explanation.audioUrl = selected[0].ossPath
  96. this.isShowSelectionWindow = false
  97. },
  98. },
  99. watch: {
  100. currentScene: {
  101. immediate: true,
  102. handler: function (newVal) {
  103. if (!newVal.explanation) {
  104. this.$set(newVal, 'explanation', {
  105. audioId: '',
  106. audioName: '',
  107. audioUrl: '',
  108. openByDefault: true,
  109. repeat: true,
  110. })
  111. }
  112. },
  113. },
  114. },
  115. }
  116. </script>
  117. <style lang="less" scoped>
  118. .explanation-settings {
  119. padding: 20px;
  120. > .title {
  121. font-size: 18px;
  122. color: #fff;
  123. > i {
  124. font-size: 12px;
  125. position: relative;
  126. top: -2px;
  127. }
  128. }
  129. > button {
  130. width: 100%;
  131. margin-top: 16px;
  132. &:hover {
  133. border-color: @color;
  134. }
  135. i {
  136. font-size: 14px;
  137. }
  138. }
  139. > .music-display {
  140. cursor: pointer;
  141. margin-top: 16px;
  142. width: 234px;
  143. height: 36px;
  144. background: #1A1B1D;
  145. border-radius: 2px;
  146. border: 1px solid #404040;
  147. color: #fff;
  148. font-size: 14px;
  149. text-align: center;
  150. position: relative;
  151. &:hover {
  152. color: #0076F6;
  153. border-color: @color;
  154. > .audio-control {
  155. display: inline-block;
  156. }
  157. > i {
  158. display: inline-block;
  159. }
  160. }
  161. > .audio-control {
  162. position: absolute;
  163. top: 50%;
  164. transform: translateY(-50%);
  165. left: 18px;
  166. display: none;
  167. }
  168. > .name {
  169. position: absolute;
  170. left: 50%;
  171. top: 50%;
  172. transform: translate(-50%, -50%);
  173. width: 65%;
  174. text-overflow: ellipsis;
  175. overflow: hidden;
  176. white-space: nowrap;
  177. display: inline-block;
  178. }
  179. > i {
  180. display: none;
  181. position: absolute;
  182. top: 50%;
  183. transform: translateY(-50%);
  184. right: 18px;
  185. &:hover {
  186. color: #FA5555;
  187. }
  188. }
  189. }
  190. .switch-wrapper {
  191. display: flex;
  192. align-items: center;
  193. justify-content: space-between;
  194. margin-top: 18px;
  195. .label {
  196. color: rgba(255, 255, 255, 0.6);
  197. font-size: 14px;
  198. }
  199. }
  200. .disabled-tip {
  201. text-align: center;
  202. color: rgba(255, 255, 255, 0.6);
  203. font-size: 14px;
  204. }
  205. }
  206. </style>