Skip to content

Commit

Permalink
chore: add DISABLE_USERAGENT env to hide ua fix #55
Browse files Browse the repository at this point in the history
  • Loading branch information
lizheming committed Dec 5, 2020
1 parent 3436ce0 commit a6589b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@
border-radius: .2em;
margin-right: .3em
}
.v[data-class=v] .vsys:empty {
display: none;
}

@media screen and (max-width:520px) {
.v[data-class=v] .vsys {
Expand Down
6 changes: 4 additions & 2 deletions packages/server/src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const {
TCB_ENV,
TENCENTCLOUD_SECRETKEY,
TCB_KEY,
SECURE_DOMAINS
SECURE_DOMAINS,
DISABLE_USERAGENT
} = process.env;

let storage = 'leancloud';
Expand Down Expand Up @@ -48,5 +49,6 @@ module.exports = {
jwtKey,
forbiddenWords,
disallowIPList: [],
secureDomains: SECURE_DOMAINS ? SECURE_DOMAINS.split(/\s*,\s*/) : undefined
secureDomains: SECURE_DOMAINS ? SECURE_DOMAINS.split(/\s*,\s*/) : undefined,
disableUserAgent: DISABLE_USERAGENT && !['0', 'false'].includes(DISABLE_USERAGENT.toLowerCase())
};
6 changes: 4 additions & 2 deletions packages/server/src/controller/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ marked.setOptions({
function formatCmt({ua, ip, ...comment}) {
ua = parser(ua)
comment.mail = helper.md5(comment.mail);
comment.browser = ua.browser.name + ' ' + ua.browser.version;
comment.os = ua.os.name + ' ' + ua.os.version;
if(!think.config('disableUserAgent')) {
comment.browser = ua.browser.name + ' ' + ua.browser.version;
comment.os = ua.os.name + ' ' + ua.os.version;
}
return comment;
}

Expand Down

0 comments on commit a6589b5

Please sign in to comment.