mirror of https://github.com/halo-dev/halo
chore: remove unnecessary env (#6022)
#### What type of PR is this? /area ui /kind cleanup /milestone 2.16.x #### What this PR does / why we need it: 移除 UI 项目中不必要的环境变量配置。 1. VITE_API_URL:当前 Console 不会考虑独立部署,并且在开发环境是后端 Proxy 的 Console 请求,所以此变量没有任何意义。 2. VITE_BASE_URL:无意义,当前不考虑修改。 #### Does this PR introduce a user-facing change? ```release-note None ```pull/6009/head v2.16.0-rc.2
parent
296d8c5833
commit
a26b73e258
|
@ -1,2 +0,0 @@
|
|||
VITE_API_URL=
|
||||
VITE_BASE_URL=/console/
|
|
@ -1,2 +0,0 @@
|
|||
VITE_API_URL=
|
||||
VITE_BASE_URL=/console/
|
|
@ -6,12 +6,9 @@ export function useGlobalInfoFetch() {
|
|||
const { data } = useQuery<GlobalInfo>({
|
||||
queryKey: ["globalinfo"],
|
||||
queryFn: async () => {
|
||||
const { data } = await axios.get<GlobalInfo>(
|
||||
`${import.meta.env.VITE_API_URL}/actuator/globalinfo`,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
const { data } = await axios.get<GlobalInfo>(`/actuator/globalinfo`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
|
|
|
@ -47,7 +47,7 @@ const handleLogout = () => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await axios.post(`${import.meta.env.VITE_API_URL}/logout`, undefined, {
|
||||
await axios.post(`/logout`, undefined, {
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -88,9 +88,7 @@ const previewUrl = computed(() => {
|
|||
if (!selectedTheme.value) {
|
||||
return "#";
|
||||
}
|
||||
return `${import.meta.env.VITE_API_URL}/?preview-theme=${
|
||||
selectedTheme.value.metadata.name
|
||||
}`;
|
||||
return `/?preview-theme=${selectedTheme.value.metadata.name}`;
|
||||
});
|
||||
|
||||
const modalTitle = computed(() => {
|
||||
|
|
|
@ -31,12 +31,9 @@ const { currentUserHasPermission } = usePermission();
|
|||
const { data: info } = useQuery<Info>({
|
||||
queryKey: ["system-info"],
|
||||
queryFn: async () => {
|
||||
const { data } = await axios.get<Info>(
|
||||
`${import.meta.env.VITE_API_URL}/actuator/info`,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
const { data } = await axios.get<Info>(`/actuator/info`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
retry: 0,
|
||||
|
@ -45,12 +42,9 @@ const { data: info } = useQuery<Info>({
|
|||
const { data: globalInfo } = useQuery<GlobalInfo>({
|
||||
queryKey: ["system-global-info"],
|
||||
queryFn: async () => {
|
||||
const { data } = await axios.get<GlobalInfo>(
|
||||
`${import.meta.env.VITE_API_URL}/actuator/globalinfo`,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
const { data } = await axios.get<GlobalInfo>(`/actuator/globalinfo`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
retry: 0,
|
||||
|
@ -59,12 +53,9 @@ const { data: globalInfo } = useQuery<GlobalInfo>({
|
|||
const { data: startup } = useQuery<Startup>({
|
||||
queryKey: ["system-startup-info"],
|
||||
queryFn: async () => {
|
||||
const { data } = await axios.get<Startup>(
|
||||
`${import.meta.env.VITE_API_URL}/actuator/startup`,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
const { data } = await axios.get<Startup>(`/actuator/startup`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
retry: 0,
|
||||
|
@ -201,7 +192,7 @@ const handleCopy = () => {
|
|||
|
||||
const handleDownloadLogfile = () => {
|
||||
axios
|
||||
.get(`${import.meta.env.VITE_API_URL}/actuator/logfile`)
|
||||
.get(`/actuator/logfile`)
|
||||
.then((response) => {
|
||||
const blob = new Blob([response.data]);
|
||||
const downloadElement = document.createElement("a");
|
||||
|
|
|
@ -19,9 +19,7 @@ export async function setupPluginModules(app: App) {
|
|||
const pluginModuleStore = usePluginModuleStore();
|
||||
try {
|
||||
const { load } = useScriptTag(
|
||||
`${
|
||||
import.meta.env.VITE_API_URL
|
||||
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js?t=${Date.now()}`
|
||||
`/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js?t=${Date.now()}`
|
||||
);
|
||||
|
||||
await load();
|
||||
|
@ -43,9 +41,7 @@ export async function setupPluginModules(app: App) {
|
|||
|
||||
try {
|
||||
await loadStyle(
|
||||
`${
|
||||
import.meta.env.VITE_API_URL
|
||||
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.css?t=${Date.now()}`
|
||||
`/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.css?t=${Date.now()}`
|
||||
);
|
||||
} catch (e) {
|
||||
const message = i18n.global.t("core.plugin.loader.toast.style_load_failed");
|
||||
|
|
|
@ -57,7 +57,7 @@ async function handleLogin(data: {
|
|||
encrypt.setPublicKey(publicKey.base64Format as string);
|
||||
|
||||
await axios.post(
|
||||
`${import.meta.env.VITE_API_URL}/login?remember-me=${data.rememberMe}`,
|
||||
`/login?remember-me=${data.rememberMe}`,
|
||||
qs.stringify({
|
||||
_csrf: _csrf.value,
|
||||
username: data.username,
|
||||
|
|
|
@ -20,7 +20,7 @@ async function onSubmit({ code }: { code: string }) {
|
|||
return;
|
||||
}
|
||||
await axios.post(
|
||||
`${import.meta.env.VITE_API_URL}/login/2fa/totp`,
|
||||
`/login/2fa/totp`,
|
||||
qs.stringify({
|
||||
code,
|
||||
_csrf,
|
||||
|
|
|
@ -66,7 +66,7 @@ const uppy = computed(() => {
|
|||
autoProceed: props.autoProceed,
|
||||
})
|
||||
.use(XHRUpload, {
|
||||
endpoint: `${import.meta.env.VITE_API_URL}${props.endpoint}`,
|
||||
endpoint: `${props.endpoint}`,
|
||||
allowedMetaFields: props.allowedMetaFields,
|
||||
withCredentials: true,
|
||||
formData: true,
|
||||
|
|
|
@ -7,12 +7,9 @@ export const useGlobalInfoStore = defineStore("global-info", () => {
|
|||
const globalInfo = ref<GlobalInfo>();
|
||||
|
||||
async function fetchGlobalInfo() {
|
||||
const { data } = await axios.get<GlobalInfo>(
|
||||
`${import.meta.env.VITE_API_URL}/actuator/globalinfo`,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
const { data } = await axios.get<GlobalInfo>(`/actuator/globalinfo`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
globalInfo.value = data;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ import { useUserStore } from "@/stores/user";
|
|||
import { Toast } from "@halo-dev/components";
|
||||
import { i18n } from "@/locales";
|
||||
|
||||
const baseURL = import.meta.env.VITE_API_URL;
|
||||
const baseURL = "/";
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
baseURL,
|
||||
|
|
|
@ -43,7 +43,7 @@ const handleLogout = () => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await axios.post(`${import.meta.env.VITE_API_URL}/logout`, undefined, {
|
||||
await axios.post(`/logout`, undefined, {
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -45,12 +45,9 @@ const handleUnbindAuth = (authProvider: ListedAuthProvider) => {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await axios.put(
|
||||
`${import.meta.env.VITE_API_URL}${authProvider.unbindingUrl}`,
|
||||
{
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
await axios.put(`${authProvider.unbindingUrl}`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
window.location.reload();
|
||||
},
|
||||
|
|
|
@ -19,9 +19,7 @@ export async function setupPluginModules(app: App) {
|
|||
const pluginModuleStore = usePluginModuleStore();
|
||||
try {
|
||||
const { load } = useScriptTag(
|
||||
`${
|
||||
import.meta.env.VITE_API_URL
|
||||
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js?t=${Date.now()}`
|
||||
`/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js?t=${Date.now()}`
|
||||
);
|
||||
|
||||
await load();
|
||||
|
@ -43,9 +41,7 @@ export async function setupPluginModules(app: App) {
|
|||
|
||||
try {
|
||||
await loadStyle(
|
||||
`${
|
||||
import.meta.env.VITE_API_URL
|
||||
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.css?t=${Date.now()}`
|
||||
`/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.css?t=${Date.now()}`
|
||||
);
|
||||
} catch (e) {
|
||||
const message = i18n.global.t("core.plugin.loader.toast.style_load_failed");
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import path from "path";
|
||||
import { loadEnv, Plugin } from "vite";
|
||||
import { Plugin } from "vite";
|
||||
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
||||
import { createViteConfig } from "./src/vite/config-builder";
|
||||
|
||||
export default ({ mode }: { mode: string }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
return createViteConfig({
|
||||
base: env.VITE_BASE_URL,
|
||||
base: "/console/",
|
||||
entryFile: "/console-src/main.ts",
|
||||
port: 3000,
|
||||
outDir: path.resolve("build/dist/console"),
|
||||
|
|
Loading…
Reference in New Issue