Skip to content

Commit 7a771a9

Browse files
committedJan 6, 2024
feat: use css with console log
1 parent b2a17f1 commit 7a771a9

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed
 

‎src/GZCTF/ClientApp/src/utils/useConfig.ts

+24-22
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,36 @@ export const ValidatedRepoMeta = () => {
5959

6060
const showBanner = () => {
6161
const { sha, tag, buildtime, repo, valid } = ValidatedRepoMeta()
62-
const rst = '\x1b[0m'
63-
const bold = '\x1b[1m'
64-
const brand = '\x1b[38;2;4;202;171m'
65-
const alert = '\x1b[38;2;254;48;48m'
6662
const padding = ' '.repeat(45)
6763

68-
const showtag = valid ? `${brand}${tag}` : `${alert}Unknown`
69-
const commit = valid ? `${brand}${sha}` : `${alert}Unofficial build version`
64+
const bannerClr = ['color: #4ccaaa', 'color: unset']
65+
const textClr = ['font-weight: bold', 'font-weight: bold; color: #4ccaaa']
66+
const badClr = ['font-weight: bold', 'font-weight: bold; color: #fe3030']
7067

71-
const title = `
72-
██████╗ ███████╗ ${brand} ${rst} ██████╗████████╗███████╗
73-
██╔════╝ ╚══███╔╝ ${brand} ██╗██╗ ${rst} ██╔════╝╚══██╔══╝██╔════╝
74-
██║ ███╗ ███╔╝ ${brand} ╚═╝╚═╝ ${rst} ██║ ██║ █████╗
75-
██║ ██║ ███╔╝ ${brand} ██╗██╗ ${rst} ██║ ██║ ██╔══╝
76-
╚██████╔╝███████╗ ${brand} ╚═╝╚═╝ ${rst} ╚██████╗ ██║ ██║
77-
╚═════╝ ╚══════╝ ${brand} ${rst} ╚═════╝ ╚═╝ ╚═╝
68+
const banner = `
69+
██████╗ ███████╗ ██████╗████████╗███████╗
70+
██╔════╝ ╚══███╔╝ %c ██╗██╗ %c ██╔════╝╚══██╔══╝██╔════╝
71+
██║ ███╗ ███╔╝ %c ╚═╝╚═╝ %c ██║ ██║ █████╗
72+
██║ ██║ ███╔╝ %c ██╗██╗ %c ██║ ██║ ██╔══╝
73+
╚██████╔╝███████╗ %c ╚═╝╚═╝ %c ╚██████╗ ██║ ██║
74+
╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝
75+
${padding}%c@ %c${valid ? tag : 'Unknown'}
7876
79-
${padding}${bold}@ ${showtag}${rst}
80-
`
77+
%cCopyright (C) 2022-now, GZTimeWalker, All rights reserved.
8178
79+
%cLicense : %cGNU Affero General Public License v3.0
80+
%cCommit : %c${valid ? sha : 'Unofficial build version'}
81+
%cBuilt at : %c${buildtime.format('YYYY-MM-DDTHH:mm:ssZ')}
82+
%cIssues : %c${repo}/issues
83+
`
84+
85+
// rewrite the show banner function with %c and css
8286
console.log(
83-
`${title}` +
84-
`\n${bold}Copyright (C) 2022-now, GZTimeWalker, All rights reserved.${rst}\n` +
85-
`\n${bold}License : ${brand}GNU Affero General Public License v3.0${rst}` +
86-
`\n${bold}Commit : ${commit}${rst}` +
87-
`\n${bold}Built at : ${brand}${buildtime.format('YYYY-MM-DDTHH:mm:ssZ')}${rst}` +
88-
`\n${bold}Issues : ${repo}/issues` +
89-
'\n'
87+
banner,
88+
...bannerClr.concat(bannerClr, bannerClr, bannerClr),
89+
...(valid ? textClr : badClr),
90+
'font-weight: bold',
91+
...textClr.concat(valid ? textClr : badClr, textClr, textClr)
9092
)
9193
}
9294

0 commit comments

Comments
 (0)
Please sign in to comment.