Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check browser compatibility simply #654

Merged
merged 7 commits into from
Jun 30, 2020
Merged

Conversation

baurine
Copy link
Collaborator

@baurine baurine commented Jun 22, 2020

A simpler version of PR #634 .

Just show a prompt message for the browser that is not included in the supported browsers list.

image


// This part code is auto generated by `yarn supportedBrowsers` command.
// Don't edit it and always keep it in the end of this file. It means don't add new content after it.
;checkBrowser(/((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(9[_\.]3|9[_\.]([4-9]|\d{2,})|([1-9]\d|\d{3,})[_\.]\d+|11[_\.]3|11[_\.]([4-9]|\d{2,})|(1[2-9]|[2-9]\d|\d{3,})[_\.]\d+|12[_\.]0|12[_\.]([1-9]|\d{2,})|12[_\.]4|12[_\.]([5-9]|\d{2,})|(1[3-9]|[2-9]\d|\d{3,})[_\.]\d+|13[_\.]0|13[_\.]([1-9]|\d{2,})|13[_\.]3|13[_\.]([4-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_\.]\d+)(?:[_\.]\d+)?)|(CFNetwork\/8.* Darwin\/16\.5\.\d+)|(CFNetwork\/8.* Darwin\/16\.6\.\d+)|(CFNetwork\/8.* Darwin\/16\.7\.\d+)|(SamsungBrowser\/(10\.1|10\.([2-9]|\d{2,})|(1[1-9]|[2-9]\d|\d{3,})\.\d+))|(Edge\/(18(?:\.0)?|18(?:\.([1-9]|\d{2,}))?|(19|[2-9]\d|\d{3,})(?:\.\d+)?))|((Chromium|Chrome)\/(49\.0|49\.([1-9]|\d{2,})|([5-9]\d|\d{3,})\.\d+|79\.0|79\.([1-9]|\d{2,})|([8-9]\d|\d{3,})\.\d+)(?:\.\d+)?([\d.]+$|.*Safari\/(?![\d.]+ Edge\/[\d.]+$)))|(Version\/(12\.1|12\.([2-9]|\d{2,})|(1[3-9]|[2-9]\d|\d{3,})\.\d+|13\.0|13\.([1-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Trident\/7\.0)|(Firefox\/(68\.0|68\.([1-9]|\d{2,})|(69|[7-9]\d|\d{3,})\.\d+|74\.0|74\.([1-9]|\d{2,})|(7[5-9]|[8-9]\d|\d{3,})\.\d+)\.\d+)|(Firefox\/(68\.0|68\.([1-9]|\d{2,})|(69|[7-9]\d|\d{3,})\.\d+|74\.0|74\.([1-9]|\d{2,})|(7[5-9]|[8-9]\d|\d{3,})\.\d+)(pre|[ab]\d+[a-z]*)?)|(([MS]?IE) (11\.0|11\.([1-9]|\d{2,})|(1[2-9]|[2-9]\d|\d{3,})\.\d+))/)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the supported browser list fixed, don't change them every time when building anymore. It may be changed by manually running yarn supportedBrowsers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that this part will be auto-generated, how about simply use placeholders like __SUPPORTED_BROWSERS__?

Copy link
Collaborator Author

@baurine baurine Jun 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean ;checkBrowser(__SUPPORTED_BROWSERS__)? But I think the content should be fixed and don't change often, so they should be included in the code repo, right?

Or do you mean var __SUPPORTED_BROWSERS__ = /.../, I tried this for the first time but found it doesn't work. Because we defined it in the last, when we access it before, its value is null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I mean, make this file kind of "template", and plug it into the gulp's standard stream to generate a final script content.

You are right, it is indeed changed not very often. I'm ok with the current implementation now.

'一些功能在此浏览器上可能无法工作,请使用最新版本的 Chrome/Edge/Firefox/Safari 浏览器。'
} else {
text =
'Some features may not work in your browser. Please use latest Chrome/Edge/Firefox/Safari browsers.'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is enough to use latest to represent the version instead of a specific version value. Because when people want to upgrade or download an app, they just care about the newest version. How do you think about it? @breeswish

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so!

ui/package.json Outdated
@@ -47,7 +47,8 @@
"build": "gulp build",
"build:library": "gulp build:library",
"test": "react-app-rewired test",
"fmt": "prettier --write ."
"fmt": "prettier --write .",
"supportedBrowsers": "gulp supportedBrowsers"
Copy link
Member

@breezewish breezewish Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to add a verb for it to be aligned with others, like, gen:browserlist

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good naming, will update it.

@@ -28,6 +28,15 @@ task(
shell.task('yarn react-app-rewired build --library')
)

task(
Copy link
Member

@breezewish breezewish Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to use gulp style file process? e.g. input a file, transform, and finally output. We can also use the API to get a list of supported browsers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, let me try it.

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job

@ti-srebot
Copy link

@breeswish,Thanks for you review.

@breezewish breezewish merged commit 9d4982a into pingcap:master Jun 30, 2020
@baurine baurine deleted the browers-list branch June 30, 2020 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants