mirror of
https://github.com/sharevb/it-tools.git
synced 2026-12-01 01:14:13 +03:00
chore: global code formatting
This commit is contained in:
1 parent
5bf94bc567
commit
bc44870665
830 files changed
+21075
-13592
No files matched your search
+3
-3
@@ -1,3 +1,3 @@
|
||||
declare module "dom-to-image-more" {
|
||||
export function toPng(el: HTMLElement | undefined, options?: { bgcolor: string }) : Promise<string>;
|
||||
}
|
||||
declare module 'dom-to-image-more' {
|
||||
export function toPng(el: HTMLElement | undefined, options?: { bgcolor: string }): Promise<string>;
|
||||
}
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
declare module "javastack.js" {
|
||||
export default function javastack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
declare module 'javastack.js' {
|
||||
export default function javastack(selector: string, options: { prettyprint: boolean }): void;
|
||||
}
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
declare module "jsstack.js" {
|
||||
export default function jsstack(selector: string) : void;
|
||||
}
|
||||
declare module 'jsstack.js' {
|
||||
export default function jsstack(selector: string): void;
|
||||
}
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
declare module "netstack.js" {
|
||||
export default class netstack {
|
||||
constructor(el: HTMLElement | undefined, options: { prettyprint: boolean })
|
||||
}
|
||||
}
|
||||
declare module 'netstack.js' {
|
||||
export default class netstack {
|
||||
constructor(el: HTMLElement | undefined, options: { prettyprint: boolean });
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
declare module "pythonstack.js" {
|
||||
export default function pythonstack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
declare module 'pythonstack.js' {
|
||||
export default function pythonstack(selector: string, options: { prettyprint: boolean }): void;
|
||||
}
|
||||
@@ -13,7 +13,11 @@ const { t } = useI18n();
|
||||
|
||||
const styleStore = useStyleStore();
|
||||
|
||||
const stackType = useQueryParamOrStorage<'net' | 'js' | 'java' | 'python'>({ name: 'type', storageName: 'stackfmt:type', defaultValue: 'net' });
|
||||
const stackType = useQueryParamOrStorage<'net' | 'js' | 'java' | 'python'>({
|
||||
name: 'type',
|
||||
storageName: 'stackfmt:type',
|
||||
defaultValue: 'net',
|
||||
});
|
||||
const stackTrace = ref('');
|
||||
const formatedStackTrace = ref<HTMLElement>();
|
||||
|
||||
@@ -25,54 +29,54 @@ watchEffect(() => {
|
||||
let cleanedStackTrace;
|
||||
try {
|
||||
cleanedStackTrace = JSON.parse(stackTrace.value);
|
||||
}
|
||||
catch (_) {
|
||||
} catch (_) {
|
||||
cleanedStackTrace = stackTrace.value.replace(/(\\r)?\\n/g, '\n').replace(/(?:^['"])|(?:['"]$)/, '');
|
||||
};
|
||||
}
|
||||
try {
|
||||
if (stackType.value === 'js') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JSStack('.stacktrace');
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
} else if (stackType.value === 'java') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JavaStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
} else if (stackType.value === 'python') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
PythonStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'net') {
|
||||
} else if (stackType.value === 'net') {
|
||||
formatedStackTrace.value.innerText = cleanedStackTrace;
|
||||
const _ = new NetStack(formatedStackTrace.value, { prettyprint: true });
|
||||
}
|
||||
stackTraceText.value = formatedStackTrace.value.innerText;
|
||||
}
|
||||
catch {}
|
||||
} catch {}
|
||||
});
|
||||
|
||||
const stackTraceMarkdown = computed(() => {
|
||||
let lang;
|
||||
if (stackType.value === 'net') {
|
||||
lang = 'csharp';
|
||||
}
|
||||
else if (stackType.value === 'js') {
|
||||
} else if (stackType.value === 'js') {
|
||||
lang = 'javascript';
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
} else if (stackType.value === 'java') {
|
||||
lang = 'java';
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
} else if (stackType.value === 'python') {
|
||||
lang = 'python';
|
||||
}
|
||||
return `\`\`\`${lang}\n${formatedStackTrace.value?.innerText}\n\`\`\``;
|
||||
});
|
||||
|
||||
const { copy: copyText } = useCopy({ source: stackTraceText, text: t('tools.stacktrace-prettier.texts.text-formatted-stacktrace-copied-to-the-clipboard') });
|
||||
const { copy: copyMarkdown } = useCopy({ source: stackTraceMarkdown, text: t('tools.stacktrace-prettier.texts.text-markdown-formatted-stacktrace-copied-to-the-clipboard') });
|
||||
const { copy: copyText } = useCopy({
|
||||
source: stackTraceText,
|
||||
text: t('tools.stacktrace-prettier.texts.text-formatted-stacktrace-copied-to-the-clipboard'),
|
||||
});
|
||||
const { copy: copyMarkdown } = useCopy({
|
||||
source: stackTraceMarkdown,
|
||||
text: t('tools.stacktrace-prettier.texts.text-markdown-formatted-stacktrace-copied-to-the-clipboard'),
|
||||
});
|
||||
|
||||
async function downloadAsPNG() {
|
||||
const dataUrl = await domtoimage.toPng(formatedStackTrace.value, { bgcolor: styleStore.isDarkTheme ? '#333' : '#fff' });
|
||||
const dataUrl = await domtoimage.toPng(formatedStackTrace.value, {
|
||||
bgcolor: styleStore.isDarkTheme ? '#333' : '#fff',
|
||||
});
|
||||
const link = document.createElement('a');
|
||||
link.download = 'stacktrace.png';
|
||||
link.href = dataUrl;
|
||||
@@ -86,22 +90,10 @@ const wrap = ref(true);
|
||||
<div>
|
||||
<n-radio-group v-model:value="stackType" name="radiogroup" mb-2 flex justify-center>
|
||||
<n-space>
|
||||
<n-radio
|
||||
value="net"
|
||||
:label="t('tools.stacktrace-prettier.texts.label-net')"
|
||||
/>
|
||||
<n-radio
|
||||
value="js"
|
||||
:label="t('tools.stacktrace-prettier.texts.label-javascript')"
|
||||
/>
|
||||
<n-radio
|
||||
value="python"
|
||||
:label="t('tools.stacktrace-prettier.texts.label-python')"
|
||||
/>
|
||||
<n-radio
|
||||
value="java"
|
||||
:label="t('tools.stacktrace-prettier.texts.label-java')"
|
||||
/>
|
||||
<n-radio value="net" :label="t('tools.stacktrace-prettier.texts.label-net')" />
|
||||
<n-radio value="js" :label="t('tools.stacktrace-prettier.texts.label-javascript')" />
|
||||
<n-radio value="python" :label="t('tools.stacktrace-prettier.texts.label-python')" />
|
||||
<n-radio value="java" :label="t('tools.stacktrace-prettier.texts.label-java')" />
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
|
||||
@@ -120,7 +112,11 @@ const wrap = ref(true);
|
||||
|
||||
<n-divider />
|
||||
|
||||
<pre ref="formatedStackTrace" class="stacktrace" :style="{ padding: '20px', whiteSpace: wrap ? 'pre-wrap' : 'pre', overflowX: 'auto', wordBreak: 'break-all' }" />
|
||||
<pre
|
||||
ref="formatedStackTrace"
|
||||
class="stacktrace"
|
||||
:style="{ padding: '20px', whiteSpace: wrap ? 'pre-wrap' : 'pre', overflowX: 'auto', wordBreak: 'break-all' }"
|
||||
/>
|
||||
|
||||
<div v-if="stackTraceText" flex justify-center gap-1>
|
||||
<c-button @click="copyText()">
|
||||
@@ -138,19 +134,53 @@ const wrap = ref(true);
|
||||
|
||||
<style lang="less" scoped>
|
||||
::v-deep(.stacktrace) {
|
||||
pre, code {background-color:#333 !important; color: #fff !important;}
|
||||
.st-type {color: #0a8472; font-weight: bolder;}
|
||||
.st-method {color: #70c9ba; font-weight: bolder;}
|
||||
.st-frame-params {color: #ffffff; font-weight: normal;}
|
||||
.st-param-type {color: #0a8472;}
|
||||
.st-param-name {color: #ffffff;}
|
||||
.st-file {color:#f8b068;}
|
||||
.st-line {color:#ff4f68;}
|
||||
.st-methodName {color: #70c9ba;font-weight: bolder;}
|
||||
.st-column {color: #f8b068;}
|
||||
.st-lineNumber {color: #ff4f68;}
|
||||
.st-fileName {color: #85dbff;}
|
||||
.st-intro {color: #0044dd;}
|
||||
.st-exception {color: #e40000;}
|
||||
pre,
|
||||
code {
|
||||
background-color: #333 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
.st-type {
|
||||
color: #0a8472;
|
||||
font-weight: bolder;
|
||||
}
|
||||
.st-method {
|
||||
color: #70c9ba;
|
||||
font-weight: bolder;
|
||||
}
|
||||
.st-frame-params {
|
||||
color: #ffffff;
|
||||
font-weight: normal;
|
||||
}
|
||||
.st-param-type {
|
||||
color: #0a8472;
|
||||
}
|
||||
.st-param-name {
|
||||
color: #ffffff;
|
||||
}
|
||||
.st-file {
|
||||
color: #f8b068;
|
||||
}
|
||||
.st-line {
|
||||
color: #ff4f68;
|
||||
}
|
||||
.st-methodName {
|
||||
color: #70c9ba;
|
||||
font-weight: bolder;
|
||||
}
|
||||
.st-column {
|
||||
color: #f8b068;
|
||||
}
|
||||
.st-lineNumber {
|
||||
color: #ff4f68;
|
||||
}
|
||||
.st-fileName {
|
||||
color: #85dbff;
|
||||
}
|
||||
.st-intro {
|
||||
color: #0044dd;
|
||||
}
|
||||
.st-exception {
|
||||
color: #e40000;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user