dealSeoDetail.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. export default class DealSeoData {
  2. constructor({$axios, req, app, redirect, error}) {
  3. this.$axios = $axios
  4. this.req = req
  5. this.app = app
  6. this.redirect = redirect
  7. this.error = error
  8. this.skillDetail = {}
  9. this.isExist = true
  10. }
  11. async dealData() {
  12. let {
  13. name,
  14. query: { act },
  15. path,
  16. params,
  17. fullPath
  18. } = this.app.context.route
  19. const sale_id = params.id || ''
  20. // 重定向
  21. if (path.indexOf('/frontend/learn/detail') > -1) {
  22. this.redirect(301, '/l/' + sale_id)
  23. }
  24. const skillDetail = {}
  25. return {
  26. isExist: this.isExist,
  27. sale_id,
  28. skillDetail,
  29. mobile: this.app.$deviceType.isMobile(),
  30. head: this.dealThisMeta(),
  31. act
  32. }
  33. }
  34. dealThisMeta() {
  35. if (!this.isExist) {
  36. // 页面不存在时
  37. return {
  38. title: "页面不存在-程序员客栈",
  39. keyword: "",
  40. description: "",
  41. h1: "",
  42. canonical: "",
  43. metaLocation: ""
  44. }
  45. }
  46. let head = {
  47. title: `客栈学院`,
  48. keyword: `客栈学院`,
  49. description: `客栈学院`,
  50. h1: "",
  51. canonical: "",
  52. metaLocation: ""
  53. }
  54. return head
  55. }
  56. }