v-uni-app-ui 1.0.2 → 1.0.6
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/README.md +127 -0
- package/dist/v-uni-app-ui.css +1 -0
- package/dist/v-uni-app-ui.es.js +6569 -0
- package/dist/v-uni-app-ui.umd.js +7 -0
- package/package.json +28 -8
- package/components/config.js +0 -123
- package/components/layout/v-card/v-card.vue +0 -108
- package/components/layout/v-grid/v-grid.vue +0 -162
- package/components/layout/v-icon-grid/v-icon-grid.vue +0 -195
- package/components/layout/v-infinite-scroll/v-infinite-scroll.vue +0 -172
- package/components/layout/v-list/v-list.vue +0 -43
- package/components/layout/v-row/v-row.vue +0 -142
- package/components/layout/v-waterfall/v-waterfall.vue +0 -79
- package/components/model/compound/v-checkbox-group/v-checkbox-group.vue +0 -96
- package/components/model/compound/v-console/v-console.js +0 -20
- package/components/model/compound/v-console/v-console.vue +0 -299
- package/components/model/compound/v-date-time/v-date-time.vue +0 -261
- package/components/model/compound/v-dialog/v-dialog.vue +0 -178
- package/components/model/compound/v-drum-select-picker/v-drum-select-picker.vue +0 -83
- package/components/model/compound/v-form/v-form.vue +0 -226
- package/components/model/compound/v-form-item/v-form-item.vue +0 -255
- package/components/model/compound/v-image/v-image.vue +0 -357
- package/components/model/compound/v-input-desensitize/v-input-desensitize.vue +0 -101
- package/components/model/compound/v-page/v-page.vue +0 -11
- package/components/model/compound/v-pages/v-pages.vue +0 -141
- package/components/model/compound/v-picker-list/v-picker-list.vue +0 -109
- package/components/model/compound/v-popup/v-popup.vue +0 -151
- package/components/model/compound/v-radio-group/v-radio-group.vue +0 -86
- package/components/model/compound/v-select-picker/v-select-picker.vue +0 -202
- package/components/model/compound/v-series-picker-list/v-series-picker-list.vue +0 -221
- package/components/model/compound/v-series-select-picker/v-series-select-picker.vue +0 -203
- package/components/model/compound/v-switch/v-switch.vue +0 -136
- package/components/model/compound/v-tabs-page/v-tabs-page.vue +0 -138
- package/components/model/native/v-badge/v-badge.vue +0 -143
- package/components/model/native/v-button/v-button.vue +0 -273
- package/components/model/native/v-carousel/v-carousel.vue +0 -138
- package/components/model/native/v-checkbox/v-checkbox.vue +0 -215
- package/components/model/native/v-collapse/v-collapse.vue +0 -190
- package/components/model/native/v-header-navigation-bar/v-header-navigation-bar.vue +0 -92
- package/components/model/native/v-input/v-input.vue +0 -352
- package/components/model/native/v-input-code/v-input-code.vue +0 -146
- package/components/model/native/v-loading/v-loading.vue +0 -206
- package/components/model/native/v-menu/v-menu.vue +0 -222
- package/components/model/native/v-menu-slide/v-menu-slide.vue +0 -364
- package/components/model/native/v-min-loading/v-min-loading.vue +0 -80
- package/components/model/native/v-null/v-null.vue +0 -97
- package/components/model/native/v-overlay/v-overlay.vue +0 -96
- package/components/model/native/v-pull-up-refresh/v-pull-up-refresh.vue +0 -157
- package/components/model/native/v-radio/v-radio.vue +0 -138
- package/components/model/native/v-scroll-list/v-scroll-list.vue +0 -169
- package/components/model/native/v-steps/v-steps.vue +0 -253
- package/components/model/native/v-table/v-table.vue +0 -203
- package/components/model/native/v-tabs/v-tabs.vue +0 -235
- package/components/model/native/v-tag/v-tag.vue +0 -206
- package/components/model/native/v-text/v-text.vue +0 -187
- package/components/model/native/v-text-button/v-text-button.vue +0 -139
- package/components/model/native/v-textarea/v-textarea.vue +0 -178
- package/components/model/native/v-title/v-title.vue +0 -91
- package/components/model/native/v-toast/info.png +0 -0
- package/components/model/native/v-toast/success.png +0 -0
- package/components/model/native/v-toast/v-toast.vue +0 -198
- package/components/model/native/v-toast/warn.png +0 -0
- package/components/model/native/v-upload-file-button/v-upload-file-button.vue +0 -296
- package/components/model/native/v-video/v-video.vue +0 -175
- package/components/model/native/v-window/v-window.vue +0 -158
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="['v-row', `v-row--justify-${justify}`, `v-row--align-${align}`, `v-row--border-${borderMode}`]" :style="rowStyle">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed, inject } from 'vue';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* v-row 行
|
|
12
|
-
* gutter 子元素之间的间距 Number 0 -
|
|
13
|
-
* justify 水平排列方式 String 'start' 'start', 'end', 'center', 'space-between', 'space-around', 'space-evenly'
|
|
14
|
-
* align 垂直排列方式 String 'top' 'top', 'center', 'bottom', 'stretch', 'baseline'
|
|
15
|
-
* borderMode 边框模式 String 'all' 'all', 'none', 'bottom', 'top', 'left', 'right', 'ends', 'up-down'
|
|
16
|
-
*/
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
gutter: {
|
|
19
|
-
type: Number,
|
|
20
|
-
default: 0
|
|
21
|
-
},
|
|
22
|
-
justify: {
|
|
23
|
-
type: String,
|
|
24
|
-
default: 'start',
|
|
25
|
-
validator: (value: any) => {
|
|
26
|
-
return ['start', 'end', 'center', 'space-between', 'space-around', 'space-evenly'].includes(value);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
align: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'top',
|
|
32
|
-
validator: (value: string) => {
|
|
33
|
-
return ['top', 'center', 'bottom', 'stretch', 'baseline'].includes(value);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
borderMode: {
|
|
37
|
-
type: String,
|
|
38
|
-
default: 'none',
|
|
39
|
-
validator: (value: string) => {
|
|
40
|
-
return ['all', 'none', 'bottom', 'top', 'left', 'right', 'ends', 'up-down'].includes(value);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const config = inject<any>('config');
|
|
46
|
-
|
|
47
|
-
const rowStyle = computed(() => {
|
|
48
|
-
const style: Record<string, string | number> = {};
|
|
49
|
-
if (props.gutter) {
|
|
50
|
-
style.marginLeft = `-${props.gutter / 2}rpx`;
|
|
51
|
-
style.marginRight = `-${props.gutter / 2}rpx`;
|
|
52
|
-
}
|
|
53
|
-
return style;
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<style lang="scss" scoped>
|
|
58
|
-
.v-row {
|
|
59
|
-
display: flex;
|
|
60
|
-
flex-wrap: wrap;
|
|
61
|
-
box-sizing: border-box;
|
|
62
|
-
border: 1rpx solid v-bind('config.border.color');
|
|
63
|
-
border-radius: 4rpx;
|
|
64
|
-
|
|
65
|
-
// 边框模式
|
|
66
|
-
&--border-none {
|
|
67
|
-
border: none;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
&--border-bottom {
|
|
71
|
-
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&--border-top {
|
|
75
|
-
border-top: 1rpx solid v-bind('config.border.color');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
&--border-left {
|
|
79
|
-
border-left: 1rpx solid v-bind('config.border.color');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&--border-right {
|
|
83
|
-
border-right: 1rpx solid v-bind('config.border.color');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&--border-ends {
|
|
87
|
-
border-left: 1rpx solid v-bind('config.border.color');
|
|
88
|
-
border-right: 1rpx solid v-bind('config.border.color');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&--border-up-down {
|
|
92
|
-
border-top: 1rpx solid v-bind('config.border.color');
|
|
93
|
-
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 对齐方式
|
|
97
|
-
&--justify-start {
|
|
98
|
-
justify-content: flex-start;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
&--justify-end {
|
|
102
|
-
justify-content: flex-end;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&--justify-center {
|
|
106
|
-
justify-content: center;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&--justify-space-between {
|
|
110
|
-
justify-content: space-between;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
&--justify-space-around {
|
|
114
|
-
justify-content: space-around;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
&--justify-space-evenly {
|
|
118
|
-
justify-content: space-evenly;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 垂直对齐
|
|
122
|
-
&--align-top {
|
|
123
|
-
align-items: flex-start;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
&--align-center {
|
|
127
|
-
align-items: center;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
&--align-bottom {
|
|
131
|
-
align-items: flex-end;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&--align-stretch {
|
|
135
|
-
align-items: stretch;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
&--align-baseline {
|
|
139
|
-
align-items: baseline;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
</style>
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="v-waterfall">
|
|
3
|
-
<view v-for="(column, columnIndex) in columnsList" :key="columnIndex" class="column">
|
|
4
|
-
<view v-for="(item, itemIndex) in column" :key="itemIndex" class="waterfall-item">
|
|
5
|
-
<slot name="item" :item="item" />
|
|
6
|
-
</view>
|
|
7
|
-
</view>
|
|
8
|
-
</view>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script lang="ts" setup>
|
|
12
|
-
import { ref, watch } from 'vue';
|
|
13
|
-
|
|
14
|
-
interface WaterfallItem {
|
|
15
|
-
height: number;
|
|
16
|
-
content: any;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const props = defineProps({
|
|
20
|
-
items: {
|
|
21
|
-
type: Array as () => WaterfallItem[],
|
|
22
|
-
default: () => []
|
|
23
|
-
},
|
|
24
|
-
columns: {
|
|
25
|
-
type: Number,
|
|
26
|
-
default: 2
|
|
27
|
-
},
|
|
28
|
-
columnWidth: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: '50%'
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const columnsList = ref<WaterfallItem[][]>([]);
|
|
35
|
-
|
|
36
|
-
const splitIntoColumns = () => {
|
|
37
|
-
const cols = Array.from({ length: props.columns }, () => []);
|
|
38
|
-
props.items.forEach((item, index) => {
|
|
39
|
-
const columnIndex = index % props.columns;
|
|
40
|
-
cols[columnIndex].push(item);
|
|
41
|
-
});
|
|
42
|
-
columnsList.value = cols;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
splitIntoColumns();
|
|
46
|
-
|
|
47
|
-
watch(
|
|
48
|
-
() => props.items,
|
|
49
|
-
() => {
|
|
50
|
-
splitIntoColumns();
|
|
51
|
-
},
|
|
52
|
-
{ deep: true }
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
watch(
|
|
56
|
-
() => props.columns,
|
|
57
|
-
() => {
|
|
58
|
-
splitIntoColumns();
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
</script>
|
|
62
|
-
|
|
63
|
-
<style lang="scss" scoped>
|
|
64
|
-
.v-waterfall {
|
|
65
|
-
display: flex;
|
|
66
|
-
flex-wrap: wrap;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.column {
|
|
70
|
-
width: v-bind('100 / props.columns + "%"');
|
|
71
|
-
box-sizing: border-box;
|
|
72
|
-
padding: 0 5rpx;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.waterfall-item {
|
|
76
|
-
margin-bottom: 5rpx;
|
|
77
|
-
padding: 10rpx 0;
|
|
78
|
-
}
|
|
79
|
-
</style>
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="['v-checkbox-group', vertical ? 'vertical' : 'horizontal']" :style="groupStyle" role="checkboxgroup">
|
|
3
|
-
<slot />
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { provide, computed, ref, watch } from 'vue';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* v-checkbox-group 复选按钮组
|
|
12
|
-
* value 双向绑定
|
|
13
|
-
* vertical 布局方向 默认值:false 可选值:true竖 false:行
|
|
14
|
-
* disabled 是否禁用 默认值:false 可选值:false不禁用 true禁用
|
|
15
|
-
* indeterminate 是否开启全选/半选功能 默认值:false 可选值:false不开启 true开启
|
|
16
|
-
* groupStyle 自定义样式
|
|
17
|
-
* 相关事件:change
|
|
18
|
-
*/
|
|
19
|
-
const props = defineProps({
|
|
20
|
-
value: {
|
|
21
|
-
type: Array as () => Array<string | number | object>,
|
|
22
|
-
default: () => []
|
|
23
|
-
},
|
|
24
|
-
vertical: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: false
|
|
27
|
-
},
|
|
28
|
-
disabled: {
|
|
29
|
-
type: Boolean,
|
|
30
|
-
default: false
|
|
31
|
-
},
|
|
32
|
-
indeterminate: {
|
|
33
|
-
type: Boolean,
|
|
34
|
-
default: false
|
|
35
|
-
},
|
|
36
|
-
groupStyle: {
|
|
37
|
-
type: Object,
|
|
38
|
-
default: () => ({})
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const emit = defineEmits(['update:value', 'change']);
|
|
43
|
-
|
|
44
|
-
const checkedValues = ref([...props.value]);
|
|
45
|
-
|
|
46
|
-
provide('checkboxGroup', {
|
|
47
|
-
name: 'vCheckboxGroup',
|
|
48
|
-
checkedValues,
|
|
49
|
-
disabled: computed(() => props.disabled),
|
|
50
|
-
indeterminate: computed(() => props.indeterminate)
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
watch(
|
|
54
|
-
() => props.value,
|
|
55
|
-
(newVal) => {
|
|
56
|
-
checkedValues.value = [...newVal];
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const updateValues = (newValues: any[]) => {
|
|
61
|
-
checkedValues.value = newValues;
|
|
62
|
-
emit('update:value', newValues);
|
|
63
|
-
emit('change', newValues);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
defineExpose({
|
|
67
|
-
updateValues
|
|
68
|
-
});
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<style lang="scss">
|
|
72
|
-
.v-checkbox-group {
|
|
73
|
-
&.horizontal {
|
|
74
|
-
display: flex;
|
|
75
|
-
flex-wrap: wrap;
|
|
76
|
-
|
|
77
|
-
.v-checkbox {
|
|
78
|
-
margin-right: 32rpx;
|
|
79
|
-
|
|
80
|
-
&:last-child {
|
|
81
|
-
margin-right: 0;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&.vertical {
|
|
87
|
-
.v-checkbox {
|
|
88
|
-
margin-bottom: 24rpx;
|
|
89
|
-
|
|
90
|
-
&:last-child {
|
|
91
|
-
margin-bottom: 0;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
</style>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function initVConsole() {
|
|
2
|
-
const STORAGE_KEY = 'v-console-logs';
|
|
3
|
-
const logs = [];
|
|
4
|
-
|
|
5
|
-
['log', 'info', 'warn', 'error', 'debug'].forEach((type) => {
|
|
6
|
-
const original = console[type];
|
|
7
|
-
console[type] = (...args) => {
|
|
8
|
-
original.apply(console, args);
|
|
9
|
-
const time = new Date().toLocaleTimeString();
|
|
10
|
-
const msg = args.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v))).join(' ');
|
|
11
|
-
logs.unshift({
|
|
12
|
-
type,
|
|
13
|
-
msg,
|
|
14
|
-
time,
|
|
15
|
-
blockLines: 2
|
|
16
|
-
});
|
|
17
|
-
uni.setStorageSync(STORAGE_KEY, logs);
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
}
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
v-if="!visible"
|
|
4
|
-
class="console-toggle"
|
|
5
|
-
:style="{ left: btnPos.x + 'rpx', top: btnPos.y + 'rpx' }"
|
|
6
|
-
@touchstart="onTouchStart"
|
|
7
|
-
@touchmove="onTouchMove"
|
|
8
|
-
@touchend="onTouchEnd"
|
|
9
|
-
@mousedown="onTouchStart"
|
|
10
|
-
@mousemove="onTouchMove"
|
|
11
|
-
@mouseup="onTouchEnd"
|
|
12
|
-
@click="toggle"
|
|
13
|
-
>
|
|
14
|
-
<v-button>控制台</v-button>
|
|
15
|
-
</view>
|
|
16
|
-
<view v-if="visible" class="v-console" :class="{ expanded: expanded }">
|
|
17
|
-
<view class="toolbar">
|
|
18
|
-
<view class="buttons">
|
|
19
|
-
<v-text-button size="medium" @click="toggle">关闭</v-text-button>
|
|
20
|
-
<v-text-button size="medium" @click="toggleExpand">
|
|
21
|
-
{{ expanded ? '收起' : '展开' }}
|
|
22
|
-
</v-text-button>
|
|
23
|
-
<v-text-button size="medium" @click="clear">清空</v-text-button>
|
|
24
|
-
</view>
|
|
25
|
-
<view class="filter">
|
|
26
|
-
<v-input v-model="keyword" placeholder="关键字筛选" class="keyword" @confirm="onKeywordConfirm" />
|
|
27
|
-
<v-select-picker :options="levels" :value="levelIndex" @confirm="onLevelConfirm" class="level" />
|
|
28
|
-
</view>
|
|
29
|
-
</view>
|
|
30
|
-
<scroll-view scroll-y class="list">
|
|
31
|
-
<view v-for="(log, i) in showList" :key="i" :class="'log ' + log.type">
|
|
32
|
-
<text v-if="log.time" class="time">{{ log.time }} {{ log.type }}</text>
|
|
33
|
-
<!-- <v-text :class="['msg', log.type]" :lines="log.blockLines" @longpress="copyLog(log.msg)">{{ log.msg }}</v-text> -->
|
|
34
|
-
<view class="msg" :class="log.type" @longpress="copyLog(log.msg)">
|
|
35
|
-
<v-text :lines="log.blockLines">{{ log.msg }}</v-text>
|
|
36
|
-
</view>
|
|
37
|
-
<v-text-button class="detail-info" @click="log.blockLines == 2 ? (log.blockLines = 999) : (log.blockLines = 2)">
|
|
38
|
-
{{ log.blockLines == 2 ? '详细' : '简略' }}
|
|
39
|
-
</v-text-button>
|
|
40
|
-
</view>
|
|
41
|
-
</scroll-view>
|
|
42
|
-
</view>
|
|
43
|
-
</template>
|
|
44
|
-
|
|
45
|
-
<script setup>
|
|
46
|
-
import { ref, computed, onMounted } from 'vue';
|
|
47
|
-
|
|
48
|
-
const STORAGE_KEY = 'v-console-logs';
|
|
49
|
-
const visible = ref(false);
|
|
50
|
-
const toggle = () => (visible.value = !visible.value);
|
|
51
|
-
|
|
52
|
-
const expanded = ref(false);
|
|
53
|
-
const toggleExpand = () => (expanded.value = !expanded.value);
|
|
54
|
-
|
|
55
|
-
const logs = ref([]);
|
|
56
|
-
const keyword = ref('');
|
|
57
|
-
const levelIndex = ref(0);
|
|
58
|
-
const levels = [
|
|
59
|
-
{ label: '全部', value: 0 },
|
|
60
|
-
{ label: 'log', value: 1 },
|
|
61
|
-
{ label: 'info', value: 2 },
|
|
62
|
-
{ label: 'warn', value: 3 },
|
|
63
|
-
{ label: 'error', value: 4 },
|
|
64
|
-
{ label: 'debug', value: 5 }
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
const btnPos = ref({ x: 30, y: 100 });
|
|
68
|
-
const dragging = ref(false);
|
|
69
|
-
const startPos = ref({ x: 0, y: 0 });
|
|
70
|
-
|
|
71
|
-
const rpx2px = (rpx) => (rpx * uni.getSystemInfoSync().windowWidth) / 750;
|
|
72
|
-
|
|
73
|
-
onMounted(() => {
|
|
74
|
-
loadLogs();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const getPos = (e) => {
|
|
78
|
-
// #ifdef H5
|
|
79
|
-
return { x: e.clientX, y: e.clientY };
|
|
80
|
-
// #endif
|
|
81
|
-
// #ifndef H5
|
|
82
|
-
const touch = e.touches[0] || e.changedTouches[0];
|
|
83
|
-
return { x: touch.clientX, y: touch.clientY };
|
|
84
|
-
// #endif
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/* 按下 */
|
|
88
|
-
const onTouchStart = (e) => {
|
|
89
|
-
dragging.value = true;
|
|
90
|
-
startPos.value = getPos(e);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/* 移动 */
|
|
94
|
-
const onTouchMove = (e) => {
|
|
95
|
-
if (!dragging.value) return;
|
|
96
|
-
const { windowWidth, windowHeight } = uni.getSystemInfoSync();
|
|
97
|
-
const cur = getPos(e);
|
|
98
|
-
const dx = cur.x - startPos.value.x;
|
|
99
|
-
const dy = cur.y - startPos.value.y;
|
|
100
|
-
|
|
101
|
-
/* 转成 rpx */
|
|
102
|
-
const newX = btnPos.value.x + (dx * 750) / windowWidth;
|
|
103
|
-
const newY = btnPos.value.y + (dy * 750) / windowHeight;
|
|
104
|
-
|
|
105
|
-
/* 边界限制:0~屏幕宽/高 - 按钮宽/高(≈120rpx) */
|
|
106
|
-
btnPos.value.x = Math.max(0, Math.min(newX, (windowWidth * 750) / windowWidth - 120));
|
|
107
|
-
btnPos.value.y = Math.max(0, Math.min(newY, (windowHeight * 750) / windowWidth - 120));
|
|
108
|
-
|
|
109
|
-
startPos.value = cur;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const onTouchEnd = () => (dragging.value = false);
|
|
113
|
-
|
|
114
|
-
if (typeof window !== 'undefined') {
|
|
115
|
-
window.onerror = (msg, url, line, col, error) => {
|
|
116
|
-
console.error('[Global Error]', msg, `${url}:${line}:${col}`, error?.stack);
|
|
117
|
-
};
|
|
118
|
-
window.onunhandledrejection = (e) => {
|
|
119
|
-
console.error('[Unhandled Promise]', e.reason);
|
|
120
|
-
};
|
|
121
|
-
} else {
|
|
122
|
-
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-QQ
|
|
123
|
-
wx.onError?.((res) => console.error('[wx Error]', res));
|
|
124
|
-
wx.onUnhandledRejection?.((res) => console.error('[wx Promise]', res.reason));
|
|
125
|
-
// #endif
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
['log', 'info', 'warn', 'error', 'debug'].forEach((type) => {
|
|
130
|
-
const origin = console[type];
|
|
131
|
-
console[type] = (...args) => {
|
|
132
|
-
origin.apply(console, args);
|
|
133
|
-
const time = new Date().toLocaleTimeString();
|
|
134
|
-
const msg = args.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v))).join(' ');
|
|
135
|
-
const newLog = { type, msg, time, blockLines: 2 };
|
|
136
|
-
logs.value.unshift(newLog);
|
|
137
|
-
saveLogs();
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
const showList = computed(() => {
|
|
142
|
-
let list = logs.value;
|
|
143
|
-
if (levelIndex.value) {
|
|
144
|
-
list = list.filter((l) => l.type === levels[levelIndex.value].label.toLowerCase());
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (keyword.value.trim()) {
|
|
148
|
-
const k = keyword.value.trim().toLowerCase();
|
|
149
|
-
list = list.filter((l) => l.msg.toLowerCase().includes(k));
|
|
150
|
-
}
|
|
151
|
-
list.blockLines = 2;
|
|
152
|
-
return list;
|
|
153
|
-
});
|
|
154
|
-
const saveLogs = () => {
|
|
155
|
-
try {
|
|
156
|
-
// #ifdef H5
|
|
157
|
-
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(logs.value));
|
|
158
|
-
// #endif
|
|
159
|
-
// #ifndef H5
|
|
160
|
-
uni.setStorageSync(STORAGE_KEY, logs.value);
|
|
161
|
-
// #endif
|
|
162
|
-
} catch (_) {}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const loadLogs = () => {
|
|
166
|
-
try {
|
|
167
|
-
let data = null;
|
|
168
|
-
// #ifdef H5
|
|
169
|
-
data = JSON.parse(sessionStorage.getItem(STORAGE_KEY) || '[]');
|
|
170
|
-
// #endif
|
|
171
|
-
// #ifndef H5
|
|
172
|
-
data = uni.getStorageSync(STORAGE_KEY) || [];
|
|
173
|
-
// #endif
|
|
174
|
-
logs.value = data;
|
|
175
|
-
} catch (_) {}
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const clear = () => {
|
|
179
|
-
logs.value = [];
|
|
180
|
-
try {
|
|
181
|
-
// #ifdef H5
|
|
182
|
-
sessionStorage.removeItem(STORAGE_KEY);
|
|
183
|
-
// #endif
|
|
184
|
-
// #ifndef H5
|
|
185
|
-
uni.removeStorageSync(STORAGE_KEY);
|
|
186
|
-
// #endif
|
|
187
|
-
} catch (_) {}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const copyLog = (msg) => {
|
|
191
|
-
// #ifdef H5
|
|
192
|
-
const input = document.createElement('textarea');
|
|
193
|
-
input.value = msg;
|
|
194
|
-
document.body.appendChild(input);
|
|
195
|
-
input.select();
|
|
196
|
-
document.execCommand('copy');
|
|
197
|
-
document.body.removeChild(input);
|
|
198
|
-
uni.showToast({ title: '已复制', icon: 'none' });
|
|
199
|
-
// #endif
|
|
200
|
-
// #ifndef H5
|
|
201
|
-
uni.setClipboardData({ data: msg, showToast: false });
|
|
202
|
-
uni.showToast({ title: '已复制', icon: 'none' });
|
|
203
|
-
// #endif
|
|
204
|
-
};
|
|
205
|
-
const onKeywordConfirm = (e) => {
|
|
206
|
-
console.log(e);
|
|
207
|
-
keyword.value = e;
|
|
208
|
-
};
|
|
209
|
-
const onLevelConfirm = (e) => {
|
|
210
|
-
levelIndex.value = e;
|
|
211
|
-
};
|
|
212
|
-
</script>
|
|
213
|
-
|
|
214
|
-
<style lang="scss" scoped>
|
|
215
|
-
/* 悬浮开关按钮(黑底白字) */
|
|
216
|
-
.console-toggle {
|
|
217
|
-
position: fixed;
|
|
218
|
-
right: 30rpx;
|
|
219
|
-
bottom: 100rpx;
|
|
220
|
-
z-index: 10000;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/* 控制台主体:白底黑字 */
|
|
224
|
-
.v-console {
|
|
225
|
-
position: fixed;
|
|
226
|
-
left: 0;
|
|
227
|
-
right: 0;
|
|
228
|
-
bottom: 0;
|
|
229
|
-
z-index: 9999;
|
|
230
|
-
background: #fff;
|
|
231
|
-
color: #000;
|
|
232
|
-
font-family: monospace;
|
|
233
|
-
font-size: 0.75rem;
|
|
234
|
-
height: 120rpx; /* 默认收缩高度 */
|
|
235
|
-
transition: height 0.25s ease;
|
|
236
|
-
border-top: 1rpx solid #e5e5e5;
|
|
237
|
-
|
|
238
|
-
&.expanded {
|
|
239
|
-
height: 50%; /* 展开后高度 */
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.toolbar {
|
|
243
|
-
display: flex;
|
|
244
|
-
padding: 12rpx 24rpx;
|
|
245
|
-
background: #f7f7f7;
|
|
246
|
-
border-bottom: 1rpx solid #e5e5e5;
|
|
247
|
-
flex-direction: column;
|
|
248
|
-
.buttons {
|
|
249
|
-
display: flex;
|
|
250
|
-
}
|
|
251
|
-
.filter {
|
|
252
|
-
display: flex;
|
|
253
|
-
.keyword {
|
|
254
|
-
flex: 1;
|
|
255
|
-
margin-right: 20rpx;
|
|
256
|
-
}
|
|
257
|
-
.level {
|
|
258
|
-
width: 200rpx;
|
|
259
|
-
:deep(.select-input) {
|
|
260
|
-
height: 60rpx;
|
|
261
|
-
line-height: 60rpx;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.list {
|
|
268
|
-
height: calc(100% - 100rpx);
|
|
269
|
-
padding: 16rpx;
|
|
270
|
-
.log {
|
|
271
|
-
display: flex;
|
|
272
|
-
line-height: 1.4;
|
|
273
|
-
margin-bottom: 8rpx;
|
|
274
|
-
.time {
|
|
275
|
-
margin-right: 12rpx;
|
|
276
|
-
color: #666;
|
|
277
|
-
}
|
|
278
|
-
.msg {
|
|
279
|
-
width: 50%;
|
|
280
|
-
&.log {
|
|
281
|
-
color: #008000;
|
|
282
|
-
}
|
|
283
|
-
&.info {
|
|
284
|
-
color: #0066cc;
|
|
285
|
-
}
|
|
286
|
-
&.warn {
|
|
287
|
-
color: #ff6600;
|
|
288
|
-
}
|
|
289
|
-
&.error {
|
|
290
|
-
color: #cc0000;
|
|
291
|
-
}
|
|
292
|
-
&.debug {
|
|
293
|
-
color: #666;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
</style>
|