mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-01 18:07:22 +00:00
Compare commits
6 Commits
de55966349
...
6097d039c3
Author | SHA1 | Date | |
---|---|---|---|
|
6097d039c3 | ||
|
9bf8465806 | ||
|
f94d3f2bc6 | ||
|
9c8cd4b74b | ||
|
df5038a272 | ||
|
d8d89b9dee |
@ -21,8 +21,8 @@ Or follow the steps below to set up a new Nuxt project on your computer.
|
|||||||
<!-- markdownlint-disable-next-line MD001 -->
|
<!-- markdownlint-disable-next-line MD001 -->
|
||||||
#### Prerequisites
|
#### Prerequisites
|
||||||
|
|
||||||
- **Node.js** - [`v18.0.0`](https://nodejs.org/en) or newer
|
- **Node.js** - [`18.x`](https://nodejs.org/en) or newer (but we recommend the [active LTS release](https://github.com/nodejs/release#release-schedule))
|
||||||
- **Text editor** - We recommend [Visual Studio Code](https://code.visualstudio.com/) with the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously known as Volar)
|
- **Text editor** - There is no IDE requirement, but we recommend [Visual Studio Code](https://code.visualstudio.com/) with the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously known as Volar) or [WebStorm](https://www.jetbrains.com/webstorm/), which, along with [other JetBrains IDEs](https://www.jetbrains.com/ides/), offers great Nuxt support right out-of-the-box.
|
||||||
- **Terminal** - In order to run Nuxt commands
|
- **Terminal** - In order to run Nuxt commands
|
||||||
|
|
||||||
::note
|
::note
|
||||||
|
@ -189,7 +189,6 @@ export default createConfigForNuxt({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Sort rule keys in eslint config
|
// Sort rule keys in eslint config
|
||||||
// @ts-expect-error incorrect types 🤔
|
|
||||||
{
|
{
|
||||||
files: ['**/eslint.config.mjs'],
|
files: ['**/eslint.config.mjs'],
|
||||||
name: 'local/sort-eslint-config',
|
name: 'local/sort-eslint-config',
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
"@nuxt/ui-templates": "workspace:*",
|
"@nuxt/ui-templates": "workspace:*",
|
||||||
"@nuxt/vite-builder": "workspace:*",
|
"@nuxt/vite-builder": "workspace:*",
|
||||||
"@nuxt/webpack-builder": "workspace:*",
|
"@nuxt/webpack-builder": "workspace:*",
|
||||||
"@types/node": "22.9.0",
|
"@types/node": "22.9.1",
|
||||||
"@unhead/dom": "1.11.11",
|
"@unhead/dom": "1.11.11",
|
||||||
"@unhead/shared": "1.11.11",
|
"@unhead/shared": "1.11.11",
|
||||||
"@unhead/vue": "1.11.11",
|
"@unhead/vue": "1.11.11",
|
||||||
@ -75,7 +75,7 @@
|
|||||||
"@nuxt/webpack-builder": "workspace:*",
|
"@nuxt/webpack-builder": "workspace:*",
|
||||||
"@testing-library/vue": "8.1.0",
|
"@testing-library/vue": "8.1.0",
|
||||||
"@types/eslint__js": "8.42.3",
|
"@types/eslint__js": "8.42.3",
|
||||||
"@types/node": "22.9.0",
|
"@types/node": "22.9.1",
|
||||||
"@types/semver": "7.5.8",
|
"@types/semver": "7.5.8",
|
||||||
"@unhead/schema": "1.11.11",
|
"@unhead/schema": "1.11.11",
|
||||||
"@unhead/vue": "1.11.11",
|
"@unhead/vue": "1.11.11",
|
||||||
@ -91,7 +91,7 @@
|
|||||||
"devalue": "5.1.1",
|
"devalue": "5.1.1",
|
||||||
"eslint": "9.15.0",
|
"eslint": "9.15.0",
|
||||||
"eslint-plugin-no-only-tests": "3.3.0",
|
"eslint-plugin-no-only-tests": "3.3.0",
|
||||||
"eslint-plugin-perfectionist": "3.9.1",
|
"eslint-plugin-perfectionist": "4.0.2",
|
||||||
"eslint-typegen": "0.3.2",
|
"eslint-typegen": "0.3.2",
|
||||||
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
||||||
"happy-dom": "15.11.6",
|
"happy-dom": "15.11.6",
|
||||||
|
@ -28,13 +28,11 @@ export default <RouterConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hash routes on the same page, no page hook is fired so resolve here
|
// Hash routes on the same page, no page hook is fired so resolve here
|
||||||
if (to.path === from.path) {
|
if (to.path === from.path && !to.hash) {
|
||||||
if (from.hash && !to.hash) {
|
if (from.hash) {
|
||||||
return { left: 0, top: 0 }
|
return { left: 0, top: 0 }
|
||||||
}
|
}
|
||||||
if (to.hash) {
|
|
||||||
return { el: to.hash, top: _getHashElementScrollMarginTop(to.hash), behavior }
|
|
||||||
}
|
|
||||||
// The route isn't changing so keep current scroll position
|
// The route isn't changing so keep current scroll position
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -42,12 +40,15 @@ export default <RouterConfig> {
|
|||||||
// Wait for `page:transition:finish` or `page:finish` depending on if transitions are enabled or not
|
// Wait for `page:transition:finish` or `page:finish` depending on if transitions are enabled or not
|
||||||
const hasTransition = (route: RouteLocationNormalized) => !!(route.meta.pageTransition ?? defaultPageTransition)
|
const hasTransition = (route: RouteLocationNormalized) => !!(route.meta.pageTransition ?? defaultPageTransition)
|
||||||
const hookToWait = (hasTransition(from) && hasTransition(to)) ? 'page:transition:finish' : 'page:finish'
|
const hookToWait = (hasTransition(from) && hasTransition(to)) ? 'page:transition:finish' : 'page:finish'
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
nuxtApp.hooks.hookOnce(hookToWait, async () => {
|
nuxtApp.hooks.hookOnce(hookToWait, async () => {
|
||||||
await new Promise(resolve => setTimeout(resolve, 0))
|
await new Promise(resolve => setTimeout(resolve, 0))
|
||||||
|
|
||||||
if (to.hash) {
|
if (to.hash) {
|
||||||
position = { el: to.hash, top: _getHashElementScrollMarginTop(to.hash), behavior }
|
position = { el: to.hash, top: _getHashElementScrollMarginTop(to.hash), behavior }
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(position)
|
resolve(position)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -57,11 +58,13 @@ export default <RouterConfig> {
|
|||||||
function _getHashElementScrollMarginTop (selector: string): number {
|
function _getHashElementScrollMarginTop (selector: string): number {
|
||||||
try {
|
try {
|
||||||
const elem = document.querySelector(selector)
|
const elem = document.querySelector(selector)
|
||||||
|
|
||||||
if (elem) {
|
if (elem) {
|
||||||
return (Number.parseFloat(getComputedStyle(elem).scrollMarginTop) || 0) + (Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0)
|
return (Number.parseFloat(getComputedStyle(elem).scrollMarginTop) || 0) + (Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0)
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// ignore any errors parsing scrollMarginTop
|
// ignore any errors parsing scrollMarginTop
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
429
pnpm-lock.yaml
429
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user