uni-oaview 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/oa-single-select/oa-single-select.vue +3 -1
- package/components/oa-vconsole/awesome-display-info.vue +14 -3
- package/components/oa-vconsole/console.vue +1 -1
- package/components/oa-vconsole/native-event.vue +19 -12
- package/components/oa-vconsole/network.vue +28 -21
- package/components/oa-vconsole/oa-vconsole.vue +14 -8
- package/components/oa-vconsole/storage.vue +17 -10
- package/components/oa-vconsole/utils.ts +53 -35
- package/package.json +1 -1
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
<view class="search-box-item">
|
|
11
11
|
<picker-view :indicator-style="indicatorStyle" :value="indexList" @change="bindChange" class="picker-view">
|
|
12
12
|
<picker-view-column>
|
|
13
|
-
<
|
|
13
|
+
<slot :columns="columns">
|
|
14
|
+
<view class="item" v-for="(item, index) in columns" :key="index">{{ item[labelKey ?? 'label'] }}</view>
|
|
15
|
+
</slot>
|
|
14
16
|
</picker-view-column>
|
|
15
17
|
</picker-view>
|
|
16
18
|
</view>
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<rich-text
|
|
3
|
+
:nodes="formatJson(log)"
|
|
4
|
+
:selectable="true"
|
|
5
|
+
style="font-size: 10px; word-break: break-all; white-space: pre-wrap"
|
|
6
|
+
></rich-text>
|
|
3
7
|
</template>
|
|
4
8
|
|
|
5
|
-
<script lang="ts" setup
|
|
6
|
-
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
import { formatJson } from './utils';
|
|
11
|
+
defineProps({
|
|
12
|
+
log: {
|
|
13
|
+
type: [Object, String, Boolean, Number, Array],
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
11
|
import { onBeforeUnmount, ref } from 'vue';
|
|
12
12
|
import { consoleSubject, getConsoleLogs } from 'uniapp-log-sdk';
|
|
13
|
-
const logConvert = (items) =>
|
|
13
|
+
const logConvert = (items: any[]) =>
|
|
14
14
|
items.reduce((prev, current, index) => {
|
|
15
15
|
try {
|
|
16
16
|
prev +=
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
2
|
+
<uni-collapse>
|
|
3
|
+
<uni-collapse-item v-for="log in nativeEventLogs" :title="getTitle(log)" :key="log.key">
|
|
4
4
|
<view style="font-size: 10px">
|
|
5
|
-
<view style="word-break: break-all">
|
|
6
|
-
<text style="font-weight: bolder">发送数据:</text>
|
|
7
|
-
|
|
5
|
+
<view style="word-break: break-all; padding: 0 15px">
|
|
6
|
+
<text :selectable="true" style="font-weight: bolder">发送数据:</text>
|
|
7
|
+
<awesome-display-info :log="log.params" />
|
|
8
8
|
</view>
|
|
9
|
-
<view style="word-break: break-all">
|
|
10
|
-
<text style="font-weight: bolder">接收数据:</text>
|
|
11
|
-
|
|
9
|
+
<view style="word-break: break-all; padding: 0 15px">
|
|
10
|
+
<text :selectable="true" style="font-weight: bolder">接收数据:</text>
|
|
11
|
+
<awesome-display-info :log="log.response" />
|
|
12
12
|
</view>
|
|
13
13
|
</view>
|
|
14
|
-
</
|
|
15
|
-
</
|
|
14
|
+
</uni-collapse-item>
|
|
15
|
+
</uni-collapse>
|
|
16
16
|
</template>
|
|
17
17
|
<script lang="ts" setup>
|
|
18
18
|
import { ref, onBeforeUnmount } from 'vue';
|
|
19
|
+
import awesomeDisplayInfo from './awesome-display-info.vue';
|
|
19
20
|
import { nativeEventSubject, getNativeEventLogs } from 'uniapp-log-sdk';
|
|
20
21
|
const nativeEventLogs = ref<Record<string, any>[]>(getNativeEventLogs());
|
|
21
22
|
const stop = nativeEventSubject.subscribe((data) => {
|
|
@@ -34,12 +35,18 @@
|
|
|
34
35
|
</script>
|
|
35
36
|
|
|
36
37
|
<style lang="scss" scoped>
|
|
37
|
-
.
|
|
38
|
+
.uni-collapse-content {
|
|
38
39
|
font-size: 12px;
|
|
39
40
|
}
|
|
40
41
|
::v-deep {
|
|
41
|
-
.
|
|
42
|
+
.uni-collapse-item__title-text {
|
|
43
|
+
white-space: normal !important; /* 允许文本换行 */
|
|
44
|
+
overflow: visible !important; /* 显示溢出的文本 */
|
|
45
|
+
text-overflow: clip !important; /* 不显示省略标记(...) */
|
|
46
|
+
line-height: normal !important; /* 重置行高 */
|
|
47
|
+
word-break: break-all !important; /* 允许单词内换行 */
|
|
42
48
|
font-size: 10px;
|
|
49
|
+
font-weight: normal;
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
</style>
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
2
|
+
<uni-collapse>
|
|
3
|
+
<uni-collapse-item
|
|
4
4
|
v-for="log in networkLogs"
|
|
5
5
|
:title="getTitle(log)"
|
|
6
6
|
:key="log.request.url + log.response?.data?.errno"
|
|
7
|
-
:class="{ '
|
|
7
|
+
:class="{ 'uni-collapse-item-failed': log.response?.statusCode !== 200 || log.response?.data?.errno !== 0 }"
|
|
8
8
|
>
|
|
9
9
|
<view style="font-size: 10px">
|
|
10
|
-
<view style="word-break: break-all">
|
|
11
|
-
<text style="font-weight: bolder">状态码:</text>
|
|
10
|
+
<view style="word-break: break-all; padding: 0 15px">
|
|
11
|
+
<text :selectable="true" style="font-weight: bolder">状态码:</text>
|
|
12
12
|
{{ log.request.method }} {{ log.response?.statusCode }}
|
|
13
13
|
</view>
|
|
14
|
-
<view style="word-break: break-all">
|
|
15
|
-
<text style="font-weight: bolder">请求头:</text>
|
|
16
|
-
|
|
14
|
+
<view style="word-break: break-all; padding: 0 15px">
|
|
15
|
+
<text :selectable="true" style="font-weight: bolder">请求头:</text>
|
|
16
|
+
<awesome-display-info :log="log.request.header" />
|
|
17
17
|
</view>
|
|
18
|
-
<view style="word-break: break-all">
|
|
19
|
-
<text style="font-weight: bolder">请求参数:</text>
|
|
20
|
-
|
|
18
|
+
<view style="word-break: break-all; padding: 0 15px">
|
|
19
|
+
<text :selectable="true" style="font-weight: bolder">请求参数:</text>
|
|
20
|
+
<awesome-display-info :log="log.request.data" />
|
|
21
21
|
</view>
|
|
22
|
-
<view style="word-break: break-all">
|
|
23
|
-
<text style="font-weight: bolder">响应数据:</text>
|
|
24
|
-
|
|
22
|
+
<view style="word-break: break-all; padding: 0 15px">
|
|
23
|
+
<text :selectable="true" style="font-weight: bolder">响应数据:</text>
|
|
24
|
+
<awesome-display-info :log="log.response" />
|
|
25
25
|
</view>
|
|
26
26
|
</view>
|
|
27
|
-
</
|
|
28
|
-
</
|
|
27
|
+
</uni-collapse-item>
|
|
28
|
+
</uni-collapse>
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
31
|
<script lang="ts" setup>
|
|
32
32
|
import { ref, onBeforeUnmount } from 'vue';
|
|
33
|
+
import awesomeDisplayInfo from './awesome-display-info.vue';
|
|
33
34
|
import { networkSubject, getNetworkLogs } from 'uniapp-log-sdk';
|
|
34
|
-
const networkLogs = ref<{ request: any; response: any; startTime; endTime }[]>(getNetworkLogs());
|
|
35
|
+
const networkLogs = ref<{ request: any; response: any; startTime: number; endTime: number }[]>(getNetworkLogs());
|
|
35
36
|
const stop = networkSubject.subscribe((data) => {
|
|
36
37
|
networkLogs.value = data;
|
|
37
38
|
});
|
|
@@ -48,15 +49,21 @@
|
|
|
48
49
|
</script>
|
|
49
50
|
|
|
50
51
|
<style lang="scss" scoped>
|
|
51
|
-
.
|
|
52
|
+
.uni-collapse-content {
|
|
52
53
|
font-size: 12px;
|
|
53
54
|
}
|
|
54
55
|
::v-deep {
|
|
55
|
-
.
|
|
56
|
+
.uni-collapse-item__title-text {
|
|
57
|
+
white-space: normal !important; /* 允许文本换行 */
|
|
58
|
+
overflow: visible !important; /* 显示溢出的文本 */
|
|
59
|
+
text-overflow: clip !important; /* 不显示省略标记(...) */
|
|
60
|
+
line-height: normal !important; /* 重置行高 */
|
|
61
|
+
word-break: break-all !important; /* 允许单词内换行 */
|
|
56
62
|
font-size: 10px;
|
|
63
|
+
font-weight: normal;
|
|
57
64
|
}
|
|
58
|
-
.
|
|
59
|
-
.
|
|
65
|
+
.uni-collapse-item-failed {
|
|
66
|
+
.uni-collapse-item__title-text {
|
|
60
67
|
color: red !important;
|
|
61
68
|
}
|
|
62
69
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<view style="height:
|
|
4
|
-
<
|
|
2
|
+
<uni-popup ref="popupRef" v-if="isShowDebugButton" background-color="#fff">
|
|
3
|
+
<view style="height: 500px; background-color: white; width: 100vw">
|
|
4
|
+
<uni-segmented-control
|
|
5
|
+
styleType="text"
|
|
6
|
+
:values="list"
|
|
7
|
+
:current="current"
|
|
8
|
+
@clickItem="(e:any) => (current = e.currentIndex)"
|
|
9
|
+
></uni-segmented-control>
|
|
5
10
|
<view style="height: calc(100% - 48px); overflow-y: auto; padding: 8px">
|
|
6
11
|
<template v-if="current === 0">
|
|
7
12
|
<Console />
|
|
@@ -23,7 +28,7 @@
|
|
|
23
28
|
</template>
|
|
24
29
|
</view>
|
|
25
30
|
</view>
|
|
26
|
-
</
|
|
31
|
+
</uni-popup>
|
|
27
32
|
<view
|
|
28
33
|
v-if="isShowDebugButton"
|
|
29
34
|
@click="openDebug"
|
|
@@ -54,25 +59,26 @@
|
|
|
54
59
|
'http://test-oa.ge.cn:6174',
|
|
55
60
|
];
|
|
56
61
|
const show = ref(false);
|
|
62
|
+
const popupRef = ref();
|
|
57
63
|
const baseUrl = uni.getStorageSync('baseUrl');
|
|
58
64
|
const isShowDebugButton = ref(whiteUrls.some((url) => url.includes(baseUrl)) || !!uni.getStorageSync('isDebug'));
|
|
59
65
|
const list = ref(['console', 'network', 'event', 'error', 'storage', 'system']);
|
|
60
66
|
const current = ref(0);
|
|
61
67
|
const openDebug = () => {
|
|
62
|
-
|
|
68
|
+
popupRef.value?.open('bottom');
|
|
63
69
|
};
|
|
64
70
|
uni.$once('show-debug-button', () => {
|
|
65
71
|
isShowDebugButton.value = true;
|
|
66
72
|
});
|
|
67
73
|
const bottom = ref(200);
|
|
68
74
|
const right = ref(10);
|
|
69
|
-
let pageX, pageY;
|
|
70
|
-
const start = (e) => {
|
|
75
|
+
let pageX: number, pageY: number;
|
|
76
|
+
const start = (e: any) => {
|
|
71
77
|
let page = e.changedTouches[0];
|
|
72
78
|
pageX = page.pageX;
|
|
73
79
|
pageY = page.pageY;
|
|
74
80
|
};
|
|
75
|
-
const move = (e) => {
|
|
81
|
+
const move = (e: any) => {
|
|
76
82
|
let page = e.changedTouches[0];
|
|
77
83
|
let x = page.pageX - pageX;
|
|
78
84
|
let y = page.pageY - pageY;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
</
|
|
7
|
-
</
|
|
8
|
-
</
|
|
2
|
+
<uni-collapse>
|
|
3
|
+
<uni-collapse-item v-for="log in storageLogs" :title="log.key" :key="log.key">
|
|
4
|
+
<view style="padding: 5px 15px">
|
|
5
|
+
<awesome-display-info :log="log.data" />
|
|
6
|
+
</view>
|
|
7
|
+
</uni-collapse-item>
|
|
8
|
+
</uni-collapse>
|
|
9
9
|
</template>
|
|
10
10
|
<script lang="ts" setup>
|
|
11
11
|
import { ref } from 'vue';
|
|
12
|
+
import awesomeDisplayInfo from './awesome-display-info.vue';
|
|
12
13
|
const storageLogs = ref<Record<string, any>[]>([]);
|
|
13
14
|
uni.getStorageInfo({
|
|
14
15
|
success: function (res) {
|
|
15
16
|
res.keys?.forEach((key) => {
|
|
16
17
|
storageLogs.value.push({
|
|
17
18
|
key,
|
|
18
|
-
data:
|
|
19
|
+
data: uni.getStorageSync(key),
|
|
19
20
|
});
|
|
20
21
|
});
|
|
21
22
|
},
|
|
@@ -23,12 +24,18 @@
|
|
|
23
24
|
</script>
|
|
24
25
|
|
|
25
26
|
<style lang="scss" scoped>
|
|
26
|
-
.
|
|
27
|
+
.uni-collapse-content {
|
|
27
28
|
font-size: 12px;
|
|
28
29
|
}
|
|
29
30
|
::v-deep {
|
|
30
|
-
.
|
|
31
|
+
.uni-collapse-item__title-text {
|
|
32
|
+
white-space: normal !important; /* 允许文本换行 */
|
|
33
|
+
overflow: visible !important; /* 显示溢出的文本 */
|
|
34
|
+
text-overflow: clip !important; /* 不显示省略标记(...) */
|
|
35
|
+
line-height: normal !important; /* 重置行高 */
|
|
36
|
+
word-break: break-all !important; /* 允许单词内换行 */
|
|
31
37
|
font-size: 10px;
|
|
38
|
+
font-weight: normal;
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
</style>
|
|
@@ -1,41 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
export const formatJson = (data: any, indent = 0) => {
|
|
2
|
+
const indentStr = ' '.repeat(indent);
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
export function formatJson(obj: JsonValue, indent: string = ''): string {
|
|
10
|
-
let output = '';
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(obj)) {
|
|
13
|
-
output += '[\n';
|
|
14
|
-
const lastIndex = obj.length - 1;
|
|
15
|
-
|
|
16
|
-
obj.forEach((value, index) => {
|
|
17
|
-
const isLast = index === lastIndex;
|
|
18
|
-
const formattedValue = formatJson(value, indent + ' ');
|
|
19
|
-
output += `${indent} ${formattedValue}${isLast ? '' : ','}\n`;
|
|
20
|
-
});
|
|
4
|
+
// 防止死循环,限制最大递归深度
|
|
5
|
+
if (indent > 100) {
|
|
6
|
+
return [{ type: 'text', text: 'Error: Maximum recursion depth exceeded.' }];
|
|
7
|
+
}
|
|
21
8
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
if (Array.isArray(data)) {
|
|
10
|
+
return formatArray(data, indent, indentStr);
|
|
11
|
+
} else if (typeof data === 'object' && data !== null) {
|
|
12
|
+
return formatObject(data, indent, indentStr);
|
|
13
|
+
} else {
|
|
14
|
+
return formatPrimitive(data);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
output += `${indent} "${key}": ${formattedValue}${isLast ? '' : ','}\n`;
|
|
33
|
-
});
|
|
18
|
+
const formatArray = (data: any[], indent: number, indentStr: string) => {
|
|
19
|
+
if (data.length === 0) {
|
|
20
|
+
return [{ type: 'text', text: '[]' }];
|
|
21
|
+
}
|
|
34
22
|
|
|
35
|
-
|
|
23
|
+
let formatted = [{ type: 'text', text: '[\n' }];
|
|
24
|
+
data.forEach((item, index) => {
|
|
25
|
+
formatted.push({ type: 'text', text: indentStr + ' '.repeat(2) });
|
|
26
|
+
formatted.push(...formatJson(item, indent + 2));
|
|
27
|
+
if (index < data.length - 1) {
|
|
28
|
+
formatted.push({ type: 'text', text: ',\n' });
|
|
29
|
+
} else {
|
|
30
|
+
formatted.push({ type: 'text', text: '\n' });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
formatted.push({ type: 'text', text: indentStr + ']' });
|
|
34
|
+
|
|
35
|
+
return formatted;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const formatObject = (data: Record<string, any>, indent: number, indentStr: string) => {
|
|
39
|
+
let formatted = [{ type: 'text', text: '{\n' }];
|
|
40
|
+
const keys = Object.keys(data);
|
|
41
|
+
keys.forEach((key, index) => {
|
|
42
|
+
formatted.push({ type: 'text', text: indentStr + ' '.repeat(2) + key + ': ' });
|
|
43
|
+
formatted.push(...formatJson(data[key], indent + 2));
|
|
44
|
+
if (index < keys.length - 1) {
|
|
45
|
+
formatted.push({ type: 'text', text: ',\n' });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
formatted.push({ type: 'text', text: '\n' + indentStr + '}' });
|
|
49
|
+
|
|
50
|
+
return formatted;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const formatPrimitive = (data: any) => {
|
|
54
|
+
if (typeof data === 'string') {
|
|
55
|
+
return [{ type: 'text', text: `"${data}"` }];
|
|
36
56
|
} else {
|
|
37
|
-
|
|
57
|
+
return [{ type: 'text', text: String(data) }];
|
|
38
58
|
}
|
|
39
|
-
|
|
40
|
-
return output;
|
|
41
|
-
}
|
|
59
|
+
};
|