Skip to content

Commit 0d3c5b1

Browse files
qkang07wqcstrong
authored andcommittedJan 17, 2025
mp system panel finish
1 parent 72fd796 commit 0d3c5b1

File tree

5 files changed

+107
-54
lines changed

5 files changed

+107
-54
lines changed
 

‎.env

-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ VITE_PLUGIN_DOC=https://github.com/HuolalaTech/page-spy/blob/main/docs/plugin.md
1515
VITE_PLUGIN_RRWEB=https://github.com/HuolalaTech/page-spy/tree/main/packages/page-spy-plugin-rrweb
1616
VITE_PLUGIN_DATA_HARBOR=https://github.com/HuolalaTech/page-spy/tree/main/packages/page-spy-plugin-data-harbor
1717
VITE_PLUGIN_RN_STORAGE=https://github.com/HuolalaTech/page-spy/tree/main/packages/page-spy-plugin-rn-async-storage
18-
VITE_API_BASE=localhost:6752

‎src/components/SystemContent/MPSysInfo/index.tsx

+61-36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import './index.less';
33
import '../index.less';
4-
import { Card, Typography, Grid, Row, Col } from 'antd';
4+
import { Card, Typography, Grid, Row, Col, Empty, Space, Divider } from 'antd';
55
import {
66
AppAuthSettings,
77
AuthInfo,
@@ -27,14 +27,15 @@ const Schemas = [
2727
title: '基础信息',
2828
schema: DeviceInfo,
2929
},
30-
{
31-
title: '手机系统信息',
32-
schema: SysInfo,
33-
},
3430
{
3531
title: '应用授权',
3632
schema: AppAuthSettings,
3733
},
34+
{
35+
title: '手机系统信息',
36+
schema: SysInfo,
37+
},
38+
3839
{
3940
title: '用户授权',
4041
schema: AuthInfo,
@@ -71,10 +72,22 @@ const MPSysInfo = (props: Props) => {
7172
<Col span={8}>
7273
<div className="mp-info-main">
7374
<img className="info-icon" src={clientInfo?.os.logo} />
74-
<span>
75-
{sysInfo?.brand} {sysInfo?.model} {clientInfo?.os.name}{' '}
76-
{clientInfo?.os.version}
77-
</span>
75+
<Space
76+
split={
77+
<Divider style={{ marginInline: 0 }} type="vertical" />
78+
}
79+
size="small"
80+
>
81+
{[
82+
sysInfo?.brand,
83+
sysInfo?.model,
84+
clientInfo?.os.name + ' ' + clientInfo?.os.version,
85+
]
86+
.filter((v) => v)
87+
.map((v, i) => (
88+
<span key={i}>{v}</span>
89+
))}
90+
</Space>
7891
</div>
7992
</Col>
8093
<Col span={16}>
@@ -89,39 +102,51 @@ const MPSysInfo = (props: Props) => {
89102
</Card>
90103
</div>
91104
{Schemas.map(({ title, schema }) => {
105+
const items = schema
106+
.map((item) => {
107+
const key = item.keys.find(
108+
(key) =>
109+
// TODO: how to distinguish the real 'undefined' string?
110+
sysInfo[key] !== undefined && sysInfo[key] !== 'undefined',
111+
);
112+
return { key, item };
113+
})
114+
.filter((item) => item.key);
115+
if (!items.length) {
116+
return (
117+
<div key={title} className="system-info">
118+
<Title level={3}>{title}</Title>
119+
<Card>
120+
<Empty description={false} />
121+
</Card>
122+
</div>
123+
);
124+
}
92125
return (
93126
<div key={title} className="system-info">
94127
<Title level={3}>{title}</Title>
95128
<Card>
96129
<Row>
97-
{schema.map((item, index) => {
98-
const key = item.keys.find((key) =>
99-
Object.hasOwn(sysInfo, key),
100-
);
101-
if (key) {
102-
return (
103-
<Col
104-
key={key}
105-
span={spanValue?.featSpan}
106-
xxl={{
107-
span: spanValue?.xxlFeatSpan,
108-
}}
109-
>
110-
<div className="mp-info-item" key={key}>
111-
<div className="system-info__name">
112-
<div className="system-info__label">{key}</div>
113-
<div className="system-info__desc">
114-
{item.label}
115-
</div>
116-
</div>
117-
<div className="system-info__value">
118-
{renderValue(item, sysInfo[key])}
119-
</div>
130+
{items.map(({ key, item }) => {
131+
return (
132+
<Col
133+
key={key}
134+
span={spanValue?.featSpan}
135+
xxl={{
136+
span: spanValue?.xxlFeatSpan,
137+
}}
138+
>
139+
<div className="mp-info-item" key={key}>
140+
<div className="system-info__name">
141+
<div className="system-info__label">{key}</div>
142+
<div className="system-info__desc">{item.label}</div>
120143
</div>
121-
</Col>
122-
);
123-
}
124-
return <></>;
144+
<div className="system-info__value">
145+
{renderValue(item, sysInfo[key!])}
146+
</div>
147+
</div>
148+
</Col>
149+
);
125150
})}
126151
</Row>
127152
</Card>

‎src/components/SystemContent/MPSysInfo/infoSchema.tsx

+26-14
Original file line numberDiff line numberDiff line change
@@ -143,59 +143,71 @@ export const AppAuthSettings: InfoItem[] = [
143143

144144
export const AuthInfo: InfoItem[] = [
145145
{
146-
keys: ['scope.userLocation'],
146+
keys: ['scope.hostId'],
147+
label: '授权抖音号',
148+
},
149+
{
150+
keys: ['scope.userLocation', 'userLocation'],
147151
label: '精确地理位置',
148152
},
149153
{
150-
keys: ['scope.userFuzzyLocation'],
154+
keys: ['scope.userFuzzyLocation', 'userFuzzyLocation'],
151155
label: '模糊地理位置',
152156
},
153157
{
154-
keys: ['scope.userLocationBackground'],
158+
keys: ['scope.userLocationBackground', 'userLocationBackground'],
155159
label: '后台定位',
156160
},
157161
{
158-
keys: ['scope.record'],
162+
keys: ['scope.record', 'record'],
159163
label: '麦克风',
160164
},
161165
{
162-
keys: ['scope.camera'],
166+
keys: ['scope.camera', 'camera'],
163167
label: '摄像头',
164168
},
165169
{
166-
keys: ['scope.bluetooth'],
170+
keys: ['scope.bluetooth', 'bluetooth'],
167171
label: '蓝牙',
168172
},
169173
{
170-
keys: ['scope.writePhotosAlbum'],
174+
keys: ['scope.writePhotosAlbum', 'writePhotosAlbum'],
171175
label: '添加到相册',
172176
},
173177
{
174-
keys: ['scope.addPhoneContact'],
178+
keys: ['scope.album'],
179+
label: '读取相册', // 抖音
180+
},
181+
{
182+
keys: ['scope.addPhoneContact', 'addPhoneContact'],
175183
label: '添加到联系人',
176184
},
177185
{
178-
keys: ['scope.addPhoneCalendar'],
186+
keys: ['scope.addPhoneCalendar', 'addPhoneCalendar', 'scope.calendar'],
179187
label: '添加日历事件',
180188
},
181189
{
182-
keys: ['scope.werun'],
190+
keys: ['scope.werun', 'werun'],
183191
label: '微信运动步数',
184192
},
185193
{
186-
keys: ['scope.address'],
194+
keys: ['scope.address', 'address'],
187195
label: '通讯地址',
188196
},
189197
{
190-
keys: ['scope.invoiceTitle'],
198+
keys: ['scope.invoiceTitle', 'invoiceTitle'],
191199
label: '发票抬头',
192200
},
193201
{
194-
keys: ['scope.invoice'],
202+
keys: ['scope.invoice', 'invoice'],
195203
label: '获取发票',
196204
},
197205
{
198-
keys: ['scope.userInfo'],
206+
keys: ['scope.userInfo', 'userInfo'],
199207
label: '用户信息',
200208
},
209+
{
210+
keys: ['scope.clipboard'],
211+
label: '剪切板',
212+
},
201213
];

‎src/components/SystemContent/index.tsx

+17-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ const SystemContent = memo(({ data }: SystemContentProps) => {
2222
const clientInfo = useMemo(() => {
2323
return parseUserAgent(system?.ua);
2424
}, [system]);
25+
26+
const mpSysInfo = useMemo(() => {
27+
if (mp) {
28+
try {
29+
const sysInfo = JSON.parse(mp);
30+
return sysInfo;
31+
} catch (e) {
32+
console.error(e);
33+
// if parse error, the client is still mp, should display the mp panel.
34+
return {};
35+
}
36+
}
37+
return null;
38+
}, [mp]);
39+
2540
const noSupport = useMemo(() => {
2641
if (!features) return [];
2742
return Object.values(features).reduce((acc, cur) => {
@@ -53,8 +68,8 @@ const SystemContent = memo(({ data }: SystemContentProps) => {
5368
if (data.length === 0) {
5469
return <Empty description={false} />;
5570
}
56-
if (mp) {
57-
return <MPSysInfo sysInfo={mp} spanValue={spanValue} />;
71+
if (mpSysInfo) {
72+
return <MPSysInfo sysInfo={mpSysInfo} spanValue={spanValue} />;
5873
}
5974
return (
6075
<div className="system-content">

‎src/pages/Devtools/SystemPanel/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { useTranslation } from 'react-i18next';
77

88
const SystemPanel = memo(() => {
99
const systemMsg = useSocketMessageStore((state) => state.systemMsg);
10+
const refresh = useSocketMessageStore((state) => state.refresh);
11+
1012
const { t } = useTranslation();
1113

1214
if (systemMsg.length === 0) {
@@ -19,7 +21,7 @@ const SystemPanel = memo(() => {
1921
<Tooltip title={t('common.refresh')}>
2022
<Button
2123
onClick={() => {
22-
refresh(activeTab);
24+
refresh('system');
2325
}}
2426
>
2527
<ReloadOutlined />

0 commit comments

Comments
 (0)
Please sign in to comment.