_test.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // js/_test.js
  2. console.log('加载test...')
  3. globalThis.check = ()=>{
  4. console.log('check...')
  5. }
  6. check1 = ()=>{
  7. console.log('check1...')
  8. }
  9. sleepSync(2000);
  10. console.log('睡眠了200ms')
  11. async function test1(){
  12. await sleep(200);
  13. console.log('test1睡眠完毕11')
  14. }
  15. console.log('test1定义完毕')
  16. var rule = {
  17. title: '标题1',
  18. description: '这是描述',
  19. category: '视频',
  20. class_parse: async () => {
  21. console.log('执行了分类获取')
  22. return [
  23. {type_id: '1', type_name: '电影'},
  24. {type_id: '2', type_name: '电视剧'},
  25. {type_id: '3', type_name: '综艺'},
  26. {type_id: '4', type_name: '动漫'},
  27. ]
  28. },
  29. 预处理: async () => {
  30. console.log('执行了预处理')
  31. check()
  32. check1()
  33. await test1()
  34. eval('console.log("这是测试eval打印日志")')
  35. rule.title = 'test影视'
  36. },
  37. 推荐: async () => {
  38. sleepSync(2000);
  39. console.log('进入了推荐')
  40. console.log(`这是推荐:${rule.title}`);
  41. return [
  42. {vod_name: '测试电影1', vod_pic: '1.png', vod_remarks: '测试描述1', vod_id: 'http://www.1.com'},
  43. {vod_name: '测试电影2', vod_pic: '2.png', vod_remarks: '测试描述2', vod_id: 'http://www.2.com'},
  44. ]
  45. },
  46. 一级: async function(tid, pg, filter, extend) {
  47. let {input,MY_URL} = this;
  48. console.log({tid,pg,filter,extend});
  49. console.log(`input:${input},MY_URL:${MY_URL}`);
  50. console.log(rule.host);
  51. console.log(rule.host.rstrip('/'));
  52. // log(typeof jsonpath)
  53. // log(jsonpath({path:'$.title',json:rule}))
  54. log(MOBILE_UA);
  55. log(jsonpath.query(rule,'$.title'));
  56. return `input:${input},MY_URL:${MY_URL},host:${rule.host.rstrip('/')}`
  57. },
  58. 二级: async () => {
  59. return '这是二级:' + rule.title
  60. },
  61. 搜索: async () => {
  62. return '这是搜索:' + rule.title
  63. },
  64. lazy: async () => {
  65. return '这是播放:' + rule.title
  66. },
  67. };