mirror of https://github.com/halo-dev/halo-admin
fix: start plugin
parent
090ed19a26
commit
21d5fbb8c3
|
@ -52,12 +52,7 @@ const handleSubmit = async () => {
|
||||||
const { data: postData } = await apiClient.post.draftPost({
|
const { data: postData } = await apiClient.post.draftPost({
|
||||||
postRequest: post as PostRequest,
|
postRequest: post as PostRequest,
|
||||||
});
|
});
|
||||||
|
await apiClient.post.publishPost({ name: postData.metadata.name });
|
||||||
try {
|
|
||||||
await apiClient.post.publishPost({ name: postData.metadata.name });
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Publish post failed", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create singlePage
|
// Create singlePage
|
||||||
const { data: singlePageData } = await apiClient.singlePage.draftSinglePage(
|
const { data: singlePageData } = await apiClient.singlePage.draftSinglePage(
|
||||||
|
@ -66,13 +61,9 @@ const handleSubmit = async () => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
await apiClient.singlePage.publishSinglePage({
|
||||||
await apiClient.singlePage.publishSinglePage({
|
name: singlePageData.metadata.name,
|
||||||
name: singlePageData.metadata.name,
|
});
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Publish single page failed", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create menu and menu items
|
// Create menu and menu items
|
||||||
const menuItemPromises = menuItems.map((item) => {
|
const menuItemPromises = menuItems.map((item) => {
|
||||||
|
@ -85,56 +76,60 @@ const handleSubmit = async () => {
|
||||||
|
|
||||||
// Install preset plugins
|
// Install preset plugins
|
||||||
const { data: presetPlugins } = await apiClient.plugin.listPluginPresets();
|
const { data: presetPlugins } = await apiClient.plugin.listPluginPresets();
|
||||||
const installPluginPromises = presetPlugins.map((plugin) => {
|
|
||||||
return apiClient.plugin.installPlugin({
|
|
||||||
source: "PRESET",
|
|
||||||
presetName: plugin.metadata.name as string,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const installPluginResponses = await Promise.all(installPluginPromises);
|
|
||||||
|
|
||||||
await Promise.all(
|
const installPluginResponses = await Promise.all(
|
||||||
installPluginResponses.map((response) => {
|
presetPlugins.map((plugin) => {
|
||||||
return apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin({
|
return apiClient.plugin.installPlugin({
|
||||||
name: response.data.metadata.name as string,
|
source: "PRESET",
|
||||||
plugin: {
|
presetName: plugin.metadata.name as string,
|
||||||
...response.data,
|
|
||||||
spec: {
|
|
||||||
...response.data.spec,
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create system-states ConfigMap
|
for (let i = 0; i < installPluginResponses.length; i++) {
|
||||||
await apiClient.extension.configMap.createv1alpha1ConfigMap({
|
const response = installPluginResponses[i];
|
||||||
configMap: {
|
const { data: plugin } =
|
||||||
metadata: {
|
await apiClient.extension.plugin.getpluginHaloRunV1alpha1Plugin({
|
||||||
name: "system-states",
|
name: response.data.metadata.name,
|
||||||
|
});
|
||||||
|
|
||||||
|
plugin.spec.enabled = true;
|
||||||
|
await apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin(
|
||||||
|
{
|
||||||
|
name: response.data.metadata.name as string,
|
||||||
|
plugin,
|
||||||
},
|
},
|
||||||
kind: "ConfigMap",
|
{ mute: true }
|
||||||
apiVersion: "v1alpha1",
|
);
|
||||||
data: {
|
}
|
||||||
states: JSON.stringify({ isSetup: true }),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const systemStateStore = useSystemStatesStore();
|
|
||||||
await systemStateStore.fetchSystemStates();
|
|
||||||
const themeStore = useThemeStore();
|
|
||||||
await themeStore.fetchActivatedTheme();
|
|
||||||
|
|
||||||
router.push({ name: "Dashboard" });
|
|
||||||
|
|
||||||
Toast.success("初始化成功");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to setup", error);
|
console.error("Failed to initialize preset data", error);
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create system-states ConfigMap
|
||||||
|
await apiClient.extension.configMap.createv1alpha1ConfigMap({
|
||||||
|
configMap: {
|
||||||
|
metadata: {
|
||||||
|
name: "system-states",
|
||||||
|
},
|
||||||
|
kind: "ConfigMap",
|
||||||
|
apiVersion: "v1alpha1",
|
||||||
|
data: {
|
||||||
|
states: JSON.stringify({ isSetup: true }),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const systemStateStore = useSystemStatesStore();
|
||||||
|
await systemStateStore.fetchSystemStates();
|
||||||
|
const themeStore = useThemeStore();
|
||||||
|
await themeStore.fetchActivatedTheme();
|
||||||
|
|
||||||
|
loading.value = false;
|
||||||
|
|
||||||
|
router.push({ name: "Dashboard" });
|
||||||
|
|
||||||
|
Toast.success("初始化成功");
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
Loading…
Reference in New Issue