文件操作 - route-locale-detect.js
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/@nuxtjs/i18n/dist/runtime/plugins/route-locale-detect.js
编辑文件内容
import { unref } from "vue"; import { hasPages } from "#build/i18n.options.mjs"; import { addRouteMiddleware, defineNuxtPlugin, defineNuxtRouteMiddleware } from "#imports"; import { createLogger } from "virtual:nuxt-i18n-logger"; import { detectLocale, detectRedirect, loadAndSetLocale, navigate } from "../utils.js"; import { createLocaleFromRouteGetter } from "../routing/utils.js"; export default defineNuxtPlugin({ name: "i18n:plugin:route-locale-detect", dependsOn: ["i18n:plugin"], async setup(nuxt) { const logger = /* @__PURE__ */ createLogger("plugin:route-locale-detect"); const nuxtApp = nuxt; const currentRoute = nuxtApp.$router.currentRoute; const getRouteLocale = createLocaleFromRouteGetter(); async function handleRouteDetect(to) { let detected = detectLocale(to, getRouteLocale(to), unref(nuxtApp.$i18n.locale), nuxtApp.$i18n.getLocaleCookie()); if (nuxtApp._vueI18n.__firstAccess) { nuxtApp._vueI18n.__setLocale(detected); await nuxtApp.$i18n.loadLocaleMessages(detected); } const modified = await nuxtApp.runWithContext(() => loadAndSetLocale(detected, nuxtApp._vueI18n.__firstAccess)); if (modified) { detected = unref(nuxtApp.$i18n.locale); } return detected; } if (!hasPages) { await handleRouteDetect(currentRoute.value); return; } const localeChangeMiddleware = defineNuxtRouteMiddleware(async (to, from) => { __DEBUG__ && logger.log("locale-changing middleware", to, from); const locale = await nuxtApp.runWithContext(() => handleRouteDetect(to)); const redirectPath = await nuxtApp.runWithContext( () => detectRedirect({ to, from, locale, routeLocale: getRouteLocale(to) }, true) ); nuxtApp._vueI18n.__firstAccess = false; __DEBUG__ && logger.log("redirectPath on locale-changing middleware", redirectPath); return await nuxtApp.runWithContext(() => navigate({ nuxtApp, redirectPath, locale, route: to })); }); addRouteMiddleware("locale-changing", localeChangeMiddleware, { global: true }); } });
修改文件时间
将文件时间修改为当前时间的前一年
删除文件