feat: 完善环境标识配置
This commit was merged in pull request #1.
This commit is contained in:
+49
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<el-config-provider :locale="currentLocale">
|
||||
<div class="environment-badge" :aria-label="`当前环境:${appEnvLabel}`">
|
||||
{{ appEnvLabel }}
|
||||
</div>
|
||||
<router-view />
|
||||
<ReDialog />
|
||||
</el-config-provider>
|
||||
@@ -17,6 +20,27 @@ export default defineComponent({
|
||||
[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;
|
||||
@@ -24,3 +48,28 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user