mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
Merge branch 'main' into feat/headerNotice
This commit is contained in:
commit
c4a6a337a3
@ -11,7 +11,7 @@ import { unref, watch, getCurrentInstance } from "vue";
|
|||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||||
import screenfull from "../components/screenfull/index.vue";
|
import screenfull from "../components/screenfull/index.vue";
|
||||||
import globalization from "/@/assets/svg/globalization.svg";
|
import globalization from "/@/assets/svg/globalization.svg";
|
||||||
import { getMessage } from "/@/utils/i18n";
|
import { transformI18n } from "/@/utils/i18n";
|
||||||
|
|
||||||
const instance =
|
const instance =
|
||||||
getCurrentInstance().appContext.config.globalProperties.$storage;
|
getCurrentInstance().appContext.config.globalProperties.$storage;
|
||||||
@ -25,7 +25,7 @@ watch(
|
|||||||
() => locale.value,
|
() => locale.value,
|
||||||
() => {
|
() => {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
document.title = getMessage(
|
document.title = transformI18n(
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
unref(route.meta.title),
|
unref(route.meta.title),
|
||||||
unref(route.meta.i18n)
|
unref(route.meta.i18n)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
|
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
|
||||||
import { getMessage } from "/@/utils/i18n";
|
import { transformI18n } from "/@/utils/i18n";
|
||||||
|
|
||||||
const levelList = ref([]);
|
const levelList = ref([]);
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -38,9 +38,6 @@ watch(
|
|||||||
() => route.path,
|
() => route.path,
|
||||||
() => getBreadcrumb()
|
() => getBreadcrumb()
|
||||||
);
|
);
|
||||||
const getI18nMessage = meta => {
|
|
||||||
return getMessage(meta.title, meta.i18n);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleLink = (item: RouteLocationMatched): any => {
|
const handleLink = (item: RouteLocationMatched): any => {
|
||||||
const { redirect, path } = item;
|
const { redirect, path } = item;
|
||||||
@ -59,10 +56,10 @@ const handleLink = (item: RouteLocationMatched): any => {
|
|||||||
<span
|
<span
|
||||||
v-if="item.redirect === 'noRedirect' || index == levelList.length - 1"
|
v-if="item.redirect === 'noRedirect' || index == levelList.length - 1"
|
||||||
class="no-redirect"
|
class="no-redirect"
|
||||||
>{{ getI18nMessage(item.meta) }}</span
|
>{{ transformI18n(item.meta.title, item.meta.i18n) }}</span
|
||||||
>
|
>
|
||||||
<a v-else @click.prevent="handleLink(item)">
|
<a v-else @click.prevent="handleLink(item)">
|
||||||
{{ getI18nMessage(item.meta) }}
|
{{ transformI18n(item.meta.title, item.meta.i18n) }}
|
||||||
</a>
|
</a>
|
||||||
</el-breadcrumb-item>
|
</el-breadcrumb-item>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
|
@ -4,7 +4,7 @@ import { PropType, ref, nextTick, getCurrentInstance } from "vue";
|
|||||||
import { childrenType } from "../../types";
|
import { childrenType } from "../../types";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
import { useAppStoreHook } from "/@/store/modules/app";
|
||||||
import Icon from "/@/components/ReIcon/src/Icon.vue";
|
import Icon from "/@/components/ReIcon/src/Icon.vue";
|
||||||
import { getMessage } from "/@/utils/i18n";
|
import { transformI18n } from "/@/utils/i18n";
|
||||||
import { findIconReg } from "/@/components/ReIcon";
|
import { findIconReg } from "/@/components/ReIcon";
|
||||||
const instance = getCurrentInstance().appContext.app.config.globalProperties;
|
const instance = getCurrentInstance().appContext.app.config.globalProperties;
|
||||||
const menuMode = instance.$storage.layout?.layout === "vertical";
|
const menuMode = instance.$storage.layout?.layout === "vertical";
|
||||||
@ -111,7 +111,7 @@ function resolvePath(routePath) {
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span v-if="!menuMode">{{
|
<span v-if="!menuMode">{{
|
||||||
getMessage(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
|
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
|
||||||
}}</span>
|
}}</span>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
v-else
|
v-else
|
||||||
@ -120,7 +120,9 @@ function resolvePath(routePath) {
|
|||||||
:disabled="!onlyOneChild.showTooltip"
|
:disabled="!onlyOneChild.showTooltip"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
{{ getMessage(onlyOneChild.meta.title, onlyOneChild.meta.i18n) }}
|
{{
|
||||||
|
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
|
||||||
|
}}
|
||||||
</template>
|
</template>
|
||||||
<span
|
<span
|
||||||
ref="menuTextRef"
|
ref="menuTextRef"
|
||||||
@ -131,7 +133,9 @@ function resolvePath(routePath) {
|
|||||||
}"
|
}"
|
||||||
@mouseover="hoverMenu(onlyOneChild)"
|
@mouseover="hoverMenu(onlyOneChild)"
|
||||||
>
|
>
|
||||||
{{ getMessage(onlyOneChild.meta.title, onlyOneChild.meta.i18n) }}
|
{{
|
||||||
|
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<Icon
|
<Icon
|
||||||
@ -157,7 +161,7 @@ function resolvePath(routePath) {
|
|||||||
></component>
|
></component>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<span v-if="!menuMode">{{
|
<span v-if="!menuMode">{{
|
||||||
getMessage(props.item.meta.title, props.item.meta.i18n)
|
transformI18n(props.item.meta.title, props.item.meta.i18n)
|
||||||
}}</span>
|
}}</span>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
v-else
|
v-else
|
||||||
@ -166,7 +170,7 @@ function resolvePath(routePath) {
|
|||||||
:disabled="!pureApp.sidebar.opened || !props.item.showTooltip"
|
:disabled="!pureApp.sidebar.opened || !props.item.showTooltip"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
{{ getMessage(props.item.meta.title, props.item.meta.i18n) }}
|
{{ transformI18n(props.item.meta.title, props.item.meta.i18n) }}
|
||||||
</template>
|
</template>
|
||||||
<div
|
<div
|
||||||
ref="menuTextRef"
|
ref="menuTextRef"
|
||||||
@ -179,7 +183,7 @@ function resolvePath(routePath) {
|
|||||||
@mouseover="hoverMenu(props.item)"
|
@mouseover="hoverMenu(props.item)"
|
||||||
>
|
>
|
||||||
<span style="overflow: hidden; text-overflow: ellipsis">
|
<span style="overflow: hidden; text-overflow: ellipsis">
|
||||||
{{ getMessage(props.item.meta.title, props.item.meta.i18n) }}
|
{{ transformI18n(props.item.meta.title, props.item.meta.i18n) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
@ -6,6 +6,7 @@ let routerArrays: Array<RouteConfigs> = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: "message.hshome",
|
title: "message.hshome",
|
||||||
icon: "el-icon-s-home",
|
icon: "el-icon-s-home",
|
||||||
|
i18n: true,
|
||||||
showLink: true
|
showLink: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,6 +32,7 @@ import { storageLocal } from "/@/utils/storage";
|
|||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||||
import { toggleClass, removeClass, hasClass } from "/@/utils/operate";
|
import { toggleClass, removeClass, hasClass } from "/@/utils/operate";
|
||||||
|
import { transformI18n } from "/@/utils/i18n";
|
||||||
|
|
||||||
import close from "/@/assets/svg/close.svg";
|
import close from "/@/assets/svg/close.svg";
|
||||||
import refresh from "/@/assets/svg/refresh.svg";
|
import refresh from "/@/assets/svg/refresh.svg";
|
||||||
@ -166,6 +168,7 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
|
|||||||
parentPath: "/",
|
parentPath: "/",
|
||||||
meta: {
|
meta: {
|
||||||
title: "message.hshome",
|
title: "message.hshome",
|
||||||
|
i18n: true,
|
||||||
icon: "el-icon-s-home",
|
icon: "el-icon-s-home",
|
||||||
showLink: true
|
showLink: true
|
||||||
}
|
}
|
||||||
@ -481,7 +484,7 @@ onBeforeMount(() => {
|
|||||||
@mouseleave.prevent="onMouseleave(item, index)"
|
@mouseleave.prevent="onMouseleave(item, index)"
|
||||||
>
|
>
|
||||||
<router-link :to="item.path" @click="tagOnClick(item)">{{
|
<router-link :to="item.path" @click="tagOnClick(item)">{{
|
||||||
$t(item.meta.title)
|
transformI18n(item.meta.title, item.meta.i18n)
|
||||||
}}</router-link>
|
}}</router-link>
|
||||||
<el-icon
|
<el-icon
|
||||||
v-if="
|
v-if="
|
||||||
|
@ -4,6 +4,7 @@ export const routerArrays: Array<RouteConfigs> = [
|
|||||||
parentPath: "/",
|
parentPath: "/",
|
||||||
meta: {
|
meta: {
|
||||||
title: "message.hshome",
|
title: "message.hshome",
|
||||||
|
i18n: true,
|
||||||
icon: "el-icon-s-home",
|
icon: "el-icon-s-home",
|
||||||
showLink: true
|
showLink: true
|
||||||
}
|
}
|
||||||
@ -15,6 +16,7 @@ export type RouteConfigs = {
|
|||||||
parentPath?: string;
|
parentPath?: string;
|
||||||
meta?: {
|
meta?: {
|
||||||
title?: string;
|
title?: string;
|
||||||
|
i18n?: boolean;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
showLink?: boolean;
|
showLink?: boolean;
|
||||||
savedPosition?: boolean;
|
savedPosition?: boolean;
|
||||||
|
@ -25,7 +25,7 @@ import flowChartRouter from "./modules/flowchart";
|
|||||||
import componentsRouter from "./modules/components";
|
import componentsRouter from "./modules/components";
|
||||||
// 动态路由
|
// 动态路由
|
||||||
import { getAsyncRoutes } from "/@/api/routes";
|
import { getAsyncRoutes } from "/@/api/routes";
|
||||||
import { getMessage } from "../utils/i18n";
|
import { transformI18n } from "../utils/i18n";
|
||||||
|
|
||||||
// https://cn.vitejs.dev/guide/features.html#glob-import
|
// https://cn.vitejs.dev/guide/features.html#glob-import
|
||||||
const modulesRoutes = import.meta.glob("/src/views/*/*/*.vue");
|
const modulesRoutes = import.meta.glob("/src/views/*/*/*.vue");
|
||||||
@ -214,7 +214,7 @@ router.beforeEach((to, _from, next) => {
|
|||||||
if (!externalLink)
|
if (!externalLink)
|
||||||
to.meta.title
|
to.meta.title
|
||||||
? // @ts-ignore
|
? // @ts-ignore
|
||||||
(document.title = getMessage(to.meta.title, to.meta.i18n))
|
(document.title = transformI18n(to.meta.title, to.meta.i18n))
|
||||||
: "";
|
: "";
|
||||||
if (name) {
|
if (name) {
|
||||||
if (_from?.name) {
|
if (_from?.name) {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { i18n } from "../plugins/i18n";
|
import { i18n } from "../plugins/i18n";
|
||||||
/**
|
/**
|
||||||
* 获取对应的消息
|
* 消息转换
|
||||||
* @param message message
|
* @param message message
|
||||||
* @param isI18n 如果true,获取对应的消息,否则返回this
|
* @param isI18n 如果true,获取对应的消息,否则返回this
|
||||||
* @returns message
|
* @returns message
|
||||||
*/
|
*/
|
||||||
export function getMessage(message = "", isI18n: Boolean = false) {
|
export function transformI18n(message = "", isI18n: Boolean = false) {
|
||||||
if (!message) {
|
if (!message) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user