parent
							
								
									cb1be0007b
								
							
						
					
					
						commit
						23488369d2
					
				| 
						 | 
					@ -14,7 +14,7 @@
 | 
				
			||||||
      />
 | 
					      />
 | 
				
			||||||
      <!-- </keep-alive> -->
 | 
					      <!-- </keep-alive> -->
 | 
				
			||||||
    </Transition>
 | 
					    </Transition>
 | 
				
			||||||
    <ft-toast ref="toast" message="hello world" :action="toastAction" />
 | 
					    <ft-toast />
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					import Vue from 'vue';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const events = new Vue();
 | 
				
			||||||
 | 
					export default events;
 | 
				
			||||||
| 
						 | 
					@ -1,22 +1,19 @@
 | 
				
			||||||
import Vue from 'vue'
 | 
					import Vue from 'vue'
 | 
				
			||||||
 | 
					import FtToastEvents from './ft-toast-events.js'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default Vue.extend({
 | 
					export default Vue.extend({
 | 
				
			||||||
  name: 'FtToast',
 | 
					  name: 'FtToast',
 | 
				
			||||||
  props: {
 | 
					 | 
				
			||||||
    message: {
 | 
					 | 
				
			||||||
      type: String,
 | 
					 | 
				
			||||||
      required: true,
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    action: {
 | 
					 | 
				
			||||||
      type: Function,
 | 
					 | 
				
			||||||
      default: function () {},
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
  data: function () {
 | 
					  data: function () {
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
      isOpen: false,
 | 
					      isOpen: false,
 | 
				
			||||||
 | 
					      message: '',
 | 
				
			||||||
 | 
					      action: () => {},
 | 
				
			||||||
 | 
					      queue: [],
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  mounted: function () {
 | 
				
			||||||
 | 
					    FtToastEvents.$on('toast.open', this.open)
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    performAction: function () {
 | 
					    performAction: function () {
 | 
				
			||||||
      this.action()
 | 
					      this.action()
 | 
				
			||||||
| 
						 | 
					@ -24,10 +21,23 @@ export default Vue.extend({
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    close: function () {
 | 
					    close: function () {
 | 
				
			||||||
      this.isOpen = false
 | 
					      this.isOpen = false
 | 
				
			||||||
 | 
					      if(this.queue.length !== 0) {
 | 
				
			||||||
 | 
					        const toast = this.queue.shift()
 | 
				
			||||||
 | 
					        this.open(toast.message, toast.action)
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    open: function () {
 | 
					    open: function (message, action) {
 | 
				
			||||||
 | 
					      if (this.isOpen) {
 | 
				
			||||||
 | 
					        this.queue.push({ message: message, action: action })
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.message = message
 | 
				
			||||||
 | 
					      this.action = action || (() => {});
 | 
				
			||||||
      this.isOpen = true
 | 
					      this.isOpen = true
 | 
				
			||||||
      setTimeout(this.close, 2000)
 | 
					      setTimeout(this.close, 2000)
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  beforeDestroy: function () {
 | 
				
			||||||
 | 
					    FtToastEvents.$off('toast.open', this.open)
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@ import FtButton from '../ft-button/ft-button.vue'
 | 
				
			||||||
import FtListDropdown from '../ft-list-dropdown/ft-list-dropdown.vue'
 | 
					import FtListDropdown from '../ft-list-dropdown/ft-list-dropdown.vue'
 | 
				
			||||||
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
 | 
					import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
 | 
				
			||||||
import FtIconButton from '../ft-icon-button/ft-icon-button.vue'
 | 
					import FtIconButton from '../ft-icon-button/ft-icon-button.vue'
 | 
				
			||||||
 | 
					import FtToastEvents from '../ft-toast/ft-toast-events'
 | 
				
			||||||
// import { shell } from 'electron'
 | 
					// import { shell } from 'electron'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default Vue.extend({
 | 
					export default Vue.extend({
 | 
				
			||||||
| 
						 | 
					@ -146,6 +147,7 @@ export default Vue.extend({
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      switch (method) {
 | 
					      switch (method) {
 | 
				
			||||||
        case 'copyYoutube':
 | 
					        case 'copyYoutube':
 | 
				
			||||||
 | 
					          FtToastEvents.$emit('toast.open', "YouTube URL copied to clipboard")
 | 
				
			||||||
          navigator.clipboard.writeText(this.youtubeUrl)
 | 
					          navigator.clipboard.writeText(this.youtubeUrl)
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
        case 'openYoutube':
 | 
					        case 'openYoutube':
 | 
				
			||||||
| 
						 | 
					@ -155,6 +157,7 @@ export default Vue.extend({
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
        case 'copyYoutubeEmbed':
 | 
					        case 'copyYoutubeEmbed':
 | 
				
			||||||
 | 
					          FtToastEvents.$emit('toast.open', "YouTube Embed URL copied to clipboard")
 | 
				
			||||||
          navigator.clipboard.writeText(this.youtubeEmbedUrl)
 | 
					          navigator.clipboard.writeText(this.youtubeEmbedUrl)
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
        case 'openYoutubeEmbed':
 | 
					        case 'openYoutubeEmbed':
 | 
				
			||||||
| 
						 | 
					@ -164,6 +167,7 @@ export default Vue.extend({
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
        case 'copyInvidious':
 | 
					        case 'copyInvidious':
 | 
				
			||||||
 | 
					          FtToastEvents.$emit('toast.open', "Invidious URL copied to clipboard")
 | 
				
			||||||
          navigator.clipboard.writeText(this.invidiousUrl)
 | 
					          navigator.clipboard.writeText(this.invidiousUrl)
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
        case 'openInvidious':
 | 
					        case 'openInvidious':
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue