mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-03-31 16:39:45 +00:00
parent
6985c895e3
commit
549d095ff3
1 changed files with 4 additions and 14 deletions
|
@ -101,6 +101,7 @@ import '~/style/console.css';
|
||||||
|
|
||||||
import { useStorage } from '@vueuse/core';
|
import { useStorage } from '@vueuse/core';
|
||||||
import { AnsiUp } from 'ansi_up';
|
import { AnsiUp } from 'ansi_up';
|
||||||
|
import { decode } from 'js-base64';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { computed, inject, nextTick, onMounted, Ref, ref, toRef, watch } from 'vue';
|
import { computed, inject, nextTick, onMounted, Ref, ref, toRef, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
@ -178,17 +179,6 @@ function writeLog(line: Partial<LogLine>) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// SOURCE: https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings
|
|
||||||
function b64DecodeUnicode(str: string) {
|
|
||||||
return decodeURIComponent(
|
|
||||||
window
|
|
||||||
.atob(str)
|
|
||||||
.split('')
|
|
||||||
.map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`)
|
|
||||||
.join(''),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrollDown() {
|
function scrollDown() {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (!consoleElement.value) {
|
if (!consoleElement.value) {
|
||||||
|
@ -253,7 +243,7 @@ async function download() {
|
||||||
downloadInProgress.value = false;
|
downloadInProgress.value = false;
|
||||||
}
|
}
|
||||||
const fileURL = window.URL.createObjectURL(
|
const fileURL = window.URL.createObjectURL(
|
||||||
new Blob([logs.map((line) => b64DecodeUnicode(line.data)).join('')], {
|
new Blob([logs.map((line) => decode(line.data)).join('')], {
|
||||||
type: 'text/plain',
|
type: 'text/plain',
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -296,12 +286,12 @@ async function loadLogs() {
|
||||||
if (isStepFinished(step.value)) {
|
if (isStepFinished(step.value)) {
|
||||||
loadedStepSlug.value = stepSlug.value;
|
loadedStepSlug.value = stepSlug.value;
|
||||||
const logs = await apiClient.getLogs(repo.value.id, pipeline.value.number, step.value.id);
|
const logs = await apiClient.getLogs(repo.value.id, pipeline.value.number, step.value.id);
|
||||||
logs?.forEach((line) => writeLog({ index: line.line, text: b64DecodeUnicode(line.data), time: line.time }));
|
logs?.forEach((line) => writeLog({ index: line.line, text: decode(line.data), time: line.time }));
|
||||||
flushLogs(false);
|
flushLogs(false);
|
||||||
} else if (isStepRunning(step.value)) {
|
} else if (isStepRunning(step.value)) {
|
||||||
loadedStepSlug.value = stepSlug.value;
|
loadedStepSlug.value = stepSlug.value;
|
||||||
stream.value = apiClient.streamLogs(repo.value.id, pipeline.value.number, step.value.id, (line) => {
|
stream.value = apiClient.streamLogs(repo.value.id, pipeline.value.number, step.value.id, (line) => {
|
||||||
writeLog({ index: line.line, text: b64DecodeUnicode(line.data), time: line.time });
|
writeLog({ index: line.line, text: decode(line.data), time: line.time });
|
||||||
flushLogs(true);
|
flushLogs(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue