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

feat:修改插件市场接口逻辑

上级 e0965734
......@@ -15,7 +15,7 @@ module.exports = () => {
: `file://${__dirname}/index.html`;
win = new BrowserWindow({
height: 148, // client_height
height: 82, // client_height
useContentSize: true,
resizable: true,
width: 920,
......
......@@ -27,8 +27,8 @@ export async function autoUpdate() {
title: "发现新版本",
buttons: ["Yes", "No"],
message: `发现新版本${latest.tag_name},是否去下载最新的版本?`,
checkboxLabel: "以后不再提醒",
checkboxChecked: false
// checkboxLabel: "以后不再提醒",
// checkboxChecked: false
});
if (res.response === 0) {
if (os.type() === "Windows_NT") {
......
......@@ -91,7 +91,7 @@
:src="userInfo.UserAvatar"
alt=""
/>
<img v-else src="./assets/imgs/quicker.png" />
<a-icon v-else class="icon-more" type="more" />
</div>
</div>
</a-input>
......@@ -152,7 +152,7 @@
</div> -->
<router-view></router-view>
</a-layout>
<quick-apps v-if="isHome" />
<quick-apps />
</div>
</template>
<script>
......@@ -488,9 +488,6 @@ export default {
"userInfo",
"pluginLoading"
]),
isHome() {
return this.$route.path === "/home";
},
isWebview() {
return this.pluginInfo.subType === "webview";
},
......@@ -543,13 +540,13 @@ body {
}
#app {
padding: 4px 14px;
padding: 10px;
box-sizing: border-box;
}
#components-layout {
overflow: auto;
margin-top: 14px;
// margin-top: 14px;
background: #fff;
::-webkit-scrollbar {
width: 0;
......@@ -611,7 +608,7 @@ body {
.options {
position: absolute;
top: 96px;
top:82px;
left: 0;
width: 100%;
z-index: 99;
......
......@@ -5,5 +5,17 @@ export default {
axios.get(
"https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker/releases"
),
getPlugins: () => axios.get("/")
// getPlugins: () => axios.get("/")
getPlugins: () =>
axios.get(
"https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker-market/repository/tree?path=plugins"
),
getPluginDetail: pluginName =>
axios.get(
`https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker-market/repository/files/plugins%2F${pluginName}%2Fplugin.json/raw?ref=master`
),
getZipPathOfPlugin: () =>
axios.get(
`https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker-market/repository/archive.zip`
)
};
const WINDOW_MAX_HEIGHT = 800;
const WINDOW_MIN_HEIGHT = 148; // client_height
const WINDOW_MIN_HEIGHT = 82; // client_height
const PRE_ITEM_HEIGHT = 60;
const SYSTEM_PLUGINS = [
......
......@@ -70,6 +70,23 @@ async function downloadZip(downloadRepoUrl, name) {
console.log(e);
}
}
async function downloadZipFromGitCode(downloadRepoUrl, name) {
try {
const plugin_path = appPath;
// 基础模版所在目录,如果是初始化,则是模板名称,否则是项目名称
const temp_dest = `${plugin_path}/${name}`;
// 下载模板
if (await existOrNot(temp_dest)) {
shell.rm("-rf", temp_dest);
}
await downloadFile(downloadRepoUrl, temp_dest, { extract: true });
return temp_dest;
} catch (e) {
console.log(e);
}
}
const sysFile = {
savePlugins(plugins) {
......@@ -189,6 +206,7 @@ export {
mergePlugins,
find,
downloadZip,
downloadZipFromGitCode,
fileLists,
debounce
};
<template>
<div class="appList">
<div class="appList" v-if="isHome && dingApp.length">
<div class="apps">
<div @click="helpDoc" class="app_item view">
<!-- <div @click="helpDoc" class="app_item view">
<a-badge :count="1">
<app :info="help" />
</a-badge>
</div>
</div> -->
<template v-for="(item, index) in dingApp">
<div
:key="index"
......@@ -34,7 +34,7 @@
</template>
<script>
import app from "./components/app.vue";
import { shell } from "electron";
import { shell, ipcRenderer } from "electron";
import { mapState, mapMutations, mapActions } from "vuex";
export default {
components: {
......@@ -45,6 +45,9 @@ export default {
isEditMode() {
return this.mode === "edit";
},
isHome() {
return this.$route.path === "/home";
},
help() {
return {
pluginName: "帮助",
......@@ -61,9 +64,15 @@ export default {
];
}
},
created() {
this.resetClientHeight();
},
data() {
return {};
},
updated() {
this.resetClientHeight();
},
methods: {
...mapActions("main", ["showMainUI", "openPlugin"]),
...mapMutations("main", [
......@@ -72,6 +81,13 @@ export default {
"commonUpdate",
"dingProdPlugin"
]),
resetClientHeight() {
// alert(123)
if (!this.isHome) return;
ipcRenderer.send("changeWindowSize-rubick", {
height: this.dingApp.length ? 126 : 82
});
},
helpDoc() {
shell.openExternal(
"https://yre5673znb.feishu.cn/docs/doccnMnLv3iZ3epFvjXprnPum3b"
......@@ -163,7 +179,7 @@ export default {
display: flex;
flex: 1;
justify-content: flex-start;
min-height: 58px;
min-height: 56px;
}
/deep/.app_item {
cursor: pointer;
......@@ -173,7 +189,7 @@ export default {
}
&.view:hover {
.app_icon {
bottom: -4px;
bottom: -2px;
z-index: 4;
}
.app_name,
......
......@@ -37,7 +37,7 @@ export default {
border-radius: 50%;
overflow: hidden;
position: relative;
bottom: -20px;
bottom: -10px;
transition: all 0.3s;
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.1);
-webkit-app-region: no-drag;
......@@ -47,7 +47,7 @@ export default {
color: #666;
font-size: 12px;
text-align: center;
margin-top: 10px;
margin-top: 4px;
opacity: 0;
transition: all 0.3s;
}
......
......@@ -99,6 +99,7 @@ export default {
pluginList: [],
loading: {},
bannerList: [],
downloadPath: "",
show: false,
currentSelect: {}
};
......@@ -195,10 +196,26 @@ export default {
methods: {
getPlugins() {
api.getPlugins().then(({ data: res }) => {
this.pluginList = res;
api.getPlugins().then(async ({ data: res }) => {
res.forEach(async plugin => {
const pluginItem = await this.getPluginDetail(plugin);
this.pluginList.push(pluginItem);
});
});
},
async getPluginDetail(plugin) {
const {
data: { pluginName, description, logo }
} = await api.getPluginDetail(plugin.name);
plugin.pluginName = pluginName;
plugin.description = description;
plugin.logo = `https://gitcode.net/weixin_43881430/quicker-market/-/raw/master/plugins/${plugin.name}/${logo}`;
plugin.downloadUrl =
"https://gitcode.net/api/v4/projects/weixin_43881430%2Fquicker-market/repository/archive.zip";
console.log(plugin);
return plugin;
},
async download(index, item) {
if (this.loading[index]) return;
this.$set(this.loading, index, true);
......@@ -209,6 +226,9 @@ export default {
}
this.$set(this.loading, index, false);
},
async getZipPathOfPlugin() {
this.downloadPath = await api.getZipPathOfPlugin();
},
showButton(item) {
return !this.devPlugins.filter(
plugin => plugin.name === item.name && plugin.type === "prod"
......
......@@ -7,6 +7,7 @@ import {
mergePlugins,
find,
downloadZip,
downloadZipFromGitCode,
fileLists
} from "../../assets/common/utils";
import systemMethod from "../../assets/common/system";
......@@ -441,7 +442,8 @@ const actions = {
});
},
async downloadPlugin({ commit }, payload) {
const distUrl = await downloadZip(payload.downloadUrl, payload.name);
const distUrl = await downloadZipFromGitCode(payload.downloadUrl, payload.name);
// const distUrl = await downloadZip(payload.downloadUrl, payload.name);
const fileUrl = find(distUrl);
// 复制文件
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册