Skip to content

Commit fbad0fd

Browse files
authored
feat: add supports for open app detail in plugin operation item (#4)
支持在插件项的操作菜单中打开应用市场的应用详情页面。 <img width="592" alt="image" src="https://github.com/halo-dev/plugin-app-store/assets/21301288/365fd748-acef-4546-ad16-ce5bed3306d5"> /kind feature ```release-note None ```
1 parent 18ca9f7 commit fbad0fd

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<script lang="ts" setup>
2+
import { VDropdownItem } from "@halo-dev/components";
3+
import { nextTick, ref } from "vue";
4+
import AppDetailModal from "../AppDetailModal.vue";
5+
import storeApiClient from "@/utils/store-api-client";
6+
import type { ApplicationDetail, ApplicationSearchResult } from "@/types";
7+
8+
const props = withDefaults(
9+
defineProps<{
10+
appId: string;
11+
}>(),
12+
{}
13+
);
14+
15+
const detailModal = ref(false);
16+
const visible = ref(false);
17+
const app = ref<ApplicationSearchResult>();
18+
19+
async function handleOpenDetailModal() {
20+
const { data } = await storeApiClient.get<ApplicationDetail>(
21+
`/apis/api.store.halo.run/v1alpha1/applications/${props.appId}`
22+
);
23+
24+
app.value = {
25+
application: data.application,
26+
latestRelease: data.latestRelease?.release,
27+
owner: data.owner,
28+
};
29+
30+
detailModal.value = true;
31+
nextTick(() => {
32+
visible.value = true;
33+
});
34+
}
35+
36+
function onDetailModalClose() {
37+
visible.value = false;
38+
setTimeout(() => {
39+
detailModal.value = false;
40+
app.value = undefined;
41+
}, 200);
42+
}
43+
</script>
44+
45+
<template>
46+
<VDropdownItem @click="handleOpenDetailModal">应用市场</VDropdownItem>
47+
<AppDetailModal v-if="detailModal" v-model:visible="visible" :app="app" tab="releases" @close="onDetailModalClose" />
48+
</template>

console/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import AppStore from "./views/AppStore.vue";
99
import type { Plugin, Theme } from "@halo-dev/api-client";
1010
import PluginVersionCheckField from "./components/entity-fields/PluginVersionCheckField.vue";
1111
import ThemeVersionCheckOperationItem from "./components/operation-items/ThemeVersionCheckOperationItem.vue";
12+
import ViewAppStoreOperationItem from "./components/operation-items/ViewAppStoreOperationItem.vue";
13+
import { STORE_APP_ID } from "./constant";
1214

1315
export default definePlugin({
1416
routes: [
@@ -81,5 +83,17 @@ export default definePlugin({
8183
},
8284
];
8385
},
86+
"plugin:list-item:operation:create": (plugin: Ref<Plugin>) => {
87+
return [
88+
{
89+
priority: 11,
90+
component: markRaw(ViewAppStoreOperationItem),
91+
props: {
92+
appId: plugin.value.metadata.annotations?.[STORE_APP_ID],
93+
},
94+
hidden: !plugin.value.metadata.annotations?.[STORE_APP_ID],
95+
},
96+
];
97+
},
8498
},
8599
});

0 commit comments

Comments
 (0)