|
12 | 12 | typeof __pageRedirects !== 'undefined' && __pageRedirects[location.hash]
|
13 | 13 | const finalUrl = hashRedirect || v3Url
|
14 | 14 |
|
15 |
| - const preferV3 = localStorage.getItem('prefer-v3') |
16 |
| - if (preferV3 === 'true') { |
17 |
| - location.href = `https://vuejs.org${finalUrl}` |
18 |
| - } else if (preferV3 === 'false') { |
19 |
| - return |
20 |
| - } |
21 |
| - |
22 |
| - const today = new Date() |
23 |
| - const target = new Date('2022-05-07') |
24 |
| - const timeinmilisec = target.getTime() - today.getTime() |
25 |
| - const days = Math.ceil(timeinmilisec / (1000 * 60 * 60 * 24)) |
26 |
| - |
27 | 15 | const el = document.createElement('div')
|
28 | 16 | el.className = `v3-notice`
|
29 | 17 | el.innerHTML = `
|
|
32 | 20 | This page contains documentation for Vue 2. The Vue 3 version of the URL you are visiting is: <a id="v3-url" target="_blank"></a>.
|
33 | 21 | </p>
|
34 | 22 | <p>
|
35 |
| -The original URL, <code>https://vuejs.org<span id="original-url"></span></code> |
36 |
| -will permanantly redirect to the v3 URL above after <b>May 7th, 2022 (${days} days from now).</b> If you need |
37 |
| -future access to this v2 page, please use the v2-prefixed URL |
38 |
| -<code>https://v2.vuejs.org<span id="current-url"></span></code>. |
39 |
| -</p> |
40 |
| -<p> |
41 | 23 | You can learn more about the Vue 2 -> Vue 3 default version switch in
|
42 | 24 | <a target="_blank" href="https://blog.vuejs.org/posts/vue-3-as-the-new-default.html">this blog post</a>.
|
43 | 25 | </p>
|
44 | 26 | <p>
|
45 |
| -Would you like to start redirecting all v2 URLs to v3 right now? |
46 |
| -</p> |
47 |
| -<p> |
48 |
| -<a class="go">Yes</a> |
49 |
| -<a class="stay">Not yet</a> |
| 27 | + <a class="stay">Stay on Vue 2 docs</a> |
50 | 28 | </p>
|
51 | 29 | `.trim()
|
52 | 30 |
|
@@ -91,23 +69,10 @@ Would you like to start redirecting all v2 URLs to v3 right now?
|
91 | 69 | document.body.appendChild(style)
|
92 | 70 | document.body.appendChild(el)
|
93 | 71 |
|
94 |
| - el.querySelector('#original-url').textContent = location.pathname |
95 |
| - el.querySelector('#current-url').textContent = location.pathname |
96 |
| - const v3Link = el.querySelector('#v3-url') |
97 |
| - |
98 |
| - v3Link.textContent = |
99 |
| - v3Link.href = |
100 |
| - el.querySelector('.go').href = |
101 |
| - `https://vuejs.org${finalUrl}` |
102 |
| - |
103 |
| - el.querySelector('.go').addEventListener('click', () => { |
104 |
| - localStorage.setItem('prefer-v3', 'true') |
105 |
| - }) |
106 |
| - |
107 | 72 | el.querySelector('.stay').addEventListener('click', () => {
|
108 |
| - localStorage.setItem('prefer-v3', 'false') |
109 | 73 | document.body.removeChild(el)
|
110 |
| - document.body.removeChild(style) |
111 |
| - location.href = location.pathname |
112 | 74 | })
|
| 75 | + |
| 76 | + const v3Link = el.querySelector('#v3-url') |
| 77 | + v3Link.textContent = v3Link.href = `https://vuejs.org${finalUrl}` |
113 | 78 | })()
|
0 commit comments