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 v-model="showUserData">
<UserData @insertText="insertSpecialVar" />
<UserData @insertText="insertSpecialVar" :showInsertBtn="true" />
</q-dialog>
</q-scroll-area>
</template>

View File

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

View File

@ -11,13 +11,13 @@
></iframe>
<div
v-else
v-show="!!runResult"
v-show="!!runResult.length"
:class="{ 'text-red': !runResultStatus }"
class="text q-px-md q-py-sm"
>
<div v-for="item in runResult" :key="item">
<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>
@ -86,7 +86,12 @@ export default {
!utools.isDarkColors() || (cfw.document.body.style.color = "white");
let clientHeight =
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);
};
},
@ -108,6 +113,14 @@ export default {
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>

View File

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

View File

@ -18,7 +18,9 @@
:placeholder="item.value || '本机未设置'"
>
<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 v-slot:append>
<q-toggle

View File

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

View File

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

View File

@ -85,9 +85,11 @@ export default {
}),
showMessageBox: (message, icon = "success", time) => {
message = _.truncate(message, { length: 1200 });
if (icon === "success") icon = "positive";
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({
type: icon,
message: message,

View File

@ -4,7 +4,7 @@
let escapeItem = 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('$', '$$$')
}

View File

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

View File

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