djiango项目先测试能使用python manage.py runserver跑起来
vue项目先测试能使用npm run dev跑起来
django_start.bat内容如下
d:
D:\venv\Scripts\python.exe D:\my_django\manage.py runserver 0.0.0.0:8000
放在django项目根目录中
vue_start.bat内容如下
chcp 65001
d:
cd D:\my_vue
npm run dev
放在vue项目根目录中
在C:\Users\ldc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup目录下新建两个.vbs的文件
django_start.vbs
CreateObject("WScript.Shell").Run"cmd /c D:/my_django/django_start.bat",0
vue_start.vbs
CreateObject("WScript.Shell").Run"cmd /c D:/my_vue/vue_start.bat",0
重启电脑可以看到效果。
bat脚本
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
d:
D:\venv\Scripts\python.exe D:\my_django\manage.py runserver 0.0.0.0:8000
python脚本
import os
def run():
os.chdir(r'D:\my_django')
os.popen('django_start.bat')
if __name__ == '__main__':
run()
print("后台运行成功")