Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
web-lib
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑磊
web-lib
Commits
d2ee7c3f
Commit
d2ee7c3f
authored
Jun 16, 2026
by
郑磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getStatusBar方法支持根据配置参数计算顶部状态栏高度
parent
759ebe4b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
environment.ts
miniapp/environment.ts
+1
-1
environment.ts
web/environment.ts
+10
-0
native-api.ts
web/native-api.ts
+24
-1
No files found.
miniapp/environment.ts
View file @
d2ee7c3f
import
{
getCookie
}
from
'../web/cookie'
export
{
type
DeviceType
,
device
,
in_app
,
lang
,
open_source
}
from
'../web/environment'
export
{
type
DeviceType
,
device
,
in_app
,
lang
,
open_source
,
run_methods
}
from
'../web/environment'
/**
* 当前轻应用的appid
...
...
web/environment.ts
View file @
d2ee7c3f
...
...
@@ -56,3 +56,13 @@ export const lang = normalizeLang(getCookie('lang') || navigator.language)
* 当前页面的打开来源
*/
export
const
open_source
=
getCookie
(
'open_source'
)
||
''
/**
* 通过地址栏runmethod参数传递给页面的控制参数
*/
export
const
run_methods
=
(()
=>
{
const
url
=
new
URL
(
location
.
href
)
const
methods
=
url
.
searchParams
.
get
(
'runmethod'
)
if
(
!
methods
)
return
[]
return
methods
.
split
(
'_'
)
})()
web/native-api.ts
View file @
d2ee7c3f
import
{
run_methods
}
from
'./environment'
import
{
callNativeApi
,
callNativeAsyncApi
}
from
'./native-api-base'
/**
...
...
@@ -9,10 +10,32 @@ export function close() {
}
/**
* 获取状态栏高度
* 获取状态栏高度
(会根据是否有顶部导航栏、是否半屏来自动判断)
* @returns
*/
export
function
getStatusBarHeight
():
Promise
<
number
>
{
if
(
!
run_methods
.
includes
(
'hidetopbar'
))
{
//页面会显示导航栏,始终返回0
return
Promise
.
resolve
(
0
)
}
//尝试解析height参数,这是半屏显示
const
height
=
new
URL
(
location
.
href
).
searchParams
.
get
(
'height'
)
if
(
height
!==
null
)
{
const
numberHeight
=
parseInt
(
height
)
if
(
!
isNaN
(
numberHeight
)
&&
numberHeight
>
0
&&
numberHeight
<
100
)
{
//指定了半屏参数
return
Promise
.
resolve
(
0
)
}
}
return
getStatusBarHeightRaw
()
}
/**
* 获取原始的状态栏高度(不考虑半屏影响)
*/
export
function
getStatusBarHeightRaw
():
Promise
<
number
>
{
console
.
log
(
'调用框架方法'
,
'getStatusBarHeight'
)
return
new
Promise
<
number
>
((
resolve
)
=>
callNativeApi
(
'getStatusBarHeight'
,
(
value
:
any
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment