@@ -7,17 +7,17 @@ import { _t } from './plugins/gettext.js'
77const ACCESS_TOKEN_KEY = 'ACCESS_TOKEN'
88const REFRESH_TOKEN_KEY = 'REFRESH_TOKEN'
99
10- // const serverUrl = 'http://localhost:9092'
11- // const clientId = '0gvr1GFNpCy9fSpxsKHPdUPUu7ZSCQS76zc8kAgl'
12- // const clientSecret = 'dazoA4IhCGrWrkh2rA02FE1qm3AVWdAz9qKqSZDLAD22xWiVYsEeMtq2BmqVY748U8Qw9jecBo9BHYYG3nZDgOUUwaEFjjDir1VX25ejnCvEcwdzV3Wt2Rxcnt45lxaN'
10+ const serverUrl = 'http://localhost:9092/api/v1 '
11+ const clientId = '0gvr1GFNpCy9fSpxsKHPdUPUu7ZSCQS76zc8kAgl'
12+ const clientSecret = 'dazoA4IhCGrWrkh2rA02FE1qm3AVWdAz9qKqSZDLAD22xWiVYsEeMtq2BmqVY748U8Qw9jecBo9BHYYG3nZDgOUUwaEFjjDir1VX25ejnCvEcwdzV3Wt2Rxcnt45lxaN'
1313
1414// const serverUrl = 'https://codebang.dashingsoft.com'
1515// const clientId = 'rgt9yKrM82ACFiKLW2aIwxYUCIUV8ggx2OH5hvu8'
1616// const clientSecret = 'hiWi4Q8k4TR1aAF8PGtqjL7DiY15gBFXjYQ9UM5F3EV5mneJbo88LlXqst0PcfpYVhPQyKc1jjlICggI0otTjOv6zoP89Q0uBNoLsEqkRVmi2G4w5Snn9dBADHx7UxaT'
1717
18- const serverUrl = 'https://cb.dashingsoft.com/api/v1'
19- const clientId = 'PetTAmGzfinaiKDcr8wAfuq2IGqYv2TfWBHuou2F'
20- const clientSecret = 'SLc0LAGCyPQ291V2f3XSpK1xyBde01SHy9hZ5l2FQbrEbd17J9ZSlT8VXDWpsHMre4JqA7F8Olr6SDOQuR5Ul8D7U5PaFopiARASA8vIudRBsh2RAWqfO6Iu14Dtc5bq'
18+ // const serverUrl = 'https://cb.dashingsoft.com/api/v1'
19+ // const clientId = 'PetTAmGzfinaiKDcr8wAfuq2IGqYv2TfWBHuou2F'
20+ // const clientSecret = 'SLc0LAGCyPQ291V2f3XSpK1xyBde01SHy9hZ5l2FQbrEbd17J9ZSlT8VXDWpsHMre4JqA7F8Olr6SDOQuR5Ul8D7U5PaFopiARASA8vIudRBsh2RAWqfO6Iu14Dtc5bq'
2121
2222// Fix this issue:
2323// Do not access Object.prototype method ‘hasOwnProperty’ from target object no-prototype-builtins
@@ -336,25 +336,26 @@ export default new Vue({
336336 this . sendRequest ( api , make_multipart_data ( args , files ) , 'api-update-coursework-content' )
337337 } ,
338338 buildCoursework : function ( coursework ) {
339- let timeout = 15000
339+ let timeout = 5000
340340 const loading = this . $loading ( {
341341 lock : true ,
342342 text : _t ( '正在编译 ' ) + coursework . name + ' ...' ,
343343 spinner : 'el-icon-loading' ,
344344 background : 'rgba(0, 0, 0, 0.7)'
345345 } )
346346
347- const retry = function ( coursework ) {
348- this . $once ( 'api-build' , ( success , data ) => {
347+ const retry = function ( ) {
348+
349+ this . $once ( 'api-build-result' , ( success , data ) => {
349350
350351 let result = false
351352 if ( success ) {
352- if ( data . state === 'SUCCESS' ) {
353+ if ( data . state === 2 ) {
353354 loading . close ( )
354355 coursework . state = COMPILED
355356 result = true
356357 }
357- else if ( data . state === 'FAILURE' ) {
358+ else if ( data . state === - 1 ) {
358359 loading . close ( )
359360 coursework . state = FAILURE
360361 }
@@ -363,52 +364,38 @@ export default new Vue({
363364 coursework . state = TIMEOUT
364365 }
365366 else {
366- timeout -= 3000
367- window . setTimeout ( retry , 3000 , coursework )
367+ timeout -= 1000
368+ window . setTimeout ( retry , 1000 )
368369 result = null
369370 }
370371 }
371372 else
372373 loading . close ( )
373374
374375 if ( result !== null )
375- this . $emit ( 'api-build-coursework' , result )
376+ this . $emit ( 'api-build-coursework' , result , data )
376377 } )
377378
378- const api = '/courseworks/' + coursework . id + '/build /'
379- this . sendRequest ( api , { data : coursework } , 'api-build' )
379+ const api = '/courseworks/' + coursework . id + '/result /'
380+ this . sendRequest ( api , { data : coursework } , 'api-build-result ' )
380381
381382 } . bind ( this )
382383
383- this . $once ( 'api-rebuild ' , ( success , data ) => {
384+ this . $once ( 'api-build ' , ( success ) => {
384385
385- let result = false
386386 if ( success ) {
387- if ( data . state === 'SUCCESS' ) {
388- loading . close ( )
389- coursework . state = COMPILED
390- result = true
391- }
392- else if ( data . state === 'FAILURE' ) {
393- loading . close ( )
394- coursework . state = FAILURE
395- }
396- else {
397- retry ( coursework )
398- result = null
399- }
387+ window . setTimeout ( retry , 3000 )
400388 }
401- else
389+ else {
402390 loading . close ( )
391+ this . $emit ( 'api-build-coursework' , false )
392+ }
403393
404- if ( result !== null )
405- this . $emit ( 'api-build-coursework' , result )
406-
407- } ) . bind ( this )
394+ } )
408395
409396 coursework . state = BUILDING
410- const api = '/courseworks/' + coursework . id + '/rebuild /'
411- this . sendRequest ( api , { data : coursework } , 'api-rebuild ' )
397+ const api = '/courseworks/' + coursework . id + '/build /'
398+ this . sendRequest ( api , { data : coursework } , 'api-build ' )
412399 } ,
413400 taskCoursework : function ( coursework ) {
414401 const api = '/courseworks/' + coursework . id + '/result/'
0 commit comments