forked from magicoflolis/Userscript-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.vue
More file actions
198 lines (192 loc) · 6.14 KB
/
Copy pathTable.vue
File metadata and controls
198 lines (192 loc) · 6.14 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<template>
<div>
<transition name="custom-classes-transition" enter-active-class="animated lightSpeedIn">
<div>
<Card :padding="0">
<div slot="title" class="card-title">
<span v-if="!showSearchInput">
<i18n path="table.tips" tag="span">
<Badge place="count" :count="count" style="padding:0px 5px;"></Badge>
</i18n>
- Userscript+
</span>
<Input v-else v-model="searchInput" icon="android-search" placeholder="Enter title、description、author..." style="width: auto"/>
</div>
<div slot="extra">
<span>
<Tooltip :content="$t('table.search')" placement="bottom">
<Button type="dashed" @click="showSearchInput = !showSearchInput">
<Icon type="android-search"></Icon>
</Button>
</Tooltip>
<Tooltip content="New issue" placement="bottom">
<Button type="dashed" @click="open('https://github.com/magicoflolis/Userscript-Plus/issues')">
<Icon type="bug"></Icon>
</Button>
</Tooltip>
<Tooltip content="GitHub" placement="bottom">
<Button type="dashed" @click="open('https://github.com/magicoflolis/Userscript-Plus#userscript-for-firefox')">
<Icon type="social-github"></Icon>
</Button>
</Tooltip>
</span>
</div>
<transition name="custom-classes-transition" enter-active-class="animated lightSpeedIn" leave-active-class="animated bounceOutRight">
<div>
<Table highlight-row :columns="columns" :data="data"></Table>
<div class="table-footer">
</div>
</div>
</transition>
</Card>
</div>
</transition>
</div>
</template>
<script>
import Tools from '../common/js/tools'
import Info from './Info.vue'
// import Support from './Support.vue'
export default {
// components: { Info, Support },
components: { Info },
mounted: function () {
this.count = Tools.getCount()
this.adult = Tools.getAdult()
},
data: function () {
return {
isZH: Tools.isZH(),
showSearchInput: false,
searchInput: '',
showTitle: false,
showBody: false,
titleIcon: 'chevron-up',
count: 0,
showDonate: false,
columns: [{
type: 'expand',
width: 50,
render: (h, params) => {
return h(Info, {
props: {
row: params.row
}
})
}
},
{
type: 'index',
width: 50,
align: 'center'
},
{
title: this.$t('table.title'),
key: 'name',
width: '35%',
ellipsis: false,
render: (h, params) => {
return h('span', {
attrs: {
title: params.row.description
},
style: {
cursor: 'pointer'
},
on: {
click: _ => {
window.open(params.row.url)
}
}
}, params.row.name)
}
},
{
title: this.$t('table.author'),
render: (h, params) => {
return h('span', {
attrs: {
title: this.$t('table.authorTips', {name: params.row.user.name})
},
style: {
cursor: 'pointer'
},
on: {
click: _ => {
window.open(params.row.user.url)
}
}
}, params.row.user.name)
}
},
{
title: this.$t('table.dailyInstalls'),
width: 105,
key: 'daily_installs',
sortable: true
},
{
title: this.$t('table.updatedTime'),
key: 'code_updated_at',
render: (h, params) => {
return h('span', Tools.timeagoFormat(params.row.code_updated_at))
},
sortable: true
},
{
title: this.$t('table.action'),
width: 100,
key: 'code_url',
align: 'center',
render: (h, params) => {
return h('div', [
h('Button', {
props: {
type: 'primary',
size: 'small',
icon: 'ios-download-outline'
},
style: {
marginRight: '5px'
},
on: {
click: (event) => {
this.$Message.info(this.$t('table.scriptInstalling'))
Tools.installUserJs(params.row.code_url)
}
}
}, this.$t('table.install'))
])
}
}
],
originData: [],
data: []
}
},
watch: {
searchInput: (val) => {
if (val) {
val = val.toLowerCase()
this.data = Tools.searcher(this.originData, val)
} else {
this.data = this.originData
}
}
},
methods: {
getData (callback) {
let host = 'github.com'
window.fetch(`https://greasyfork.org/scripts/by-site/${host}.json`)
.then((r) => {
r.json().then((json) => {
callback(json)
})
})
},
open (url) {
window.open(url)
}
}
}
</script>