mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-29 12:22:44 +08:00
分享中心 30%
This commit is contained in:
parent
0b4410cd47
commit
7973dc6a2c
@ -9,32 +9,49 @@
|
|||||||
"main": "http://127.0.0.1:8080/"
|
"main": "http://127.0.0.1:8080/"
|
||||||
},
|
},
|
||||||
"author": "云之轩",
|
"author": "云之轩",
|
||||||
"unpack":"autopep8.py",
|
"unpack": "autopep8.py",
|
||||||
"logo": "logo.png",
|
"logo": "logo.png",
|
||||||
"preload": "preload.js",
|
"preload": "preload.js",
|
||||||
"pluginSetting": {
|
"pluginSetting": {
|
||||||
"single": false
|
"single": false
|
||||||
},
|
},
|
||||||
"features": [
|
"features": [{
|
||||||
{
|
|
||||||
"code": "configuration",
|
"code": "configuration",
|
||||||
"explain": "新建、编辑或获取快捷命令",
|
"explain": "创建或编辑快捷命令",
|
||||||
"cmds": [ "快捷命令", "QuickCommand"]
|
"cmds": [
|
||||||
|
"快捷命令",
|
||||||
|
"QuickCommand"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "code",
|
"code": "code",
|
||||||
"explain": "运行代码",
|
"explain": "运行代码",
|
||||||
"cmds": [ "运行代码", "RunCode"]
|
"cmds": [
|
||||||
|
"运行代码",
|
||||||
|
"RunCode"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "newcommand",
|
"code": "newcommand",
|
||||||
"explain": "快速新建快捷命令",
|
"explain": "快速新建快捷命令",
|
||||||
"cmds": [ "新建快捷命令", "NewCommand", {
|
"cmds": [
|
||||||
"type": "regex",
|
"新建快捷命令",
|
||||||
"label": "新建快捷命令",
|
"NewCommand",
|
||||||
"match": "/^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$/i",
|
{
|
||||||
"maxNum": 1
|
"type": "regex",
|
||||||
}]
|
"label": "新建快捷命令",
|
||||||
|
"match": "/^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$/i",
|
||||||
|
"maxNum": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "share",
|
||||||
|
"explain": "查看分享中心的快捷命令",
|
||||||
|
"cmds": [
|
||||||
|
"分享中心",
|
||||||
|
"ShareCenter"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ 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 => {
|
||||||
|
let res = await axios('https://gitee.com/api/v5/repos/fofolee/qcshares' + path)
|
||||||
|
return res.data
|
||||||
|
}
|
||||||
|
|
||||||
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
// axios.defaults.adapter = require('axios/lib/adapters/http')
|
||||||
|
|
||||||
@ -212,22 +216,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
||||||
let cd = ''
|
let cd = ''
|
||||||
if (utools.isWindows()) {
|
if (utools.isWindows()) {
|
||||||
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
||||||
// 直接 existsSync wt.exe 无效
|
// 直接 existsSync wt.exe 无效
|
||||||
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
|
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
|
||||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
cmdline = cmdline.replace(/"/g, `\\"`)
|
||||||
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
|
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
|
||||||
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
|
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
|
||||||
|
} else {
|
||||||
|
cmdline = cmdline.replace(/"/g, `^"`)
|
||||||
|
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
|
||||||
|
command = `${cd} start "" cmd /k "${cmdline}"`
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cmdline = cmdline.replace(/"/g, `^"`)
|
cmdline = cmdline.replace(/"/g, `\\"`)
|
||||||
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
|
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
|
||||||
command = `${cd} start "" cmd /k "${cmdline}"`
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
|
||||||
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
|
|
||||||
if (fs.existsSync('/Applications/iTerm.app')) {
|
if (fs.existsSync('/Applications/iTerm.app')) {
|
||||||
command = `osascript -e 'tell application "iTerm"
|
command = `osascript -e 'tell application "iTerm"
|
||||||
create window with default profile
|
create window with default profile
|
||||||
@ -413,6 +417,8 @@ window.htmlEncode = (value) => {
|
|||||||
|
|
||||||
window.hexEncode = text => Buffer.from(text, 'utf8').toString('hex')
|
window.hexEncode = text => Buffer.from(text, 'utf8').toString('hex')
|
||||||
window.hexDecode = text => Buffer.from(text, 'hex').toString('utf8')
|
window.hexDecode = text => Buffer.from(text, 'hex').toString('utf8')
|
||||||
|
window.base64Decode = text => Buffer.from(text, 'base64').toString('utf8')
|
||||||
|
|
||||||
|
|
||||||
window.processPlatform = process.platform
|
window.processPlatform = process.platform
|
||||||
|
|
||||||
|
90
src/pages/ShareCenterPage.vue
Normal file
90
src/pages/ShareCenterPage.vue
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="flex">
|
||||||
|
<div
|
||||||
|
style="width: 50%"
|
||||||
|
class="q-pa-sm"
|
||||||
|
v-for="count in perPage"
|
||||||
|
:key="count"
|
||||||
|
>
|
||||||
|
<q-card class="my-card">
|
||||||
|
<q-item v-if="loading">
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-skeleton square width="48px" height="48px" animation="fade" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-skeleton type="text" square width="70%" animation="fade" />
|
||||||
|
<q-skeleton type="text" square width="30%" animation="fade" />
|
||||||
|
<q-skeleton type="text" square width="40%" animation="fade" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item v-else>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-avatar square size="48px">
|
||||||
|
<q-img :src="commands[count - 1]?.features?.icon" />
|
||||||
|
</q-avatar>
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label class="text-h5">{{
|
||||||
|
commands[count - 1]?.features?.explain
|
||||||
|
}}</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-section>
|
||||||
|
<q-btn flat>导入</q-btn>
|
||||||
|
</q-item>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="q-pa-sm flex flex-center">
|
||||||
|
<q-pagination v-model="currentPage" :max="maxPages" input />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
currentPage: 1,
|
||||||
|
commandTree: [],
|
||||||
|
commands: [],
|
||||||
|
perPage: 12,
|
||||||
|
loading: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
maxPages() {
|
||||||
|
return this.commandTree.length || 1;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
currentPage(val) {
|
||||||
|
this.updateCommands(val);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
window.fetchGitee("/contents/commands").then((res) => {
|
||||||
|
this.commandTree = res;
|
||||||
|
this.updateCommands(1);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateCommands(page) {
|
||||||
|
this.loading = true;
|
||||||
|
this.commands = [];
|
||||||
|
this.commandTree
|
||||||
|
.slice((page - 1) * this.perPage, page * this.perPage)
|
||||||
|
.forEach(async (x) => {
|
||||||
|
let res = await window.fetchGitee(`/contents/commands/${x.name}`);
|
||||||
|
let command = JSON.parse(window.base64Decode(res.content));
|
||||||
|
this.commands.push(command);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -40,8 +40,12 @@ const routes = [{
|
|||||||
name: 'loading',
|
name: 'loading',
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/LoadingPage.vue')
|
import ('pages/LoadingPage.vue')
|
||||||
|
}, {
|
||||||
|
path: '/share',
|
||||||
|
name: 'share',
|
||||||
|
component: () =>
|
||||||
|
import ('pages/ShareCenterPage.vue')
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export default routes
|
export default routes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user