feat_surenjun #60
@ -1,25 +0,0 @@
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
export default struct EndPopup {
 | 
			
		||||
  constructor() {
 | 
			
		||||
    super()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private title:string = ''
 | 
			
		||||
  private cancelFn:(event?: ClickEvent) => void
 | 
			
		||||
  private confirmFn:(event?: ClickEvent) => void
 | 
			
		||||
 | 
			
		||||
  build(){
 | 
			
		||||
    Column(){
 | 
			
		||||
      Column(){
 | 
			
		||||
        Text(this.title).fontSize(38).margin({bottom:20})
 | 
			
		||||
        Row(){}.height(50)
 | 
			
		||||
        Row(){
 | 
			
		||||
          Text('取消').backgroundImage($rawfile('judge/end-btn.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(250).height(100).fontSize(30).fontColor('#FFF').textAlign(TextAlign.Center).onClick(this.cancelFn)
 | 
			
		||||
          Text('确定').backgroundImage($rawfile('judge/end-btn.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(250).height(100).fontSize(30).fontColor('#FFF').textAlign(TextAlign.Center).margin({left:45}).onClick(this.confirmFn)
 | 
			
		||||
        }
 | 
			
		||||
      }.width('80%').height('70%').backgroundColor('#E6E3DF').borderRadius(38).position({y:'12%',x:'10%'}).justifyContent(FlexAlign.Center)
 | 
			
		||||
 | 
			
		||||
    }.width('100%').height('100%').position({y:0}).backgroundColor('rgba(0,0,0,0.7)')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -1,58 +0,0 @@
 | 
			
		||||
import Prompt from '@system.prompt'
 | 
			
		||||
 | 
			
		||||
const TAG = 'SURENJUN_JUDGE'
 | 
			
		||||
interface QUEUE{
 | 
			
		||||
  fn:Function,
 | 
			
		||||
  config?:{
 | 
			
		||||
    isDelay:boolean
 | 
			
		||||
    delayTime:number
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default class JudgeTask{
 | 
			
		||||
  private queue = []
 | 
			
		||||
  private status:string
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this.queue = []
 | 
			
		||||
    this.status = 'end'
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  executeQueue = async ()=>{
 | 
			
		||||
    const {queue,executeQueue} = this
 | 
			
		||||
    if(queue.length){
 | 
			
		||||
      for (const currentTask of queue) {
 | 
			
		||||
        const {fn,delayConfig:{
 | 
			
		||||
          isDelay = false,
 | 
			
		||||
          delayTime = 1000
 | 
			
		||||
        }} = currentTask;
 | 
			
		||||
        const {status} = this
 | 
			
		||||
        try {
 | 
			
		||||
          isDelay
 | 
			
		||||
            ?setTimeout(async ()=>{await fn()})
 | 
			
		||||
            :await fn();
 | 
			
		||||
        }catch (e){
 | 
			
		||||
          // console.info(TAG,'过程数据接口解析错误')
 | 
			
		||||
          Prompt.showToast({
 | 
			
		||||
            message: '过程数据接口解析错误',
 | 
			
		||||
            duration: 3000
 | 
			
		||||
          });
 | 
			
		||||
        }
 | 
			
		||||
        this.queue.shift()
 | 
			
		||||
        await executeQueue()
 | 
			
		||||
      }
 | 
			
		||||
    }else{
 | 
			
		||||
      this.status = 'end'
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  addTask = async (fn,delayConfig?:{
 | 
			
		||||
    isDelay:Boolean,
 | 
			
		||||
    delayTime:Number
 | 
			
		||||
  }) =>{
 | 
			
		||||
    this.queue.push({fn,delayConfig});
 | 
			
		||||
    if(this.status == 'end' && this.queue.length === 1){
 | 
			
		||||
      await this.executeQueue();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user