Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vconsole",
"version": "3.15.1",
"name": "@wyatex/vconsole",
"version": "3.15.3",
"description": "A lightweight, extendable front-end developer tool for mobile web page.",
"homepage": "https://github.com/Tencent/vConsole",
"files": [
Expand All @@ -10,6 +10,7 @@
"README*"
],
"main": "dist/vconsole.min.js",
"types": "dist/vconsole.min.d.ts",
"typings": "dist/vconsole.min.d.ts",
"scripts": {
"build": "webpack --mode=production --progress --env target=web",
Expand Down
13 changes: 11 additions & 2 deletions src/component/icon/iconCopy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const copyOptions = { target: document.documentElement };
let showSuc = false;

const onTapIcon = (e) => {
const onTapIcon = async (e) => {
let text = content;
if (tool.isFunction(handler)) {
text = handler(content) || '';
Expand All @@ -25,7 +25,16 @@
text = content;
}
}
copy(text, copyOptions);
if (
navigator.clipboard &&
typeof navigator.clipboard.writeText === "function"
) {
try {
await navigator.clipboard.writeText(text);
} catch (error) {}
} else {
copy(text, copyOptions);
}
showSuc = true;
setTimeout(() => {
showSuc = false;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const _safeJSONStringifyFlatValue = (value: any, maxLen = 0) => {
if (maxLen > 0) {
value = getStringWithinLength(value, maxLen);
}
str += '"' + getVisibleText(value) + '"';
str += JSON.stringify(value);
} else if (isSymbol(value)) {
str += String(value).replace(/^Symbol\((.*)\)$/i, 'Symbol("$1")');
} else if (isFunction(value)) {
Expand Down Expand Up @@ -265,7 +265,7 @@ const _safeJSONStringify = (obj, opt: ISafeJSONStringifyOption, _curDepth = 0) =
if (isObject(key) || isArray(key) || isSymbol(key)) {
opt.ret += Object.prototype.toString.call(key);
} else if (isString(key) && opt.standardJSON) {
opt.ret += '"' + key + '"';
opt.ret += JSON.stringify(key);
} else {
opt.ret += key;
}
Expand Down
13 changes: 13 additions & 0 deletions src/log/log.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class VConsoleLogModel extends VConsoleModel {
this.origConsole[method] = window.console[method];
});
this.origConsole.time = window.console.time;
this.origConsole.timeLog = window.console.timeLog;
this.origConsole.timeEnd = window.console.timeEnd;
this.origConsole.clear = window.console.clear;
this.origConsole.group = window.console.group;
Expand Down Expand Up @@ -153,6 +154,18 @@ export class VConsoleLogModel extends VConsoleModel {
timeLog[label] = Date.now();
}).bind(window.console);

window.console.timeLog = ((label: string = '', ...args) => {
const pre = timeLog[label];
let t = 0;
if (pre) {
t = Date.now() - pre;
}
this.addLog({
type: 'log',
origData: [`${label}: ${t}ms`, ...args],
});
}).bind(window.console);

window.console.timeEnd = ((label: string = '') => {
const pre = timeLog[label];
let t = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/log/logTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export const getValueTextAndType = (val: any, wrapString = true) => {
text = getPreviewText(val);
} else if (tool.isString(val)) {
valueType = 'string';
text = tool.getVisibleText(val);
if (wrapString) {
text = '"' + text + '"';
text = JSON.stringify(val);
} else {
text = tool.getVisibleText(val);
}
} else if (tool.isNumber(val)) {
valueType = 'number';
Expand Down
11 changes: 7 additions & 4 deletions src/network/fetch.proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ export class ResponseProxyHandler<T extends Response> implements ProxyHandler<T>
if (!readerReceivedValue) {
readerReceivedValue = new Uint8Array(result.value);
} else {
const newValue = new Uint8Array(readerReceivedValue.length + result.value.length);
newValue.set(readerReceivedValue);
newValue.set(result.value, readerReceivedValue.length);
readerReceivedValue = newValue;
// result.value may be undefined when result.done is true
if (result.value) {
const newValue = new Uint8Array(readerReceivedValue.length + result.value.length);
newValue.set(readerReceivedValue);
newValue.set(result.value, readerReceivedValue.length);
readerReceivedValue = newValue;
}
}
this.item.endTime = Date.now();
this.item.costTime = this.item.endTime - (this.item.startTime || this.item.endTime);
Expand Down
2 changes: 1 addition & 1 deletion src/network/network.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<div class="vc-table-col vc-table-col-4 vc-table-col-value vc-max-height-line">{req.startTimeText}</div>
</div>
</div>
{#if (req.requestHeader !== null)}
{#if (req.requestHeader)}
<div>
<dl class="vc-table-row vc-left-border">
<dt class="vc-table-col vc-table-col-title">
Expand Down
2 changes: 1 addition & 1 deletion src/storage/storage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
await model.removeItem(key);
};
const onTapSave = async (key: string) => {
model.setItem(editingKey, editingVal); // set value anyway
if (editingKey !== key) {
await model.removeItem(key); // dirty key
}
model.setItem(editingKey, editingVal); // set value anyway
resetEditState(); // reset editing status
};
const onTapEdit = async (key: string, value: string, i: number) => {
Expand Down