This commit is contained in:
fofolee 2022-06-07 19:39:07 +08:00
commit a9df2a76b1
11 changed files with 66 additions and 27 deletions

View File

@ -270,7 +270,7 @@
/> />
</q-dialog> </q-dialog>
<q-dialog v-model="showUserData"> <q-dialog v-model="showUserData">
<UserData @insertText="insertSpecialVar" /> <UserData @insertText="insertSpecialVar" :showInsertBtn="true" />
</q-dialog> </q-dialog>
</q-scroll-area> </q-scroll-area>
</template> </template>

View File

@ -37,6 +37,7 @@
style="width: 280px" style="width: 280px"
autofocus autofocus
v-model="$root.profile.quickFileTag" v-model="$root.profile.quickFileTag"
@blur="$root.profile.quickFileTag || ($root.profile.quickFileTag = '文件')"
type="text" type="text"
> >
<template v-slot:append> <template v-slot:append>
@ -68,6 +69,8 @@
input-class="text-center" input-class="text-center"
style="width: 280px" style="width: 280px"
v-model="$root.profile.quickUrlTag" v-model="$root.profile.quickUrlTag"
@blur="$root.profile.quickUrlTag || ($root.profile.quickUrlTag = '网址')"
type="text" type="text"
> >
<template v-slot:append> <template v-slot:append>

View File

@ -11,13 +11,13 @@
></iframe> ></iframe>
<div <div
v-else v-else
v-show="!!runResult" v-show="!!runResult.length"
:class="{ 'text-red': !runResultStatus }" :class="{ 'text-red': !runResultStatus }"
class="text q-px-md q-py-sm" class="text q-px-md q-py-sm"
> >
<div v-for="item in runResult" :key="item"> <div v-for="item in runResult" :key="item">
<ObjectTree :obj="item" v-if="typeof item === 'object'" /> <ObjectTree :obj="item" v-if="typeof item === 'object'" />
<pre class="result" v-text="item" v-else-if="!!item"></pre> <pre class="result" v-text="item" v-else></pre>
</div> </div>
</div> </div>
</div> </div>
@ -86,7 +86,12 @@ export default {
!utools.isDarkColors() || (cfw.document.body.style.color = "white"); !utools.isDarkColors() || (cfw.document.body.style.color = "white");
let clientHeight = let clientHeight =
cfw.document.documentElement.getBoundingClientRect().height; cfw.document.documentElement.getBoundingClientRect().height;
this.frameHeight = clientHeight === 20 ? 0 : clientHeight; clientHeight = clientHeight === 20 ? 0 : clientHeight;
this.frameHeight = Math.max(
//
this.getMaxElHeight(cfw.document),
clientHeight
);
this.$emit("frameLoad", this.frameHeight); this.$emit("frameLoad", this.frameHeight);
}; };
}, },
@ -108,6 +113,14 @@ export default {
onerror: (e) => showError(e), onerror: (e) => showError(e),
}; };
}, },
getMaxElHeight(doc) {
let els = Array.prototype.slice.call(doc.body.getElementsByTagName("*"));
let elHeights = [];
for (let i = 0, l = els.length; i < l; i++) {
elHeights.push(els[i].scrollTop + els[i].offsetHeight);
}
return Math.max.apply(Math, elHeights);
},
}, },
}; };
</script> </script>

View File

@ -84,12 +84,7 @@ export default {
}, },
computed: { computed: {
disableShare() { disableShare() {
return ( return this.shareLock || !this.yuQueInfo.yuQueToken;
this.shareLock ||
!this.yuQueInfo.yuQueToken ||
(this.yuQueInfo.authorId !== this.command.authorId &&
this.command.fromShare)
);
}, },
}, },
mounted() { mounted() {

View File

@ -18,7 +18,9 @@
:placeholder="item.value || '本机未设置'" :placeholder="item.value || '本机未设置'"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-chip color="primary" dense>{{ item.id }}</q-chip> <q-chip color="primary" text-color="white" dense>{{
item.id
}}</q-chip>
</template> </template>
<template v-slot:append> <template v-slot:append>
<q-toggle <q-toggle

View File

@ -2,7 +2,7 @@
export default { export default {
mounted() { mounted() {
utools.setExpendHeight(0); utools.setExpendHeight(0);
this.$root.payload.forEach((file) => { this.$root.enterData.payload.forEach((file) => {
let uid = this.getUid(); let uid = this.getUid();
let fileInfo = window.getFileInfo({ let fileInfo = window.getFileInfo({
type: "file", type: "file",

View File

@ -24,7 +24,7 @@ export default {
); );
url = choise.text + "://" + url; url = choise.text + "://" + url;
} }
let title = this.$root.payload.title let title = this.$root.enterData.payload.title
.replace(/和另外 \d+ 个页面.*/, "") .replace(/和另外 \d+ 个页面.*/, "")
.replace(/[-|—] .*?[Edge|Firefox|Chrome].*/, "") .replace(/[-|—] .*?[Edge|Firefox|Chrome].*/, "")
.trim(); .trim();
@ -39,7 +39,7 @@ export default {
let uid = this.getUid(); let uid = this.getUid();
let command = { let command = {
features: { features: {
explain: `访问${title}`, explain: title,
cmds: [title], cmds: [title],
platform: ["linux", "win32", "darwin"], platform: ["linux", "win32", "darwin"],
code: `key_${uid}`, code: `key_${uid}`,
@ -51,7 +51,7 @@ export default {
}; };
try { try {
let res = await quickcommand.downloadFile(iconUrl, iconPath); let res = await quickcommand.downloadFile(iconUrl, iconPath);
if (res) command.features.icon = iconPath; if (res) command.features.icon = window.getBase64Ico(iconPath);
} catch (e) {} } catch (e) {}
this.importCommand(command); this.importCommand(command);
utools.showNotification("操作成功!"); utools.showNotification("操作成功!");

View File

@ -85,9 +85,11 @@ export default {
}), }),
showMessageBox: (message, icon = "success", time) => { showMessageBox: (message, icon = "success", time) => {
message = _.truncate(message, { length: 1200 });
if (icon === "success") icon = "positive"; if (icon === "success") icon = "positive";
if (icon === "error") icon = "negative"; if (icon === "error") icon = "negative";
if (!time) time = Math.max(message.toString().length * 120, 1000); if (typeof time === "undefined")
time = Math.max(message.toString().length * 120, 1000);
Notify.create({ Notify.create({
type: icon, type: icon,
message: message, message: message,

View File

@ -4,7 +4,7 @@
let escapeItem = item => { let escapeItem = item => {
if (typeof item === 'number') return item if (typeof item === 'number') return item
item = typeof item === 'object' ? JSON.stringify(item) : item.replace('\\', '\\\\') item = typeof item === 'object' ? JSON.stringify(item) : item.replace(/\\/g, '\\\\')
return item.replace('$', '$$$') return item.replace('$', '$$$')
} }

View File

@ -289,7 +289,9 @@ export default {
allQuickCommandTags() { allQuickCommandTags() {
let allTags = _.union( let allTags = _.union(
...Object.values(this.allQuickCommands).map((x) => x.tags) ...Object.values(this.allQuickCommands).map((x) => x.tags)
).concat(["未分类", "来自分享"]); )
.concat(["未分类", "来自分享"])
.filter((x) => x);
if (this.commandSearchKeyword?.length > 1) allTags.push("搜索结果"); if (this.commandSearchKeyword?.length > 1) allTags.push("搜索结果");
return allTags; return allTags;
}, },

View File

@ -141,6 +141,7 @@ export default {
releaseRepo: "fofolee/qcreleases", releaseRepo: "fofolee/qcreleases",
commandTypes: commandTypes, commandTypes: commandTypes,
platform: window.processPlatform, platform: window.processPlatform,
errCommandsCount: 0,
}; };
}, },
computed: { computed: {
@ -151,9 +152,11 @@ export default {
return this.commands.length === this.currentPageCounts ? false : true; return this.commands.length === this.currentPageCounts ? false : true;
}, },
currentPageCounts() { currentPageCounts() {
return this.currentPage === this.maxPages return (
? this.matchedCommands.length % this.perPage (this.currentPage === this.maxPages
: this.perPage; ? this.matchedCommands.length % this.perPage
: this.perPage) - this.errCommandsCount
);
}, },
}, },
mounted() { mounted() {
@ -166,6 +169,7 @@ export default {
}, },
methods: { methods: {
fetchCommandDetails(page) { fetchCommandDetails(page) {
this.errCommandsCount = 0;
this.commands = []; this.commands = [];
this.matchedCommands this.matchedCommands
.slice((page - 1) * this.perPage, page * this.perPage) .slice((page - 1) * this.perPage, page * this.perPage)
@ -176,7 +180,13 @@ export default {
item.last_editor.name, item.last_editor.name,
item.last_editor.id item.last_editor.id
).then((command) => { ).then((command) => {
this.commands.push(command); if (!command) {
this.errCommandsCount++;
return;
}
command.updated
? this.commands.unshift(command.data)
: this.commands.push(command.data);
}); });
}); });
}, },
@ -208,17 +218,29 @@ export default {
// //
async getCommand(id, updateTime, authorName, authorId) { async getCommand(id, updateTime, authorName, authorId) {
let localCache = JSON.parse(localStorage.getItem(id)); let localCache = JSON.parse(localStorage.getItem(id));
if (localCache?.updateTime === updateTime) return localCache; if (localCache?.updateTime === updateTime)
return {
data: localCache,
updated: false,
};
let res = await window.yuQueClient( let res = await window.yuQueClient(
`repos/${this.releaseRepo}/docs/${id}?raw=1` `repos/${this.releaseRepo}/docs/${id}?raw=1`
); );
let command = JSON.parse( let command;
res.data?.data.body.match(/```json([\s\S]*)```/)?.[1] try {
); command = JSON.parse(
res.data?.data.body.match(/```json([\s\S]*)```/)?.[1]
);
} catch (error) {
console.log("parseErr", command, error);
}
if (!command) return; if (!command) return;
Object.assign(command, { authorName, updateTime, authorId }); Object.assign(command, { authorName, updateTime, authorId });
localStorage.setItem(id, JSON.stringify(command)); localStorage.setItem(id, JSON.stringify(command));
return command; return {
data: command,
updated: true,
};
}, },
fetchCommands() { fetchCommands() {
window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => { window.yuQueClient(`repos/${this.releaseRepo}/docs`).then((res) => {