用工小程序前端代码
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.

34 lines
1.1 KiB

3 months ago
  1. interface IRestoreInfo {
  2. /**
  3. * Whether the restoration is ongoing
  4. * If a RestoreObject request is sent but the restoration is not complete, the value is true.
  5. * If a RestoreObject request is sent and the restoration is complete, the value is false.
  6. */
  7. ongoingRequest: boolean;
  8. /**
  9. * The time before which the restored object can be read.
  10. * If a RestoreObject request is sent but the restoration is not complete, the value is undefined.
  11. * If a RestoreObject request is sent and the restoration is complete, the value is Date.
  12. */
  13. expiryDate?: Date;
  14. }
  15. export const parseRestoreInfo = (originalRestoreInfo?: string): IRestoreInfo | undefined => {
  16. let tempRestoreInfo: IRestoreInfo | undefined;
  17. if (originalRestoreInfo) {
  18. tempRestoreInfo = {
  19. ongoingRequest: originalRestoreInfo.includes('true')
  20. };
  21. if (!tempRestoreInfo.ongoingRequest) {
  22. const matchArray = originalRestoreInfo.match(/expiry-date="(.*)"/);
  23. if (matchArray && matchArray[1]) {
  24. tempRestoreInfo.expiryDate = new Date(matchArray[1]);
  25. }
  26. }
  27. }
  28. return tempRestoreInfo;
  29. };