Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
e11a227f
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e11a227f
编写于
5月 26, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: systemInfo ssr
上级
a5f0a378
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
199 deletion
+11
-199
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+3
-197
packages/uni-h5/src/service/api/device/getSystemInfoSync.ts
packages/uni-h5/src/service/api/device/getSystemInfoSync.ts
+8
-2
未找到文件。
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
e11a227f
...
@@ -905,13 +905,6 @@ function getRealPath(filePath) {
...
@@ -905,13 +905,6 @@ function getRealPath(filePath) {
}
}
return
filePath
;
return
filePath
;
}
}
const
ua
=
navigator
.
userAgent
;
const
isAndroid
=
/* @__PURE__ */
/android/i
.
test
(
ua
);
const
isIOS
=
/* @__PURE__ */
/iphone|ipad|ipod/i
.
test
(
ua
);
const
isWindows
=
/* @__PURE__ */
ua
.
match
(
/Windows NT
([\d
|
\d
.
\d]
*
)
/i
);
const
isMac
=
/* @__PURE__ */
/Macintosh|Mac/i
.
test
(
ua
);
const
isLinux
=
/* @__PURE__ */
/Linux|X11/i
.
test
(
ua
);
const
isIPadOS
=
isMac
&&
navigator
.
maxTouchPoints
>
0
;
const
HTTP_METHODS
=
[
const
HTTP_METHODS
=
[
"
GET
"
,
"
GET
"
,
"
OPTIONS
"
,
"
OPTIONS
"
,
...
@@ -10028,198 +10021,11 @@ const getStorageInfoSync = /* @__PURE__ */ defineSyncApi("getStorageInfoSync", (
...
@@ -10028,198 +10021,11 @@ const getStorageInfoSync = /* @__PURE__ */ defineSyncApi("getStorageInfoSync", (
const
getStorageInfo
=
/* @__PURE__ */
defineAsyncApi
(
"
getStorageInfo
"
,
(
_
,
{
resolve
})
=>
{
const
getStorageInfo
=
/* @__PURE__ */
defineAsyncApi
(
"
getStorageInfo
"
,
(
_
,
{
resolve
})
=>
{
resolve
(
getStorageInfoSync
());
resolve
(
getStorageInfoSync
());
});
});
function
IEVersion
()
{
const
userAgent
=
navigator
.
userAgent
;
const
isIE
=
userAgent
.
indexOf
(
"
compatible
"
)
>
-
1
&&
userAgent
.
indexOf
(
"
MSIE
"
)
>
-
1
;
const
isEdge
=
userAgent
.
indexOf
(
"
Edge
"
)
>
-
1
&&
!
isIE
;
const
isIE11
=
userAgent
.
indexOf
(
"
Trident
"
)
>
-
1
&&
userAgent
.
indexOf
(
"
rv:11.0
"
)
>
-
1
;
if
(
isIE
)
{
const
reIE
=
new
RegExp
(
"
MSIE (
\\
d+
\\
.
\\
d+);
"
);
reIE
.
test
(
userAgent
);
const
fIEVersion
=
parseFloat
(
RegExp
.
$1
);
if
(
fIEVersion
>
6
)
{
return
fIEVersion
;
}
else
{
return
6
;
}
}
else
if
(
isEdge
)
{
return
-
1
;
}
else
if
(
isIE11
)
{
return
11
;
}
else
{
return
-
1
;
}
}
function
getDeviceBrand
(
model
)
{
if
(
/iphone/gi
.
test
(
model
)
||
/ipad/gi
.
test
(
model
)
||
/mac/gi
.
test
(
model
))
{
return
"
apple
"
;
}
if
(
/windows/gi
.
test
(
model
))
{
return
"
microsoft
"
;
}
}
function
getBrowserInfo
()
{
let
osname
;
let
osversion
=
"
0
"
;
let
model
=
""
;
let
deviceType
=
"
phone
"
;
const
language
=
navigator
.
language
;
if
(
isIOS
)
{
osname
=
"
iOS
"
;
const
osversionFind
=
ua
.
match
(
/OS
\s([\w
_
]
+
)\s
like/
);
if
(
osversionFind
)
{
osversion
=
osversionFind
[
1
].
replace
(
/_/g
,
"
.
"
);
}
const
modelFind
=
ua
.
match
(
/
\(([
a-zA-Z
]
+
)
;/
);
if
(
modelFind
)
{
model
=
modelFind
[
1
];
}
}
else
if
(
isAndroid
)
{
osname
=
"
Android
"
;
const
osversionFind
=
ua
.
match
(
/Android
[\s/]([\w\.]
+
)[
;
\s]
/
);
if
(
osversionFind
)
{
osversion
=
osversionFind
[
1
];
}
const
infoFind
=
ua
.
match
(
/
\((
.+
?)\)
/
);
const
infos
=
infoFind
?
infoFind
[
1
].
split
(
"
;
"
)
:
ua
.
split
(
"
"
);
const
otherInfo
=
[
/
\b
Android
\b
/i
,
/
\b
Linux
\b
/i
,
/
\b
U
\b
/i
,
/^
\s?[
a-z
][
a-z
]
$/i
,
/^
\s?[
a-z
][
a-z
]
-
[
a-z
][
a-z
]
$/i
,
/
\b
wv
\b
/i
,
/
\/[\d\.
,
]
+$/
,
/^
\s?[\d\.
,
]
+$/
,
/
\b
Browser
\b
/i
,
/
\b
Mobile
\b
/i
];
for
(
let
i
=
0
;
i
<
infos
.
length
;
i
++
)
{
const
info
=
infos
[
i
];
if
(
info
.
indexOf
(
"
Build
"
)
>
0
)
{
model
=
info
.
split
(
"
Build
"
)[
0
].
trim
();
break
;
}
let
other
;
for
(
let
o
=
0
;
o
<
otherInfo
.
length
;
o
++
)
{
if
(
otherInfo
[
o
].
test
(
info
))
{
other
=
true
;
break
;
}
}
if
(
!
other
)
{
model
=
info
.
trim
();
break
;
}
}
}
else
if
(
isIPadOS
)
{
model
=
"
iPad
"
;
osname
=
"
iOS
"
;
deviceType
=
"
pad
"
;
osversion
=
typeof
window
.
BigInt
===
"
function
"
?
"
14.0
"
:
"
13.0
"
;
}
else
if
(
isWindows
||
isMac
||
isLinux
)
{
model
=
"
PC
"
;
osname
=
"
PC
"
;
deviceType
=
"
pc
"
;
osversion
=
"
0
"
;
let
osversionFind
=
ua
.
match
(
/
\((
.+
?)\)
/
)[
1
];
if
(
isWindows
)
{
osname
=
"
Windows
"
;
switch
(
isWindows
[
1
])
{
case
"
5.1
"
:
osversion
=
"
XP
"
;
break
;
case
"
6.0
"
:
osversion
=
"
Vista
"
;
break
;
case
"
6.1
"
:
osversion
=
"
7
"
;
break
;
case
"
6.2
"
:
osversion
=
"
8
"
;
break
;
case
"
6.3
"
:
osversion
=
"
8.1
"
;
break
;
case
"
10.0
"
:
osversion
=
"
10
"
;
break
;
}
const
framework
=
osversionFind
&&
osversionFind
.
match
(
/
[
Win|WOW
]([\d]
+
)
/
);
if
(
framework
)
{
osversion
+=
` x
${
framework
[
1
]}
`
;
}
}
else
if
(
isMac
)
{
osname
=
"
Mac
"
;
const
_osversion
=
osversionFind
&&
osversionFind
.
match
(
/Mac OS X
(
.+
)
/
)
||
""
;
if
(
osversion
)
{
osversion
=
_osversion
[
1
].
replace
(
/_/g
,
"
.
"
);
if
(
osversion
.
indexOf
(
"
;
"
)
!==
-
1
)
{
osversion
=
osversion
.
split
(
"
;
"
)[
0
];
}
}
}
else
if
(
isLinux
)
{
osname
=
"
Linux
"
;
const
_osversion
=
osversionFind
&&
osversionFind
.
match
(
/Linux
(
.*
)
/
)
||
""
;
if
(
_osversion
)
{
osversion
=
_osversion
[
1
];
if
(
osversion
.
indexOf
(
"
;
"
)
!==
-
1
)
{
osversion
=
osversion
.
split
(
"
;
"
)[
0
];
}
}
}
}
else
{
osname
=
"
Other
"
;
osversion
=
"
0
"
;
deviceType
=
"
other
"
;
}
const
system
=
`
${
osname
}
${
osversion
}
`
;
const
platform
=
osname
.
toLocaleLowerCase
();
let
browserName
=
""
;
let
browseVersion
=
String
(
IEVersion
());
if
(
browseVersion
!==
"
-1
"
)
{
browserName
=
"
IE
"
;
}
else
{
const
browseVendors
=
[
"
Version
"
,
"
Firefox
"
,
"
Chrome
"
,
"
Edge{0,1}
"
];
const
vendors
=
[
"
Safari
"
,
"
Firefox
"
,
"
Chrome
"
,
"
Edge
"
];
for
(
let
index2
=
0
;
index2
<
browseVendors
.
length
;
index2
++
)
{
const
vendor
=
browseVendors
[
index2
];
const
reg
=
new
RegExp
(
`(
${
vendor
}
)/(\\S*)\\b`
);
if
(
reg
.
test
(
ua
))
{
browserName
=
vendors
[
index2
];
browseVersion
=
ua
.
match
(
reg
)[
2
];
}
}
}
let
deviceBrand
=
""
;
if
(
model
)
{
const
_model
=
model
.
toLocaleLowerCase
();
deviceBrand
=
getDeviceBrand
(
_model
)
||
getDeviceBrand
(
osname
.
toLocaleLowerCase
())
||
_model
.
split
(
"
"
)[
0
];
}
let
deviceOrientation
=
"
portrait
"
;
const
orientation
=
typeof
window
.
screen
.
orientation
===
"
undefined
"
?
window
.
orientation
:
window
.
screen
.
orientation
.
angle
;
deviceOrientation
=
Math
.
abs
(
orientation
)
===
90
?
"
landscape
"
:
"
portrait
"
;
return
{
deviceBrand
,
deviceModel
:
model
,
deviceOrientation
,
brand
:
deviceBrand
,
model
,
system
,
platform
,
browserName
:
browserName
.
toLocaleLowerCase
(),
browseVersion
,
language
,
deviceType
,
ua
,
osname
,
osversion
,
theme
:
""
};
}
let
browserInfo
;
let
browserInfo
;
function
initBrowserInfo
()
{
function
initBrowserInfo
()
{
browserInfo
=
getBrowserInfo
();
{
return
browserInfo
=
{};
}
}
}
const
getDeviceInfo
=
/* @__PURE__ */
defineSyncApi
(
"
getDeviceInfo
"
,
()
=>
{
const
getDeviceInfo
=
/* @__PURE__ */
defineSyncApi
(
"
getDeviceInfo
"
,
()
=>
{
initBrowserInfo
();
initBrowserInfo
();
...
...
packages/uni-h5/src/service/api/device/getSystemInfoSync.ts
浏览文件 @
e11a227f
...
@@ -4,10 +4,16 @@ import { getBrowserInfo } from '../base/getBrowserInfo'
...
@@ -4,10 +4,16 @@ import { getBrowserInfo } from '../base/getBrowserInfo'
import
{
getWindowInfo
}
from
'
./getWindowInfo
'
import
{
getWindowInfo
}
from
'
./getWindowInfo
'
import
{
extend
}
from
'
@vue/shared
'
import
{
extend
}
from
'
@vue/shared
'
let
browserInfo
:
ReturnType
<
typeof
getBrowserInfo
>
type
BrowserInfo
=
ReturnType
<
typeof
getBrowserInfo
>
let
browserInfo
:
BrowserInfo
let
_initBrowserInfo
=
true
let
_initBrowserInfo
=
true
function
initBrowserInfo
()
{
function
initBrowserInfo
()
{
if
(
__NODE_JS__
)
{
//TODO 临时搞一下配合 uniCloud 测试
return
(
browserInfo
=
{}
as
BrowserInfo
)
}
if
(
!
_initBrowserInfo
)
return
if
(
!
_initBrowserInfo
)
return
browserInfo
=
getBrowserInfo
()
browserInfo
=
getBrowserInfo
()
}
}
...
@@ -67,7 +73,7 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
...
@@ -67,7 +73,7 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
return
{
return
{
deviceId
:
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
),
deviceId
:
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
),
platform
:
'
nodejs
'
,
platform
:
'
nodejs
'
,
}
as
unknown
as
UniApp
.
GetSystemInfoResult
}
as
UniApp
.
GetSystemInfoResult
}
}
_initBrowserInfo
=
true
_initBrowserInfo
=
true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录