save_to.js 926 B

1234567891011121314151617181920212223242526272829303132
  1. const directory = require("./API/directory");
  2. const share_save = require("./API/share_save")
  3. module.exports = {
  4. type: 'list',
  5. title: '保存到',
  6. async beforeCreate() {
  7. getCookie();
  8. },
  9. async fetch({args}) {
  10. var list = await directory(args.path, cookie);
  11. var data = [];
  12. if (args.path)
  13. data.push({
  14. title: `* ${args.path}`,
  15. })
  16. list.forEach(m => {
  17. if (m.type == "dir") {
  18. m.path.substring(m.path.length-1) == "/" ? m.path = m.path.substring(0, m.path.length-1) : null;
  19. data.push({
  20. title: `${f.path}${f.name}`,
  21. route: $route("save_to", {
  22. path: m.path + '/' + m.name,
  23. key: args.key
  24. })
  25. })
  26. }
  27. })
  28. await share_save(args.key, args.path, cookie);
  29. }
  30. }