mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
chore: update element-plus to the latest version
This commit is contained in:
parent
74ef4e1722
commit
666e755ae5
1437
package-lock.json
generated
1437
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -26,10 +26,10 @@
|
|||||||
"await-to-js": "^3.0.0",
|
"await-to-js": "^3.0.0",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"cropperjs": "^1.5.11",
|
"cropperjs": "^1.5.11",
|
||||||
"dayjs": "^1.10.5",
|
"dayjs": "^1.10.6",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"echarts": "^5.1.1",
|
"echarts": "^5.1.1",
|
||||||
"element-plus": "^1.0.2-beta.53",
|
"element-plus": "^1.0.2-beta.71",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"mitt": "^2.1.0",
|
"mitt": "^2.1.0",
|
||||||
@ -76,12 +76,12 @@
|
|||||||
"postcss": "^8.2.6",
|
"postcss": "^8.2.6",
|
||||||
"postcss-import": "^14.0.0",
|
"postcss-import": "^14.0.0",
|
||||||
"prettier": "^2.3.2",
|
"prettier": "^2.3.2",
|
||||||
"sass": "^1.32.8",
|
"sass": "^1.38.0",
|
||||||
"sass-loader": "^11.0.1",
|
"sass-loader": "^12.1.0",
|
||||||
"typescript": "^4.2.4",
|
"typescript": "^4.2.4",
|
||||||
"vite": "^2.4.3",
|
"vite": "^2.5.0",
|
||||||
"vite-plugin-mock": "^2.8.0",
|
"vite-plugin-mock": "^2.8.0",
|
||||||
"vite-plugin-style-import": "^1.0.1",
|
"vite-plugin-style-import": "^1.1.1",
|
||||||
"vue-eslint-parser": "^7.7.2"
|
"vue-eslint-parser": "^7.7.2"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
24
src/App.vue
24
src/App.vue
@ -1,3 +1,27 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<el-config-provider :locale="currentLocale">
|
||||||
<router-view />
|
<router-view />
|
||||||
|
</el-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ElConfigProvider } from "element-plus";
|
||||||
|
import zhCn from "element-plus/lib/locale/lang/zh-cn";
|
||||||
|
import en from "element-plus/lib/locale/lang/en";
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
[ElConfigProvider.name]: ElConfigProvider
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
// eslint-disable-next-line vue/return-in-computed-property
|
||||||
|
currentLocale() {
|
||||||
|
switch (this.$storage.locale?.locale) {
|
||||||
|
case "zh":
|
||||||
|
return zhCn;
|
||||||
|
case "en":
|
||||||
|
return en;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
<div
|
<div
|
||||||
v-show="!deviceDetection()"
|
v-show="!deviceDetection()"
|
||||||
class="inter"
|
class="inter"
|
||||||
:title="langs ? '中文' : 'English'"
|
:title="currentLocale ? '中文' : 'English'"
|
||||||
@click="toggleLang"
|
@click="toggleLang"
|
||||||
>
|
>
|
||||||
<img :src="langs ? ch : en" />
|
<img :src="currentLocale ? ch : en" />
|
||||||
</div>
|
</div>
|
||||||
<i
|
<i
|
||||||
class="el-icon-setting hsset"
|
class="el-icon-setting hsset"
|
||||||
@ -33,9 +33,9 @@
|
|||||||
</span>
|
</span>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item icon="el-icon-switch-button" @click="logout">{{
|
<el-dropdown-item icon="el-icon-switch-button" @click="logout">
|
||||||
$t("message.hsLoginOut")
|
{{ $t("message.hsLoginOut") }}
|
||||||
}}</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
@ -44,7 +44,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, defineComponent, onMounted, unref, watch } from "vue";
|
import {
|
||||||
|
defineComponent,
|
||||||
|
onMounted,
|
||||||
|
unref,
|
||||||
|
watch,
|
||||||
|
getCurrentInstance
|
||||||
|
} from "vue";
|
||||||
import Breadcrumb from "/@/components/ReBreadCrumb";
|
import Breadcrumb from "/@/components/ReBreadCrumb";
|
||||||
import Hamburger from "/@/components/ReHamBurger";
|
import Hamburger from "/@/components/ReHamBurger";
|
||||||
import screenfull from "../components/screenfull/index.vue";
|
import screenfull from "../components/screenfull/index.vue";
|
||||||
@ -58,10 +64,6 @@ import { emitter } from "/@/utils/mitt";
|
|||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
import ElementLocale from "element-plus/lib/locale";
|
|
||||||
import enLocale from "element-plus/lib/locale/lang/en";
|
|
||||||
import zhLocale from "element-plus/lib/locale/lang/zh-cn";
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "Navbar",
|
name: "Navbar",
|
||||||
components: {
|
components: {
|
||||||
@ -69,9 +71,25 @@ export default defineComponent({
|
|||||||
Hamburger,
|
Hamburger,
|
||||||
screenfull
|
screenfull
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
// eslint-disable-next-line vue/return-in-computed-property
|
||||||
|
currentLocale() {
|
||||||
|
if (!this.$storage.locale) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
this.$storage.locale = { locale: "zh" }
|
||||||
|
useI18n().locale.value = "zh";
|
||||||
|
}
|
||||||
|
switch (this.$storage.locale?.locale) {
|
||||||
|
case "zh":
|
||||||
|
return true;
|
||||||
|
case "en":
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
setup() {
|
setup() {
|
||||||
let langs = ref(true);
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let vm: any;
|
||||||
const pureApp = useAppStoreHook();
|
const pureApp = useAppStoreHook();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -82,18 +100,20 @@ export default defineComponent({
|
|||||||
|
|
||||||
// 国际化语言切换
|
// 国际化语言切换
|
||||||
const toggleLang = (): void => {
|
const toggleLang = (): void => {
|
||||||
langs.value = !langs.value;
|
switch (vm.locale.locale) {
|
||||||
if (langs.value) {
|
case "zh":
|
||||||
locale.value = "zh";
|
vm.locale = { locale: "en" };
|
||||||
ElementLocale.use(zhLocale);
|
|
||||||
} else {
|
|
||||||
locale.value = "en";
|
locale.value = "en";
|
||||||
ElementLocale.use(enLocale);
|
break;
|
||||||
|
case "en":
|
||||||
|
vm.locale = { locale: "zh" };
|
||||||
|
locale.value = "zh";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => langs.value,
|
() => locale.value,
|
||||||
() => {
|
() => {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
document.title = t(unref(route.meta.title)); // 动态title
|
document.title = t(unref(route.meta.title)); // 动态title
|
||||||
@ -115,6 +135,8 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
vm = getCurrentInstance().appContext.config.globalProperties.$storage;
|
||||||
document
|
document
|
||||||
.querySelector(".el-dropdown__popper")
|
.querySelector(".el-dropdown__popper")
|
||||||
?.setAttribute("class", "resetTop");
|
?.setAttribute("class", "resetTop");
|
||||||
@ -126,7 +148,6 @@ export default defineComponent({
|
|||||||
return {
|
return {
|
||||||
pureApp,
|
pureApp,
|
||||||
toggleSideBar,
|
toggleSideBar,
|
||||||
langs,
|
|
||||||
usename,
|
usename,
|
||||||
toggleLang,
|
toggleLang,
|
||||||
logout,
|
logout,
|
||||||
|
@ -29,7 +29,7 @@ import Storage from "responsive-storage";
|
|||||||
app.use(Storage, {
|
app.use(Storage, {
|
||||||
// 默认显示首页tag
|
// 默认显示首页tag
|
||||||
routesInStorage: {
|
routesInStorage: {
|
||||||
type: String,
|
type: Array,
|
||||||
default: Storage.getData(undefined, "routesInStorage") ?? [
|
default: Storage.getData(undefined, "routesInStorage") ?? [
|
||||||
{
|
{
|
||||||
path: "/welcome",
|
path: "/welcome",
|
||||||
@ -41,6 +41,13 @@ app.use(Storage, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
// 国际化 默认中文zh
|
||||||
|
locale: {
|
||||||
|
type: Object,
|
||||||
|
default: Storage.getData(undefined, "locale") ?? {
|
||||||
|
locale: "zh"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -69,10 +69,6 @@ const components = [
|
|||||||
|
|
||||||
const plugins = [ElLoading];
|
const plugins = [ElLoading];
|
||||||
|
|
||||||
import ElementLocale from "element-plus/lib/locale";
|
|
||||||
import zhLocale from "element-plus/lib/locale/lang/zh-cn";
|
|
||||||
ElementLocale.use(zhLocale);
|
|
||||||
|
|
||||||
export function useElementPlus(app: App) {
|
export function useElementPlus(app: App) {
|
||||||
components.forEach((component: Component) => {
|
components.forEach((component: Component) => {
|
||||||
app.component(component.name, component);
|
app.component(component.name, component);
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
import { App } from "vue";
|
import { App } from "vue";
|
||||||
import { createI18n } from "vue-i18n";
|
import { createI18n } from "vue-i18n";
|
||||||
import { localesConfigs } from "./config";
|
import { localesConfigs } from "./config";
|
||||||
|
import { storageLocal } from "/@/utils/storage";
|
||||||
|
|
||||||
export const i18n = createI18n({
|
export const i18n = createI18n({
|
||||||
locale: "zh", // set locale
|
locale: storageLocal.getItem("responsive-locale")?.locale ?? "zh",
|
||||||
fallbackLocale: "en", // set fallback locale
|
fallbackLocale: "en",
|
||||||
messages: localesConfigs
|
messages: localesConfigs
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user