Skip to content

Commit

Permalink
feat: vin
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Feb 24, 2024
1 parent 8083898 commit adea942
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/layouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,29 @@ class Index extends React.Component<Props, State> {

// try to load VIN (Very Important Notice)
fetch(`${process.env.PUBLIC_PATH}vin.txt`)
.then((r) => r.text())
.then((r) => {
if (
r.headers.get('content-type').startsWith('text/plain') &&
r.status >= 200 &&
r.status < 400
) {
return r.text();
}
throw new Error('No invalid txt');
})
.then((res) => {
const vin = res.trim();
if (vin) {
const content = res.trim();
if (content.startsWith('VIN:')) {
const vin = content.substr(4);
notification.warning({
message: 'Important Notice',
description: vin,
duration: null,
});
}
})
.catch(() => {
console.log('No valid vin file, skip');
.catch((e) => {
console.log('No valid vin file, skip.', e);
});
}

Expand Down

0 comments on commit adea942

Please sign in to comment.