use.ts 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Vue from 'vue'
  2. import { useUrlSearchParams } from '@vueuse/core'
  3. /**
  4. * Toast 弹窗
  5. * @param text
  6. * @param duration
  7. */
  8. export function useToast(text, duration = 2000) {
  9. const thisInstance = Vue.prototype
  10. return thisInstance.$toast(text, duration)
  11. }
  12. /**
  13. * 获取当前页面 URL source 参数
  14. */
  15. export function useURLSource() {
  16. const params = useUrlSearchParams('history')
  17. return String(params.source) || ''
  18. }
  19. /**
  20. * 特殊 source 处理
  21. */
  22. export function useCustomSpecialSource() {
  23. let source = useURLSource()
  24. if (source) {
  25. const pathname = window.location.pathname
  26. //结构化数据
  27. if (pathname == '/front/structed/pc_index.html') {
  28. source += '_structed'
  29. }
  30. //招标文件解读
  31. if (pathname == '/bid/pc/page/bidfile_landpage') {
  32. source += '_bidfile'
  33. }
  34. //大会员
  35. if (pathname == '/big/page/index') {
  36. source += '_member'
  37. }
  38. }
  39. return source
  40. }