76 lines
1.6 KiB
Vue
76 lines
1.6 KiB
Vue
<template>
|
|
<el-config-provider :locale="currentLocale">
|
|
<div class="environment-badge" :aria-label="`当前环境:${appEnvLabel}`">
|
|
{{ appEnvLabel }}
|
|
</div>
|
|
<router-view />
|
|
<ReDialog />
|
|
</el-config-provider>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent } from "vue";
|
|
import { ElConfigProvider } from "element-plus";
|
|
import { ReDialog } from "@/components/ReDialog";
|
|
import zhCn from "element-plus/es/locale/lang/zh-cn";
|
|
|
|
export default defineComponent({
|
|
name: "app",
|
|
components: {
|
|
[ElConfigProvider.name]: ElConfigProvider,
|
|
ReDialog
|
|
},
|
|
data() {
|
|
const appEnv =
|
|
import.meta.env.VITE_APP_ENV ||
|
|
(import.meta.env.MODE === "development"
|
|
? "local"
|
|
: import.meta.env.MODE === "production"
|
|
? "production"
|
|
: "develop");
|
|
const defaultLabelMap = {
|
|
local: "本地环境",
|
|
develop: "测试环境",
|
|
production: "生产环境"
|
|
} as const;
|
|
|
|
return {
|
|
appEnvLabel:
|
|
import.meta.env.VITE_APP_ENV_LABEL ||
|
|
defaultLabelMap[appEnv as keyof typeof defaultLabelMap] ||
|
|
"本地环境"
|
|
};
|
|
},
|
|
computed: {
|
|
currentLocale() {
|
|
return zhCn;
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.environment-badge {
|
|
position: fixed;
|
|
top: 72px;
|
|
right: 16px;
|
|
z-index: 1000;
|
|
padding: 8px 10px;
|
|
font-size: 12px;
|
|
font-weight: 750;
|
|
line-height: 1;
|
|
color: #fff;
|
|
letter-spacing: 0;
|
|
background: rgb(20 20 24 / 86%);
|
|
border-radius: 999px;
|
|
box-shadow: 0 10px 24px rgb(0 0 0 / 16%);
|
|
}
|
|
|
|
@media (width <= 768px) {
|
|
.environment-badge {
|
|
top: 16px;
|
|
right: 16px;
|
|
}
|
|
}
|
|
</style>
|