index.js 754 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import events from './events'
  2. import MultiTab from './MultiTab'
  3. import './index.less'
  4. const api = {
  5. /**
  6. * open new tab on route fullPath
  7. * @param config
  8. */
  9. open: function (config) {
  10. events.$emit('open', config)
  11. },
  12. rename: function (key, name) {
  13. events.$emit('rename', { key: key, name: name })
  14. },
  15. /**
  16. * close current page
  17. */
  18. closeCurrentPage: function () {
  19. this.close()
  20. },
  21. /**
  22. * close route fullPath tab
  23. * @param config
  24. */
  25. close: function (config) {
  26. events.$emit('close', config)
  27. }
  28. }
  29. MultiTab.install = function (Vue) {
  30. if (Vue.prototype.$multiTab) {
  31. return
  32. }
  33. api.instance = events
  34. Vue.prototype.$multiTab = api
  35. Vue.component('multi-tab', MultiTab)
  36. }
  37. export default MultiTab