cuiqian2004
4 天以前 2af5f043b60c1f7ac38ecccc8f5bf44743134325
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
    <view class="pages-my-log">
        <view class="top">
            <view class="input">
                <input :placeholder="translate('input_interface_name')" v-model="keyMethod" />
                <uni-icons class="clear" color="#ccc" type="clear" size="20" v-if="keyMethod"
                    @click="clickClearKey"></uni-icons>
            </view>
 
            <a class="btn" @click="clickSearch">
                <uni-icons type="search" size="24" color="#1890FF"></uni-icons>
            </a>
            <a class="btn" @click="clickClearLog">
                <uni-icons type="trash" size="24" color="#1890FF"></uni-icons>
            </a>
 
        </view>
 
        <view class="list">
            <view class="group" v-for="(item,index) in list" :key="index">
                <view class="title" :class="item.statusCode!=200 ? 'error':''">{{ item.date+" "+item.url}}
                </view>
                <a @click="clickDetail(item)">
                    <uni-icons type="right" size="24"></uni-icons>
                </a>
            </view>
        </view>
 
    </view>
</template>
<script>
    import {
        Base64
    } from '@/comm/Base64.js';
    import {
        session,
        showToast,
        showModal
    } from "@/comm/utils.js"
    import {
        Button
    } from 'antd-mobile-vue-next'
    export default {
        name: "PagesMyLog",
        components: {
            'a-button': Button
        },
        data() {
            return {
                list: [],
                keyMethod: ""
            }
        },
        onLoad() {
            const list = session.getValue("request_log") || []
            this.list = list.map((item) => {
                item.url = decodeURI(item.url)
                return item
            })
 
        },
        methods: {
            clickDetail(item) {
                
                getApp().globalData.pageBigData = item
                uni.navigateTo({
                    url: `/pages/my/log-detail`
                })
            },
            clickClearLog() {
                session.setValue("request_log", [])
                session.setValue("request_log_max_data", {})
 
                this.list = []
            },
            clickSearch() {
                const list = session.getValue("request_log")
                const key = this.keyMethod.trim()
                if (key)
                    this.list = list.filter((a) => a.url.toLowerCase().includes(key.toLowerCase()))
 
                else
                    this.list = list
            },
            clickClearKey() {
                this.keyMethod = ""
            },
            translate(t) {
                if (typeof this.$t == "function") return this.$t(`page.${t}`)
                else return t;
            },
 
        }
    }
</script>
 
<style lang="scss">
    .pages-my-log {
        display: flex;
        width: 750rpx;
        height: 100vh;
        flex-direction: column;
        background-color: #F5F5F5;
 
        .list {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            width: 750rpx;
        }
 
        .group {
            width: calc(100% - 20rpx);
            padding: 10rpx 10rpx;
            display: flex;
            flex-direction: row;
            margin: 5rpx 10rpx;
            background-color: #fff;
            border-radius: 10rpx;
            font-size: 30rpx;
 
            .title {
                flex: 1;
                display: flex;
                flex-direction: row;
 
                margin: 5rpx;
                word-wrap: break-word;
                /* 允许长单词或 URL 地址换行到下一行 */
                word-break: break-all;
                /* 强制文本在超出容器宽度时换行 */
                white-space: normal;
                min-height: 30prx;
                /* 允许文本换行 */
            }
 
            .error {
                margin: 5rpx;
                color: red;
            }
 
        }
 
        .top {
            margin: 10rpx;
            width: 730rpx;
            display: flex;
            flex-direction: row;
            background-color: #F0F0F0;
 
            .input {
                flex: 1;
                padding: 10rpx;
                border-radius: 8rpx;
                display: flex;
                flex-direction: row;
                background-color: #fff;
 
                input {
                    flex: 1;
                }
            }
 
            .btn {
                padding: 5rpx;
                margin: 0 10rpx;
            }
 
        }
 
    }
</style>