start.bat 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. @echo off
  2. setlocal EnableExtensions
  3. cd /d "%~dp0"
  4. chcp 65001 >nul
  5. set "XHS_PY=%~dp0python\py\python.exe"
  6. if not exist "%XHS_PY%" (
  7. echo [ERROR] Python not found: "%XHS_PY%"
  8. echo Check config.ini paths.pythonRelative
  9. call :BringCmdWindowToForeground
  10. pause
  11. exit /b 1
  12. )
  13. if "%~1"=="" goto interactive_loop
  14. "%XHS_PY%" "%~dp0workplace\main.py" %*
  15. goto end
  16. :interactive_loop
  17. set /p "KW=搜索关键词: "
  18. if "%KW%"=="" (
  19. echo 未输入搜索关键词。
  20. call :BringCmdWindowToForeground
  21. pause
  22. exit /b 1
  23. )
  24. set "SORT="
  25. set /p "N=请选择筛选条件:1 点赞最多 2 收藏最多 3 评论最多 直接回车=不筛选: "
  26. if "%N%"=="" set "SORT=0"
  27. if "%N%"=="0" set "SORT=0"
  28. if "%N%"=="1" set "SORT=likes"
  29. if "%N%"=="2" set "SORT=collect"
  30. if "%N%"=="3" set "SORT=comment"
  31. set "NOTE_ONE_BASED_INDEX="
  32. set /p "NOTE_ONE_BASED_INDEX=保存第几个笔记 (1=第一条 2=第二条 … 回车=第一条): "
  33. set "NOTE_ZERO_BASED_FOLDER_INDEX=0"
  34. if not "%NOTE_ONE_BASED_INDEX%"=="" (
  35. set /a NOTE_ZERO_BASED_FOLDER_INDEX=%NOTE_ONE_BASED_INDEX%-1
  36. )
  37. "%XHS_PY%" "%~dp0workplace\main.py" "%KW%" "%SORT%" %NOTE_ZERO_BASED_FOLDER_INDEX%
  38. set "EC=%ERRORLEVEL%"
  39. if not "%EC%"=="0" call :BringCmdWindowToForeground
  40. if not "%EC%"=="0" pause
  41. goto interactive_loop
  42. :end
  43. set "EC=%ERRORLEVEL%"
  44. if not "%EC%"=="0" call :BringCmdWindowToForeground
  45. pause >nul
  46. exit /b %EC%
  47. :BringCmdWindowToForeground
  48. powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0bring-cmd-window-foreground.ps1"
  49. goto :eof