mirror of https://github.com/halo-dev/halo
refactor: update external URL using new configMap API (#7528)
#### What type of PR is this? /kind improvement /area ui /milestone 2.21.x #### What this PR does / why we need it: Update external URL using new configMap API. #### Does this PR introduce a user-facing change? ```release-note None ```pull/7521/head^2
parent
2f1bf93b2b
commit
9a52de0f4e
|
@ -1,13 +1,15 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { setFocus } from "@/formkit/utils/focus";
|
import { setFocus } from "@/formkit/utils/focus";
|
||||||
import { useGlobalInfoFetch } from "@console/composables/use-global-info";
|
import { useGlobalInfoFetch } from "@console/composables/use-global-info";
|
||||||
import { coreApiClient } from "@halo-dev/api-client";
|
import { consoleApiClient } from "@halo-dev/api-client";
|
||||||
import { Dialog, Toast, VButton, VLoading, VSpace } from "@halo-dev/components";
|
import { Dialog, Toast, VButton, VLoading, VSpace } from "@halo-dev/components";
|
||||||
import { useQuery } from "@tanstack/vue-query";
|
import { useQuery } from "@tanstack/vue-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
|
const BASIC_GROUP = "basic";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { globalInfo } = useGlobalInfoFetch();
|
const { globalInfo } = useGlobalInfoFetch();
|
||||||
|
|
||||||
|
@ -27,23 +29,17 @@ function onSubmit({ externalUrl }: { externalUrl: string }) {
|
||||||
confirmText: t("core.common.buttons.confirm"),
|
confirmText: t("core.common.buttons.confirm"),
|
||||||
cancelText: t("core.common.buttons.cancel"),
|
cancelText: t("core.common.buttons.cancel"),
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
const { data: configMap } = await coreApiClient.configMap.getConfigMap({
|
const { data: basicConfig } =
|
||||||
name: "system",
|
await consoleApiClient.configMap.system.getSystemConfigByGroup({
|
||||||
});
|
group: BASIC_GROUP,
|
||||||
|
});
|
||||||
|
|
||||||
const basicConfig = JSON.parse(configMap.data?.["basic"] || "{}");
|
await consoleApiClient.configMap.system.updateSystemConfigByGroup({
|
||||||
|
group: BASIC_GROUP,
|
||||||
basicConfig.externalUrl = externalUrl.trim();
|
body: {
|
||||||
|
...basicConfig,
|
||||||
await coreApiClient.configMap.patchConfigMap({
|
externalUrl: externalUrl.trim(),
|
||||||
name: "system",
|
},
|
||||||
jsonPatchInner: [
|
|
||||||
{
|
|
||||||
op: "add",
|
|
||||||
path: "/data/basic",
|
|
||||||
value: JSON.stringify(basicConfig),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await axios.post(`/actuator/restart`);
|
await axios.post(`/actuator/restart`);
|
||||||
|
|
Loading…
Reference in New Issue