66 <el-icon :size =" 18" ><Refresh /></el-icon >
77 </span >
88 </h1 >
9- <el-pagination
10- v-if =" total"
11- v-model:currentPage =" submitPage"
12- :total =" total"
13- background
14- @current-change =" getSubmitArr"
15- layout =" prev, pager, next, total, jumper"
16- v-loading =" loading"
17- ></el-pagination
18- ><br />
19- <el-table :data =" subs" border :default-sort =" { order: sortByCount }" >
20- <el-table-column
21- prop =" timeStamp"
22- label =" 时间"
23- sortable
24- align =" center"
25- >
26- <template #default =" scope " >
27- {{
28- new Date(parseInt(scope.row.timeStamp)).toLocaleString()
29- }}
30- </template >
31- </el-table-column >
32- <el-table-column
33- prop =" leetName"
34- label =" 提交名"
35- sortable
36- align =" center"
37- />
38- <el-table-column prop =" submitId" label =" 提交ID" align =" center" />
39- <el-table-column label =" 操作" align =" center" >
40- <template #default =" scope " >
41- <el-link
42- type =" primary"
43- @click ="
44- getSubmissionDetail(
45- scope.row.submitId,
46- scope.row.userid
47- )
48- "
49- >查看</el-link
50- >
51- </template >
52- </el-table-column >
53- </el-table >
9+ <!-- use div acheve a list to show subs data, do not use el-table -->
10+ <div v-if =" subs.length" class =" sub-list" >
11+ <div v-for =" item in subs" :key =" item.submitId" class =" sub-item" >
12+ <div class =" sub-item-content" >
13+ <span class =" no-wrap" >
14+ <span
15+ class =" id"
16+ @click ="
17+ getSubmissionDetail(item.submitId, item.userid)
18+ "
19+ >{{ item.submitId }}</span
20+ >
21+ <span class =" leetName" >{{
22+ item.leetName + "a long fix"
23+ }}</span >
24+ </span >
25+ <span class =" time" >{{
26+ getComputedTime(item.timeStamp)
27+ }}</span >
28+ </div >
29+ </div >
30+ </div >
31+ <div v-else class =" empty" >
32+ <el-empty description =" 暂无提交记录" ></el-empty >
33+ </div >
5434 <Detail
5535 class =" detail"
5636 ref =" detail"
@@ -73,6 +53,7 @@ export default {
7353 loading: true ,
7454 loadingClass: " " ,
7555 subs: [],
56+ submissionStatus: {},
7657 submissionDetail: {},
7758 submitPage: 1 ,
7859 pageLimit: 10 ,
@@ -98,24 +79,25 @@ export default {
9879 .getSubmissionStatus (` ${ id} ` )
9980 .then ((result ) => {
10081 const { submissionDetail } = result .data .data
82+ console .log (submissionDetail, result)
10183 if (! submissionDetail) {
10284 this .$public .emit (" notice" , {
10385 type: " error" ,
104- msg: ` ❌ 检测到未登入 LeetCode 无法获取题解详情 ` ,
86+ msg: ` 无法获取题解详情 ERRCODE: -3 ` ,
10587 })
10688 return 0
10789 }
10890 this .getSubmitor (uid)
10991 this .submissionDetail = submissionDetail
11092 this .$public .emit (" notice" , {
11193 type: " success" ,
112- msg: ` ✔ 提交返回数据` ,
94+ msg: ` 提交返回数据` ,
11395 })
11496 })
115- .catch ((e ) => {
97+ .catch (() => {
11698 this .$public .emit (" notice" , {
11799 type: " error" ,
118- msg: ` 获取提交返回数据失败 ${ e . message } ` ,
100+ msg: ` 获取提交返回数据失败 ERRCODE: -2 ` ,
119101 })
120102 })
121103 }, 300 ),
@@ -134,13 +116,18 @@ export default {
134116 this .total = result .data .all
135117 this .submitPage = val
136118 this .loading = false
119+ console .log (this .subs )
120+
137121 this .$public .emit (" notice" , {
138122 type: " success" ,
139- msg: " ✔ 获取提交列表" ,
123+ msg: " 获取提交列表" ,
140124 })
141125 })
142- .catch ((err ) => {
143- console .log (err .message )
126+ .catch (() => {
127+ this .$public .emit (" notice" , {
128+ type: " error" ,
129+ msg: ` 获取提交返回数据失败 ERRCODE: -2` ,
130+ })
144131 })
145132 })
146133 }, 400 ),
@@ -169,11 +156,27 @@ export default {
169156 },
170157 })
171158 }, 500 ),
172- getQuestionPage : function () {},
173159 initTables : function () {
174160 this .submitPage = 1
175161 this .getSubmitArr ()
176162 },
163+ getComputedTime : function (timestamp ) {
164+ function addzero (num ) {
165+ return num < 10 ? " 0" + num : num
166+ }
167+
168+ const date = new Date (parseInt (timestamp))
169+ const Y = date .getFullYear () + " -"
170+ const M =
171+ (date .getMonth () + 1 < 10
172+ ? " 0" + (date .getMonth () + 1 )
173+ : date .getMonth () + 1 ) + " -"
174+ const D = addzero (date .getDate ()) + " "
175+ const h = addzero (date .getHours ()) + " :"
176+ const m = addzero (date .getMinutes ()) + " :"
177+ const s = addzero (date .getSeconds ())
178+ return Y + M + D + h + m + s
179+ },
177180 },
178181}
179182 </script >
@@ -190,8 +193,43 @@ h1 {
190193h1 span {
191194 @apply flex items-center py-2;
192195}
193- .el-pagination {
194- @apply inline-block w-full pt-4;
196+
197+ .sub-list {
198+ @apply inline-flex justify-center flex-col w-full flex-grow my-4;
199+ }
200+
201+ .sub-list .sub-item {
202+ @apply flex items-center justify-between w-full my-1 px-4 py-2 text-base border-2 rounded-lg
203+ border-gray-200 dark :border-gray-700
204+ hover :border-gray-300 dark:hover:border-gray-500
205+ hover :shadow
206+ hover :bg-gray-50 dark:hover:bg-gray-600 transition-all;
207+ }
208+
209+ .sub-list .sub-item-content {
210+ @apply inline-flex justify-between w-full;
211+ }
212+
213+ .sub-item-content .no-wrap {
214+ @apply truncate;
215+ }
216+
217+ .sub-item-content .id {
218+ @apply inline-flex items-center justify-center pr-2 border-r-2
219+ border-gray-200 dark :border-gray-700
220+ transition-all cursor-pointer;
221+ }
222+ .sub-item:hover .id {
223+ @apply border-gray-300 dark :border-gray-500;
224+ }
225+
226+ .sub-item-content .leetName {
227+ @apply inline-flex items-center mx-2;
228+ }
229+
230+ .sub-item-content .time {
231+ @apply inline-flex items-center
232+ whitespace-nowrap;
195233}
196234
197235.op {
0 commit comments