Skip to content

Commit ccb180f

Browse files
author
ubuntu
committed
Update community
1 parent b816db7 commit ccb180f

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

docs/community.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
<script>
2-
function getQuery(name) {
2+
function isBrowserLanguageChinese() {
3+
// 获取浏览器的语言设置
4+
const language = navigator.language || navigator.userLanguage;
5+
6+
// 判断语言是否为中文
7+
return language.startsWith('zh');
8+
}
9+
10+
function getQuery(name) {
311
var url = window.location.search;
412
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
513
var result = url.substr(1).match(reg);
614
return result ? decodeURIComponent(result[2]) : null;
715
}
816

9-
if (getQuery("from")=="qpyplus") {
10-
location.href='https://segmentfault.com/t/qpython'
17+
if (isBrowserLanguageChinese()) {
18+
location.href='https://www.qpython.com.cn/?from=app'
1119
} else {
12-
location.href='https://www.facebook.com/groups/qpython'
20+
location.href='https://discord.gg/hV2chuD'
1321
}
1422
</script>

qpython-docs/community.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
<script>
2-
function getQuery(name) {
2+
function isBrowserLanguageChinese() {
3+
// 获取浏览器的语言设置
4+
const language = navigator.language || navigator.userLanguage;
5+
6+
// 判断语言是否为中文
7+
return language.startsWith('zh');
8+
}
9+
10+
function getQuery(name) {
311
var url = window.location.search;
412
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
513
var result = url.substr(1).match(reg);
614
return result ? decodeURIComponent(result[2]) : null;
715
}
816

9-
if (getQuery("from")=="qpyplus") {
10-
location.href='https://segmentfault.com/t/qpython'
17+
if (isBrowserLanguageChinese()) {
18+
location.href='https://www.qpython.com.cn/?from=app'
1119
} else {
12-
location.href='https://www.facebook.com/groups/qpython'
20+
location.href='https://discord.gg/hV2chuD'
1321
}
1422
</script>

0 commit comments

Comments
 (0)