main.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import { createSSRApp } from 'vue'
  2. import App from './App.vue'
  3. // Polyfill for String.prototype.startsWith (for older browsers)
  4. if (!String.prototype.startsWith) {
  5. String.prototype.startsWith = function(search, pos) {
  6. pos = !pos || pos < 0 ? 0 : +pos
  7. return this.substring(pos, pos + search.length) === search
  8. }
  9. }
  10. // Polyfill for String.prototype.endsWith (for older browsers)
  11. if (!String.prototype.endsWith) {
  12. String.prototype.endsWith = function(search, this_len) {
  13. if (this_len === undefined || this_len > this.length) {
  14. this_len = this.length
  15. }
  16. return this.substring(this_len - search.length, this_len) === search
  17. }
  18. }
  19. // Polyfill for String.prototype.includes (for older browsers)
  20. if (!String.prototype.includes) {
  21. String.prototype.includes = function(search, start) {
  22. if (typeof start !== 'number') {
  23. start = 0
  24. }
  25. if (start + search.length > this.length) {
  26. return false
  27. } else {
  28. return this.indexOf(search, start) !== -1
  29. }
  30. }
  31. }
  32. // Polyfill for Array.prototype.includes (for older browsers)
  33. if (!Array.prototype.includes) {
  34. Array.prototype.includes = function(searchElement, fromIndex) {
  35. if (this == null) {
  36. throw new TypeError('"this" is null or not defined')
  37. }
  38. var o = Object(this)
  39. var len = o.length >>> 0
  40. if (len === 0) {
  41. return false
  42. }
  43. var n = fromIndex | 0
  44. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0)
  45. while (k < len) {
  46. if (o[k] === searchElement) {
  47. return true
  48. }
  49. k++
  50. }
  51. return false
  52. }
  53. }
  54. // Polyfill for String.prototype.repeat (for older browsers)
  55. if (!String.prototype.repeat) {
  56. String.prototype.repeat = function(count) {
  57. if (this == null) {
  58. throw new TypeError("can't convert " + this + ' to object')
  59. }
  60. var str = '' + this
  61. count = +count
  62. if (count != count) {
  63. count = 0
  64. }
  65. if (count < 0) {
  66. throw new RangeError('repeat count must be non-negative')
  67. }
  68. if (count == Infinity) {
  69. throw new RangeError('repeat count must be less than infinity')
  70. }
  71. count = Math.floor(count)
  72. if (str.length == 0 || count == 0) {
  73. return ''
  74. }
  75. if (str.length * count >= 1 << 28) {
  76. throw new RangeError('repeat count must not overflow maximum string size')
  77. }
  78. var maxCount = str.length * count
  79. count = Math.floor(Math.log(count) / Math.log(2))
  80. while (count) {
  81. str += str
  82. count--
  83. }
  84. str += str.substring(0, maxCount - str.length)
  85. return str
  86. }
  87. }
  88. // Polyfill for String.prototype.padStart (for older browsers)
  89. if (!String.prototype.padStart) {
  90. String.prototype.padStart = function padStart(targetLength, padString) {
  91. targetLength = targetLength >> 0
  92. padString = String(typeof padString !== 'undefined' ? padString : ' ')
  93. if (this.length >= targetLength) {
  94. return String(this)
  95. } else {
  96. targetLength = targetLength - this.length
  97. if (targetLength > padString.length) {
  98. padString += padString.repeat(targetLength / padString.length)
  99. }
  100. return padString.slice(0, targetLength) + String(this)
  101. }
  102. }
  103. }
  104. // Polyfill for String.prototype.padEnd (for older browsers)
  105. if (!String.prototype.padEnd) {
  106. String.prototype.padEnd = function padEnd(targetLength, padString) {
  107. targetLength = targetLength >> 0
  108. padString = String(typeof padString !== 'undefined' ? padString : ' ')
  109. if (this.length >= targetLength) {
  110. return String(this)
  111. } else {
  112. targetLength = targetLength - this.length
  113. if (targetLength > padString.length) {
  114. padString += padString.repeat(targetLength / padString.length)
  115. }
  116. return String(this) + padString.slice(0, targetLength)
  117. }
  118. }
  119. }
  120. export function createApp() {
  121. const app = createSSRApp(App)
  122. return {
  123. app
  124. }
  125. }