360test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import * as drpy from '../libs/drpyS.js';
  2. import path from 'path';
  3. import {fileURLToPath} from 'url';
  4. const __dirname = path.dirname(fileURLToPath(import.meta.url));
  5. console.log('__dirname:', __dirname);
  6. (async () => {
  7. // 使用 __dirname 来确保正确的相对路径,避免路径出错
  8. const modulePath = path.join(__dirname, '../js/_360.js');
  9. try {
  10. console.log('Initializing module...');
  11. const module = await drpy.init(modulePath); // 初始化模块
  12. console.log('Calling home...');
  13. const result1 = await drpy.home(modulePath); // 调用 home 方法
  14. console.log('Calling homeVod...');
  15. const result2 = await drpy.homeVod(modulePath); // 调用 homeVod 方法
  16. console.log('Calling cate...');
  17. const result3 = await drpy.cate(modulePath); // 调用 cate 方法
  18. console.log('Calling detail...');
  19. const result4 = await drpy.detail(modulePath, {}, [1]); // 调用 detail 方法
  20. console.log('Calling search...');
  21. const result5 = await drpy.search(modulePath, {}, '我的'); // 调用 search 方法
  22. console.log('Calling play...');
  23. const result6 = await drpy.play(modulePath, {}, 'flag', '11'); // 调用 play 方法
  24. console.log('Result1:', result1);
  25. console.log('Result2:', result2);
  26. console.log('Result3:', result3);
  27. console.log('Result4:', result4);
  28. console.log('Result5:', result5);
  29. console.log('Result6:', result6);
  30. } catch (error) {
  31. console.log('Error during module initialization or invocation:', error);
  32. }
  33. })();