提交 e37e20c5 编写于 作者: 璃白.'s avatar 璃白. 🌻

feat:添加插件市场分类

上级 58ffae88
...@@ -57,7 +57,7 @@ module.exports = () => { ...@@ -57,7 +57,7 @@ module.exports = () => {
}); });
win.on("blur", () => { win.on("blur", () => {
const childWindows = win.getChildWindows(); const childWindows = win.getChildWindows();
if (!childWindows.length) win.hide(); // if (!childWindows.length) win.hide();
}); });
}; };
......
...@@ -5,10 +5,23 @@ export default { ...@@ -5,10 +5,23 @@ export default {
axios.get( axios.get(
"https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker/releases" "https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker/releases"
), ),
getPlugins: () => getPlugins: path =>
axios.get( axios.get(
"https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/tree?path=plugins" `https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/tree?ref=dev&path=${path}`
), ),
getMenu: () =>
axios.get(
"https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/tree?path=plugins&ref=dev"
),
getLogo: plugin =>
`https://gitlab.com/layyback/quicker-market/-/raw/master/plugins/${plugin.name}/${plugin.logo}`,
getReadme: plugin =>
axios.get(
`https://gitlab.com/layyback/quicker-market/-/raw/master/plugins/${plugin.name}/${plugin.detail}`
),
getDownloadUrl: plugin =>
`https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/archive.zip?path=plugins%2F${plugin.name}`,
getPluginDetail: pluginName => getPluginDetail: pluginName =>
axios.get( axios.get(
`https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/files/plugins%2F${pluginName}%2Fplugin.json/raw?ref=master` `https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/files/plugins%2F${pluginName}%2Fplugin.json/raw?ref=master`
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<!-- 本地插件 --> <!-- 本地插件 -->
<div v-else> <div v-else>
<webview id="webview" :src="templatePath" :preload="preload"></webview> <webview id="webview" :src="templatePath" :preload="preload"></webview>
<!-- <webview id="webview" :src="templatePath" :preload="preload"></webview> -->
</div> </div>
</div> </div>
</template> </template>
......
<template> <template>
<div class="market"> <div class="market">
<a-carousel v-if="bannerList && !!bannerList.length" arrows> <a-menu mode="vertical" v-model="selectedMenu" @click="getPlugins">
<div <a-menu-item
slot="prevArrow" v-for="(item, index) in menu"
slot-scope="props" :key="item.id"
class="custom-slick-arrow" :value="item.path"
style="left: 10px; zindex: 1"
> >
<a-icon type="left-circle" /> <a-icon :type="icon[index]" />
</div> {{ item.name }}
<div </a-menu-item>
slot="nextArrow" </a-menu>
slot-scope="props" <div class="market-content">
class="custom-slick-arrow" <a-carousel v-if="bannerList && !!bannerList.length" arrows>
style="right: 10px" <div
> slot="prevArrow"
<a-icon type="right-circle" /> slot-scope="props"
</div> class="custom-slick-arrow"
<div v-for="banner in bannerList"> style="left: 10px; zindex: 1"
<img @click="jumpTo(banner.link)" width="100%" :src="banner.src" />
</div>
</a-carousel>
<a-divider v-if="bannerList && !!bannerList.length"></a-divider>
<h2>插件</h2>
<a-list
item-layout="horizontal"
style="width: 100%"
:grid="{ gutter: 16, column: 2 }"
:data-source="pluginList"
>
<a-list-item slot="renderItem" slot-scope="item, index">
<a-button
v-if="showButton(item) === 'download'"
:loading="loading[index]"
type="link"
slot="actions"
@click="download(index, item)"
> >
<a-icon <a-icon type="left-circle" />
v-show="!loading[index]" </div>
style="font-size: 20px" <div
type="cloud-download" slot="nextArrow"
/> slot-scope="props"
</a-button> class="custom-slick-arrow"
<a-button style="right: 10px"
v-if="showButton(item) === 'update'"
:loading="loading[index]"
type="link"
slot="actions"
@click="update(index, item)"
> >
<a-icon <a-icon type="right-circle" />
v-show="!loading[index]" </div>
style="font-size: 20px; color: #409eff" <div v-for="banner in bannerList">
type="sync" <img @click="jumpTo(banner.link)" width="100%" :src="banner.src" />
/> </div>
</a-button> </a-carousel>
<a-divider v-if="bannerList && !!bannerList.length"></a-divider>
<h2>插件</h2>
<a-list
item-layout="horizontal"
style="width: 100%"
:grid="{ gutter: 16, column: 2 }"
:data-source="pluginList"
>
<a-list-item slot="renderItem" slot-scope="item, index">
<a-button
v-if="showButton(item) === 'download'"
:loading="loading[index]"
type="link"
slot="actions"
@click="download(index, item)"
>
<a-icon
v-show="!loading[index]"
style="font-size: 20px"
type="cloud-download"
/>
</a-button>
<a-button
v-if="showButton(item) === 'update'"
:loading="loading[index]"
type="link"
slot="actions"
@click="update(index, item)"
>
<a-icon
v-show="!loading[index]"
style="font-size: 20px; color: #409eff"
type="sync"
/>
</a-button>
<a-list-item-meta <a-list-item-meta
@click="showPannel(item, index)" @click="showPannel(item, index)"
:description="item.description" :description="item.description"
> >
<div slot="title">{{ item.pluginName }}</div> <div slot="title">{{ item.pluginName }}</div>
<a-avatar slot="avatar" :src="item.logo" /> <a-avatar slot="avatar" :src="item.logo" />
</a-list-item-meta> </a-list-item-meta>
</a-list-item> </a-list-item>
</a-list> </a-list>
</div>
<a-drawer <a-drawer
placement="right" placement="right"
:visible="show" :visible="show"
...@@ -119,20 +131,35 @@ const rendererMD = new marked.Renderer(); ...@@ -119,20 +131,35 @@ const rendererMD = new marked.Renderer();
export default { export default {
data() { data() {
return { return {
menu: [],
pluginList: [], pluginList: [],
loading: {}, loading: {},
bannerList: [], bannerList: [],
show: false, show: false,
selectedMenu: [],
icon: ["calculator", "tool", "build"],
currentSelect: {} currentSelect: {}
}; };
}, },
async created() { async created() {
this.getPlugins(); this.getMenu();
// this.bannerList = bannerRes.result; // this.bannerList = bannerRes.result;
}, },
methods: { methods: {
getPlugins() { getMenu() {
api.getPlugins().then(async ({ data: res }) => { api.getMenu().then(async ({ data: res }) => {
if (!res.length) return;
this.menu = res;
const firstItem = res[0];
this.selectedMenu = [firstItem.id];
this.getPlugins({ item: { value: firstItem.path } });
});
},
getPlugins({ item }) {
console.log(item);
const path = encodeURIComponent(item.value);
api.getPlugins(path).then(async ({ data: res }) => {
this.pluginList = [];
res.forEach(async plugin => { res.forEach(async plugin => {
const pluginItem = await this.getPluginDetail(plugin.name); const pluginItem = await this.getPluginDetail(plugin.name);
this.pluginList.push(pluginItem); this.pluginList.push(pluginItem);
...@@ -140,20 +167,17 @@ export default { ...@@ -140,20 +167,17 @@ export default {
}); });
}, },
async getPluginDetail(name) { async getPluginDetail(name) {
const { const { data: plugin } = await api.getPluginDetail(name);
data: plugin
} = await api.getPluginDetail(name);
if (plugin.detail && isMdFile(plugin.detail)) { if (plugin.detail && isMdFile(plugin.detail)) {
const { readme } = await axios.get( const { readme } = await api.getReadme(plugin);
`https://gitlab.com/layyback/quicker-market/-/raw/master/plugins/${plugin.name}/${plugin.detail}`
);
plugin.readme = readme; plugin.readme = readme;
} else { } else {
plugin.readme = plugin.detail; plugin.readme = plugin.detail;
} }
plugin.logo = `https://gitlab.com/layyback/quicker-market/-/raw/master/plugins/${plugin.name}/${plugin.logo}`; plugin.logo = api.getLogo(plugin);
// plugin.logo = `https://gitcode.net/weixin_43881430/quicker-market/-/raw/master/plugins/${plugin.name}/${logo}`; // plugin.logo = `https://gitcode.net/weixin_43881430/quicker-market/-/raw/master/plugins/${plugin.name}/${logo}`;
plugin.downloadUrl = `https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/archive.zip?path=plugins%2F${plugin.name}`; plugin.downloadUrl = api.getDownloadUrl(plugin);
// plugin.downloadUrl = `https://gitlab.com/api/v4/projects/layyback%2Fquicker-market/repository/archive.zip?path=plugins%2F${plugin.name}`;
// plugin.downloadUrl = // plugin.downloadUrl =
// "https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker-market/repository/archive.zip"; // "https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker-market/repository/archive.zip";
...@@ -275,9 +299,17 @@ export default { ...@@ -275,9 +299,17 @@ export default {
.market { .market {
height: calc(~"100vh - 110px"); height: calc(~"100vh - 110px");
background: #fff; background: #fff;
padding: 20px;
box-sizing: border-box; box-sizing: border-box;
overflow: auto; overflow: auto;
display: flex;
.ant-menu {
width: 220px;
}
.market-content {
flex: 1;
padding: 20px;
box-sizing: border-box;
}
.ant-carousel .slick-slide { .ant-carousel .slick-slide {
text-align: center; text-align: center;
height: 235px; height: 235px;
...@@ -318,5 +350,8 @@ export default { ...@@ -318,5 +350,8 @@ export default {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.ant-list-item-action {
margin-left: 0;
}
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册