mirror of https://github.com/halo-dev/halo
fix: not remembering the selected editor (#6114)
#### What type of PR is this? /area ui /kind bug /milestone 2.17.x #### What this PR does / why we need it: 修复新建文章时,没有自动选择之前所选编辑器的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/6091 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 修复新建文章时,没有自动选择之前所选编辑器的问题。 ```pull/6128/head
parent
c10862d6fe
commit
373229e9de
|
@ -50,7 +50,7 @@ const { mutateAsync: singlePageUpdateMutate } = usePageUpdateMutate();
|
|||
const { currentUserHasPermission } = usePermission();
|
||||
|
||||
// Editor providers
|
||||
const { editorProviders } = useEditorExtensionPoints();
|
||||
const { editorProviders, fetchEditorProviders } = useEditorExtensionPoints();
|
||||
const currentEditorProvider = ref<EditorProvider>();
|
||||
const storedEditorProviderName = useLocalStorage("editor-provider-name", "");
|
||||
|
||||
|
@ -331,6 +331,8 @@ const onSettingPublished = (singlePage: SinglePage) => {
|
|||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchEditorProviders();
|
||||
|
||||
if (routeQueryName.value) {
|
||||
const { data: singlePage } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
|
|
|
@ -50,7 +50,7 @@ const { mutateAsync: postUpdateMutate } = usePostUpdateMutate();
|
|||
const { currentUserHasPermission } = usePermission();
|
||||
|
||||
// Editor providers
|
||||
const { editorProviders } = useEditorExtensionPoints();
|
||||
const { editorProviders, fetchEditorProviders } = useEditorExtensionPoints();
|
||||
const currentEditorProvider = ref<EditorProvider>();
|
||||
const storedEditorProviderName = useLocalStorage("editor-provider-name", "");
|
||||
|
||||
|
@ -356,6 +356,8 @@ const onSettingPublished = (post: Post) => {
|
|||
// Get post data when the route contains the name parameter
|
||||
const name = useRouteQuery<string>("name");
|
||||
onMounted(async () => {
|
||||
await fetchEditorProviders();
|
||||
|
||||
if (name.value) {
|
||||
// fetch post
|
||||
const { data: post } =
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<script lang="ts" setup>
|
||||
import { useEditorExtensionPoints } from "@/composables/use-editor-extension-points";
|
||||
import type { EditorProvider } from "@halo-dev/console-shared";
|
||||
import {
|
||||
VAvatar,
|
||||
IconExchange,
|
||||
VAvatar,
|
||||
VDropdown,
|
||||
VDropdownItem,
|
||||
} from "@halo-dev/components";
|
||||
import type { EditorProvider } from "@halo-dev/console-shared";
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
|
@ -23,7 +23,9 @@ const emit = defineEmits<{
|
|||
(event: "select", provider: EditorProvider): void;
|
||||
}>();
|
||||
|
||||
const { editorProviders } = useEditorExtensionPoints();
|
||||
const { editorProviders, fetchEditorProviders } = useEditorExtensionPoints();
|
||||
|
||||
fetchEditorProviders();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -2,11 +2,12 @@ import Logo from "@/assets/logo.png";
|
|||
import { usePluginModuleStore } from "@/stores/plugin";
|
||||
import { VLoading } from "@halo-dev/components";
|
||||
import type { EditorProvider } from "@halo-dev/console-shared";
|
||||
import { defineAsyncComponent, markRaw, onMounted, ref, type Ref } from "vue";
|
||||
import { defineAsyncComponent, markRaw, ref, type Ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
interface useEditorExtensionPointsReturn {
|
||||
editorProviders: Ref<EditorProvider[]>;
|
||||
fetchEditorProviders: () => Promise<void>;
|
||||
}
|
||||
|
||||
export function useEditorExtensionPoints(): useEditorExtensionPointsReturn {
|
||||
|
@ -30,7 +31,7 @@ export function useEditorExtensionPoints(): useEditorExtensionPointsReturn {
|
|||
},
|
||||
]);
|
||||
|
||||
onMounted(async () => {
|
||||
async function fetchEditorProviders() {
|
||||
for (const pluginModule of pluginModules) {
|
||||
try {
|
||||
const callbackFunction =
|
||||
|
@ -40,16 +41,17 @@ export function useEditorExtensionPoints(): useEditorExtensionPointsReturn {
|
|||
continue;
|
||||
}
|
||||
|
||||
const providers = await callbackFunction();
|
||||
const pluginProviders = await callbackFunction();
|
||||
|
||||
editorProviders.value.push(...providers);
|
||||
editorProviders.value.push(...pluginProviders);
|
||||
} catch (error) {
|
||||
console.error(`Error processing plugin module:`, pluginModule, error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
editorProviders,
|
||||
fetchEditorProviders,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ provide<ComputedRef<string | undefined>>(
|
|||
);
|
||||
|
||||
// Editor providers
|
||||
const { editorProviders } = useEditorExtensionPoints();
|
||||
const { editorProviders, fetchEditorProviders } = useEditorExtensionPoints();
|
||||
const currentEditorProvider = ref<EditorProvider>();
|
||||
const storedEditorProviderName = useLocalStorage("editor-provider-name", "");
|
||||
|
||||
|
@ -125,6 +125,8 @@ const handleChangeEditorProvider = async (provider: EditorProvider) => {
|
|||
const name = useRouteQuery<string | undefined>("name");
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchEditorProviders();
|
||||
|
||||
if (name.value) {
|
||||
await getLatestPost();
|
||||
await handleFetchContent();
|
||||
|
|
Loading…
Reference in New Issue