feat: Access environment variables using import.meta

This commit is contained in:
coderwei
2025-05-21 11:41:50 +08:00
parent 8abae324a5
commit 4f15cec9ea
21 changed files with 84 additions and 31 deletions

View File

@@ -20,8 +20,8 @@ import { showMessageError } from "@/utils/dialog";
import { getLicenseInfo, getSystemInfo } from "@/store/cache";
const title = ref("");
const version = ref(process.env.VUE_APP_VERSION);
const gitURL = ref(process.env.VUE_APP_GIT_URL);
const version = ref(import.meta.env.VITE_APP_VERSION);
const gitURL = ref(import.meta.env.VITE_APP_GIT_URL);
const copyRight = ref("");
const license = ref({});
const props = defineProps({
@@ -34,7 +34,7 @@ const props = defineProps({
// 获取系统配置
getSystemInfo()
.then((res) => {
title.value = res.data.title ?? process.env.VUE_APP_TITLE;
title.value = res.data.title ?? import.meta.env.VITE_APP_TITLE;
copyRight.value =
res.data.copyright.length > 1
? res.data.copyright

View File

@@ -218,8 +218,8 @@ watch(
const login = ref(true);
const data = ref({
username: process.env.VUE_APP_USER,
password: process.env.VUE_APP_PASS,
username: import.meta.env.VITE_APP_USER,
password: import.meta.env.VITE_APP_PASS,
mobile: "",
email: "",
repass: "",

View File

@@ -107,7 +107,7 @@ const animateVoice = () => {
const wavRecorder = ref(new WavRecorder({ sampleRate: 24000 }));
const wavStreamPlayer = ref(new WavStreamPlayer({ sampleRate: 24000 }));
let host = process.env.VUE_APP_WS_HOST;
let host = import.meta.env.VITE_APP_WS_HOST;
if (host === "") {
if (location.protocol === "https:") {
host = "wss://" + location.host;

View File

@@ -62,8 +62,8 @@ import { onMounted, ref } from "vue";
import { ElMessage } from "element-plus";
import { getSystemInfo } from "@/store/cache";
const title = ref(process.env.VUE_APP_TITLE);
const version = ref(process.env.VUE_APP_VERSION);
const title = ref(import.meta.env.VITE_APP_TITLE);
const version = ref(import.meta.env.VITE_APP_VERSION);
const samples = ref([
"用小学生都能听懂的术语解释什么是量子纠缠",

View File

@@ -52,7 +52,7 @@ import {ElMessage} from "element-plus";
import {removeAdminToken} from "@/store/session";
import {useSharedStore} from "@/store/sharedata";
const version = ref(process.env.VUE_APP_VERSION);
const version = ref(import.meta.env.VITE_APP_VERSION);
const avatar = ref("/images/user-info.jpg");
const sidebar = useSidebarStore();
const router = useRouter();