You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
725 B

  1. export class PageNumber {
  2. num: number
  3. constructor(
  4. public page: number
  5. ) {
  6. if (typeof page === 'string' && /^\d+$/.test(page)) {
  7. this.num = parseInt(page, 10)
  8. }
  9. if (typeof page === 'number' && page > 0) {
  10. this.num = page
  11. }
  12. this.num = 1
  13. }
  14. }
  15. export class OptionItem {
  16. constructor(
  17. public page : number,
  18. public q? : string,
  19. public isChecked?: string
  20. ) {}
  21. static valueOf(
  22. { page, q = '', isChecked = '' }:
  23. { page: number, q?: string, isChecked?: string }
  24. ): OptionItem {
  25. return new OptionItem(page, q, isChecked)
  26. }
  27. toObject(): Object {
  28. return {
  29. page: this.page,
  30. q: this.q,
  31. isChecked: this.isChecked
  32. }
  33. }
  34. }