arguments.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.parseArguments = exports.initArguments = void 0;
  4. function initArguments(manifestJson, pagesJson) {
  5. const args = parseArguments(pagesJson);
  6. if (args) {
  7. manifestJson.plus.arguments = args;
  8. }
  9. }
  10. exports.initArguments = initArguments;
  11. function parseArguments(pagesJson) {
  12. if (process.env.NODE_ENV !== 'development') {
  13. return;
  14. }
  15. // 指定了入口
  16. if (process.env.UNI_CLI_LAUNCH_PAGE_PATH) {
  17. return JSON.stringify({
  18. path: process.env.UNI_CLI_LAUNCH_PAGE_PATH,
  19. query: process.env.UNI_CLI_LAUNCH_PAGE_QUERY,
  20. });
  21. }
  22. const condition = pagesJson.condition;
  23. if (condition && condition.list?.length) {
  24. const list = condition.list;
  25. let current = condition.current || 0;
  26. if (current < 0) {
  27. current = 0;
  28. }
  29. if (current >= list.length) {
  30. current = 0;
  31. }
  32. return JSON.stringify(list[current]);
  33. }
  34. }
  35. exports.parseArguments = parseArguments;