mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 21:13:02 +08:00
分享中心 40%
This commit is contained in:
parent
0f6c2c371a
commit
ce88da243b
110
plugin/package-lock.json
generated
110
plugin/package-lock.json
generated
@ -6,6 +6,7 @@
|
|||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
|
"axios-delay": "^1.0.0-rc6",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"lodash": "^4.17.21"
|
"lodash": "^4.17.21"
|
||||||
}
|
}
|
||||||
@ -18,6 +19,43 @@
|
|||||||
"follow-redirects": "^1.14.4"
|
"follow-redirects": "^1.14.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/axios-delay": {
|
||||||
|
"version": "1.0.0-rc6",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios-delay/-/axios-delay-1.0.0-rc6.tgz",
|
||||||
|
"integrity": "sha512-l52QkvPb3/T1b5NqyjhXt3LU5lkYOSn0AFb9tXI8qApBv9kGvLQj0PG69s7T9aVtJDMsKakekIMNhJMyXzTJZg==",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.18.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/axios-delay/node_modules/axios": {
|
||||||
|
"version": "0.18.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
|
||||||
|
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
|
||||||
|
"deprecated": "Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410",
|
||||||
|
"dependencies": {
|
||||||
|
"follow-redirects": "1.5.10",
|
||||||
|
"is-buffer": "^2.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/axios-delay/node_modules/follow-redirects": {
|
||||||
|
"version": "1.5.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
||||||
|
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "=3.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/debug": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.14.9",
|
"version": "1.14.9",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
||||||
@ -48,11 +86,38 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-buffer": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
},
|
},
|
||||||
|
"node_modules/ms": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
|
},
|
||||||
"node_modules/safer-buffer": {
|
"node_modules/safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
@ -68,6 +133,41 @@
|
|||||||
"follow-redirects": "^1.14.4"
|
"follow-redirects": "^1.14.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"axios-delay": {
|
||||||
|
"version": "1.0.0-rc6",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios-delay/-/axios-delay-1.0.0-rc6.tgz",
|
||||||
|
"integrity": "sha512-l52QkvPb3/T1b5NqyjhXt3LU5lkYOSn0AFb9tXI8qApBv9kGvLQj0PG69s7T9aVtJDMsKakekIMNhJMyXzTJZg==",
|
||||||
|
"requires": {
|
||||||
|
"axios": "^0.18.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"axios": {
|
||||||
|
"version": "0.18.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
|
||||||
|
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
|
||||||
|
"requires": {
|
||||||
|
"follow-redirects": "1.5.10",
|
||||||
|
"is-buffer": "^2.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"follow-redirects": {
|
||||||
|
"version": "1.5.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
||||||
|
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
||||||
|
"requires": {
|
||||||
|
"debug": "=3.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"follow-redirects": {
|
"follow-redirects": {
|
||||||
"version": "1.14.9",
|
"version": "1.14.9",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
||||||
@ -81,11 +181,21 @@
|
|||||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"is-buffer": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="
|
||||||
|
},
|
||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
},
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
|
"axios-delay": "^1.0.0-rc6",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"lodash": "^4.17.21"
|
"lodash": "^4.17.21"
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,14 @@ const axios = require('axios');
|
|||||||
const pictureCompress = require("./lib/picture-compressor")
|
const pictureCompress = require("./lib/picture-compressor")
|
||||||
|
|
||||||
window._ = require("lodash")
|
window._ = require("lodash")
|
||||||
window.fetchGitee = async path => {
|
window.yuQueClient = axios.create({
|
||||||
let res = await axios('https://gitee.com/api/v5/repos/fofolee/qcshares' + path)
|
baseURL: 'https://www.yuque.com/api/v2/',
|
||||||
return res.data
|
headers: {
|
||||||
}
|
'Content-Type': 'application/json',
|
||||||
|
// 只读权限
|
||||||
|
'X-Auth-Token': 'WNrd0Z4kfCZLFrGLVAaas93DZ7sbG6PirKq7VxBL'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
||||||
|
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex">
|
<div class="flex absolute-top" style="bottom: 60px; overflow-y: auto">
|
||||||
<div
|
<div
|
||||||
style="width: 50%"
|
style="width: 50%"
|
||||||
class="q-pa-sm"
|
class="q-pa-sm wrapper"
|
||||||
v-for="count in perPage"
|
v-for="command in commands.slice(
|
||||||
:key="count"
|
(currentPage - 1) * perPage,
|
||||||
|
currentPage * perPage
|
||||||
|
)"
|
||||||
|
:key="command"
|
||||||
|
>
|
||||||
|
<q-card
|
||||||
|
class="my-card"
|
||||||
|
:style="{
|
||||||
|
padding: '8px',
|
||||||
|
background: $q.dark.isActive ? '#ffffff08' : '#00000008',
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<q-card class="my-card">
|
|
||||||
<q-item v-if="loading">
|
<q-item v-if="loading">
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-skeleton square width="48px" height="48px" animation="fade" />
|
<q-skeleton square width="48px" height="48px" animation="fade" />
|
||||||
@ -21,26 +30,50 @@
|
|||||||
<q-item v-else>
|
<q-item v-else>
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-avatar square size="48px">
|
<q-avatar square size="48px">
|
||||||
<q-img :src="commands[count - 1]?.features?.icon" />
|
<q-img :src="command?.avatar" />
|
||||||
</q-avatar>
|
</q-avatar>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label class="text-h5">{{
|
<q-item-label class="text-h6" lines="1">{{
|
||||||
commands[count - 1]?.features?.explain
|
command?.title
|
||||||
}}</q-item-label>
|
|
||||||
<q-item-label caption>{{
|
|
||||||
commands[count - 1]?.program
|
|
||||||
}}</q-item-label>
|
|
||||||
<q-item-label caption>{{
|
|
||||||
commands[count - 1]?.features?.cmds[0]?.type || "key"
|
|
||||||
}}</q-item-label>
|
}}</q-item-label>
|
||||||
|
<q-item-label caption
|
||||||
|
><q-icon name="account_circle"></q-icon>{{ command?.user }}
|
||||||
|
<q-icon name="watch_later"></q-icon
|
||||||
|
>{{ command?.updateTime }}</q-item-label
|
||||||
|
>
|
||||||
|
<q-item-label caption
|
||||||
|
><q-icon name="fiber_manual_record"></q-icon
|
||||||
|
>{{ command?.program }}</q-item-label
|
||||||
|
>
|
||||||
|
<q-item-label caption>
|
||||||
|
<span
|
||||||
|
v-for="tag in [command?.type, ...command?.tags]"
|
||||||
|
:key="tag"
|
||||||
|
class="tag"
|
||||||
|
>
|
||||||
|
{{ tag }}
|
||||||
|
</span>
|
||||||
|
</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-btn flat>导入</q-btn>
|
<q-item-label side>
|
||||||
|
<q-btn
|
||||||
|
@click="importCommand(command.slug)"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
color="primary"
|
||||||
|
icon="download"
|
||||||
|
label="导入"
|
||||||
|
></q-btn>
|
||||||
|
</q-item-label>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="q-pa-sm flex flex-center">
|
<div
|
||||||
|
class="absolute flex flex-center"
|
||||||
|
:style="{ left: 0, right: 0, bottom: '10px' }"
|
||||||
|
>
|
||||||
<q-pagination v-model="currentPage" :max="maxPages" input />
|
<q-pagination v-model="currentPage" :max="maxPages" input />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -51,40 +84,81 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
commandTree: [],
|
|
||||||
commands: [],
|
commands: [],
|
||||||
perPage: 12,
|
perPage: 8,
|
||||||
loading: true,
|
loading: true,
|
||||||
|
releaseRepo: "fofolee/qcreleases",
|
||||||
|
shareRepo: "fofolee/qcshares",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
maxPages() {
|
maxPages() {
|
||||||
return this.commandTree.length || 1;
|
return Math.ceil(this.commands.length / this.perPage) || 1;
|
||||||
},
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
currentPage(val) {
|
|
||||||
this.updateCommands(val);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
window.fetchGitee("/contents/commands").then((res) => {
|
this.loading = true;
|
||||||
this.commandTree = res;
|
window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => {
|
||||||
this.updateCommands(1);
|
console.log(res.data);
|
||||||
|
this.commands = res.data.data
|
||||||
|
.map((item) => {
|
||||||
|
let info = JSON.parse(item.custom_description);
|
||||||
|
return {
|
||||||
|
title: item.title,
|
||||||
|
user: item.last_editor.name,
|
||||||
|
updateTime: item.content_updated_at.slice(0, 10),
|
||||||
|
avatar: item.last_editor.avatar_url,
|
||||||
|
tags: info.tags.split(" ").filter((x) => x), // 历史原因,这里tag的格式不规范
|
||||||
|
program: info.program,
|
||||||
|
platform: info.platform,
|
||||||
|
type: info.type,
|
||||||
|
slug: item.slug,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter((item) => item.platform.includes(window.processPlatform));
|
||||||
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
updateCommands(page) {
|
importCommand(slug) {
|
||||||
this.loading = true;
|
window
|
||||||
this.commands = [];
|
.yuQueClient(`repos/${this.releaseRepo}/docs/${slug}?raw=1`)
|
||||||
this.commandTree
|
.then((res) => {
|
||||||
.slice((page - 1) * this.perPage, page * this.perPage)
|
let command = JSON.parse(
|
||||||
.forEach(async (x) => {
|
res.data?.data.body.match(/```json([\s\S]*)```/)?.[1]
|
||||||
let res = await window.fetchGitee(`/contents/commands/${x.name}`);
|
);
|
||||||
let command = JSON.parse(window.base64Decode(res.content));
|
if (!command)
|
||||||
this.commands.push(command);
|
return quickcommand.showMessageBox("导入出错!", "error");
|
||||||
|
command.tags.push("新添加");
|
||||||
|
let code = command?.features?.code;
|
||||||
|
if (!code)
|
||||||
|
return quickcommand.showMessageBox("该命令格式有误!", "error");
|
||||||
|
this.$utools.putDB(command, this.$utools.DBPRE.QC + code);
|
||||||
|
quickcommand.showMessageBox("导入成功!可到「来自分享」标签查看");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.q-card {
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.tag {
|
||||||
|
background: var(--q-primary);
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 2px;
|
||||||
|
margin-right: 2px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.wrapper {
|
||||||
|
transition: 0.5s;
|
||||||
|
}
|
||||||
|
.wrapper:hover {
|
||||||
|
transition: 0.5s;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
filter: drop-shadow(1px 1px 5px #0000008e);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user