文件操作 - utils.js
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/@nuxtjs/i18n/dist/runtime/routing/utils.js
编辑文件内容
import { isFunction } from "@intlify/shared"; import { localeCodes } from "#build/i18n.options.mjs"; import { useRuntimeConfig } from "#app"; export function getNormalizedLocales(locales) { return locales.map((x) => typeof x === "string" ? { code: x } : x); } export function getRouteName(routeName) { if (typeof routeName === "string") return routeName; if (routeName != null) return routeName.toString(); return "(null)"; } export function getLocaleRouteName(routeName, locale, { defaultLocale, strategy, routesNameSeparator, defaultLocaleRouteNameSuffix, differentDomains }) { const localizedRoutes = strategy !== "no_prefix" || differentDomains; let name = getRouteName(routeName) + (localizedRoutes ? routesNameSeparator + locale : ""); if (locale === defaultLocale && strategy === "prefix_and_default") { name += routesNameSeparator + defaultLocaleRouteNameSuffix; } return name; } export function resolveBaseUrl(baseUrl, context) { if (isFunction(baseUrl)) { return baseUrl(context); } return baseUrl; } function matchBrowserLocale(locales, browserLocales) { const matchedLocales = []; for (const [index, browserCode] of browserLocales.entries()) { const matchedLocale = locales.find((l) => l.language.toLowerCase() === browserCode.toLowerCase()); if (matchedLocale) { matchedLocales.push({ code: matchedLocale.code, score: 1 - index / browserLocales.length }); break; } } for (const [index, browserCode] of browserLocales.entries()) { const languageCode = browserCode.split("-")[0].toLowerCase(); const matchedLocale = locales.find((l) => l.language.split("-")[0].toLowerCase() === languageCode); if (matchedLocale) { matchedLocales.push({ code: matchedLocale.code, score: 0.999 - index / browserLocales.length }); break; } } return matchedLocales; } function compareBrowserLocale(a, b) { if (a.score === b.score) { return b.code.length - a.code.length; } return b.score - a.score; } export function findBrowserLocale(locales, browserLocales, { matcher = matchBrowserLocale, comparer = compareBrowserLocale } = {}) { const normalizedLocales = []; for (const l of locales) { const { code } = l; const language = l.language || code; normalizedLocales.push({ code, language }); } const matchedLocales = matcher(normalizedLocales, browserLocales); if (matchedLocales.length === 0) { return ""; } if (matchedLocales.length > 1) { matchedLocales.sort(comparer); } return matchedLocales[0].code; } export function getLocalesRegex(localeCodes2) { return new RegExp(`^/(${localeCodes2.join("|")})(?:/|$)`, "i"); } const localesPattern = `(${localeCodes.join("|")})`; const regexpPath = getLocalesRegex(localeCodes); export function createLocaleFromRouteGetter() { const { routesNameSeparator, defaultLocaleRouteNameSuffix } = useRuntimeConfig().public.i18n; const defaultSuffixPattern = `(?:${routesNameSeparator}${defaultLocaleRouteNameSuffix})?`; const regexpName = new RegExp(`${routesNameSeparator}${localesPattern}${defaultSuffixPattern}$`, "i"); const getLocaleFromRoute = (route) => { let matches = null; if (typeof route === "string") { matches = route.match(regexpPath); return matches?.[1] ?? ""; } if (route.name) { matches = getRouteName(route.name).match(regexpName); } else if (route.path) { matches = route.path.match(regexpPath); } return matches?.[1] ?? ""; }; return getLocaleFromRoute; }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件