Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
simgle_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 00745b41
authored
Jul 27, 2026
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perf(logger): 延迟加载远程日志模块以减小初始打包体积
将远程日志模块改为动态导入,仅在用户同意隐私政策后初始化时才加载,同时更新登录页的调用以适配异步方法
1 parent
0e50f364
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
pages/common/login.vue
utils/logger/index.js
pages/common/login.vue
View file @
00745b4
...
...
@@ -199,7 +199,7 @@ export default {
noSignIn
// 传递 30 天免登状态
});
// 初始化远程日志(Sentry),此时用户已同意隐私政策;username 作为 name 兜底
uni
.
$logger
.
initRemote
({
name
:
username
})
await
uni
.
$logger
.
initRemote
({
name
:
username
})
// 关闭 loading 并跳转到门店选择页面
uni
.
hideLoading
();
uni
.
navigateTo
({
...
...
utils/logger/index.js
View file @
00745b4
// import { index } from './env'
import
RemoteLog
from
'./RemoteLog'
import
LocalLog
from
'./LocalLog'
import
{
LogLevel
}
from
'./constants'
import
{
storageApi
}
from
'../cache'
...
...
@@ -15,12 +14,13 @@ class Logger {
init
()
{
// 本地日志立即初始化,确保记录每一个用户操作
this
.
local
=
new
LocalLog
()
// remote(Sentry)延迟初始化,等用户同意隐私政策后由 initRemote() 调用
// remote(Sentry)
动态导入
延迟初始化,等用户同意隐私政策后由 initRemote() 调用
}
// 延迟初始化远程日志(Sentry),在用户同意隐私政策后调用
// overrides: 可选的用户信息覆盖,用于初始化时 userInfo 尚未完整的情况
initRemote
(
overrides
=
{})
{
async
initRemote
(
overrides
=
{})
{
if
(
this
.
remote
)
return
const
{
default
:
RemoteLog
}
=
await
import
(
'./RemoteLog'
)
const
user
=
{
...
this
.
getUserInfo
(),
...
overrides
}
this
.
remote
=
new
RemoteLog
(
user
)
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment