Nginx 部署 Vue 打包项目,将dist目录上传至ngnix中的目录中,遇到的问题

Nginx 部署 Vue 打包项目,将dist目录上传至ngnix中的目录中,遇到的问题

需要指向下面的 @router 否则会出现 Vue 的路由在 Nginx 中刷新出现 404

server {
        listen       8099;
        server_name  localhost;
        
        location / {
            root   atjk/dist/;
            index  index.html index.htm;
            try_files $uri $uri/ @router;
            index index.html;
        }
        #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
        location @router {
            #因此需要rewrite到index,html中,然后交给路由再处理请求资源
            rewrite ^.*$ /index.html last;
        }
        location /api/ {
            proxy_pass http://127.0.0.1:8089/;
        }
    }

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  abc.cn;
        
        location / {
            root   atjk-vue/;
            index  index.html index.htm;
            try_files $uri $uri/ @router;
            index index.html;
        }
        #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
        location @router {
            #因此需要rewrite到index,html中,然后交给路由再处理请求资源
            rewrite ^.*$ /index.html last;
        }
        location /api/ {
            proxy_pass http://127.0.0.1:8089/;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    
    server {
        listen 80;
        server_name www.abc.cn;
        #将请求转成https
        rewrite ^(.*)$ https://$host$1 permanent;
    }
        
  
    server {
        listen       443 ssl;
        server_name  www.abc.cn;

        ssl_certificate      cert/abc.cn.pem;
        ssl_certificate_key  cert/abc.cn.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            root   atjk-vue/;
            index  index.html index.htm;
            try_files $uri $uri/ @router;
            index index.html;
        }
        #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
        location @router {
            #因此需要rewrite到index,html中,然后交给路由再处理请求资源
            rewrite ^.*$ /index.html last;
        }
        #  location /api/ 这个后面有斜杠,proxy_pass http://127.0.0.1:8089/; 这个后面有斜杠,实际请求会去掉/api
        # 测试url:http://127.0.0.1:8089/api/abc
        # 实际访问:http://127.0.0.1:8089/abc
        location /api/ {
            proxy_pass http://127.0.0.1:8089/;
        }

		# 大屏配置
		#  location /blade-visual这个后面没有斜杠,proxy_pass http://127.0.0.1:8050; 这个后面没有斜杠,实际请求会拼接/blade-visual
        # 测试url:http://127.0.0.1:8050/blade-visual/abc
        # 实际访问:http://127.0.0.1:8050/blade-visual/abc
        location /blade-visual {
			proxy_pass http://127.0.0.1:8050;
		}
    }

}

在这里插入图片描述

<think>好的,用户想了解创芯科技CAN分析仪使用方法。我需要根据提供的引用资料来整理回答。首先,用户提到的引用[1][4]提到了官网下载驱动CANTest软件安装,还有Python二次开发的步骤。引用[2][3]强调了了解CAN通讯基础项目应用。应该分步骤讲解,从硬件准备、驱动安装、软件使用到二次开发。要注意使用正确的格式,比如行内数学公式用$符号,但这里可能用不上。还要生成相关问题,可能涉及驱动安装问题、CANTest功能、Python开发要点应用场景。需要确保回答结构清晰,步骤详细,引用标识正确添加。检查是否有遗漏的步骤,比如硬件连接或常见问题。最后确认是否符合用户需求,可能需要补充一些注意事项,比如系统兼容性或驱动安装顺序。</think>### 创芯科技CAN分析仪使用教程 #### 一、硬件准备与驱动安装 1. **硬件连接** 将创芯科技CAN分析仪(如CANalyst-II)通过USB接口连接到电脑,并确保开发板与CAN分析仪通过CAN总线正确连接(需匹配波特率)[^3]。 2. **驱动安装** - 访问创芯科技官网下载驱动及资料包,选择对应型号(如CANalyst-II)的驱动[^1]。 - 解压安装包,运行驱动程序(如`CH368Driver.exe`),按提示完成安装[^4]。 - 安装完成后,在设备管理器中确认是否识别到设备(显示为`USB-CAN Interface`或类似名称)。 --- #### 二、CANTest软件使用 1. **安装与配置** - 下载并安装`CANTest`测试软件(包含在资料包中)。 - 打开软件,选择设备类型为`USBCAN-2A/2B`,设置通道参数(如波特率、滤波模式等)[^3]。 2. **基础通信测试** - 点击“启动设备”按钮,开启CAN通道。 - 在“发送区”输入CAN帧数据(ID、数据域等),点击“发送”测试通信是否正常。 - 接收区显示从CAN总线读取的数据,验证双向通信功能[^2]。 --- #### 三、Python二次开发(以CANalyst-II为例) 1. **依赖库安装** - 根据设备提供的DLL文件(如`ControlCAN.dll`),使用`ctypes`库进行调用。 ```python from ctypes import * can_dll = windll.LoadLibrary("ControlCAN.dll") ``` 2. **初始化设备** ```python # 打开设备 ret = can_dll.VCI_OpenDevice(device_type, device_index, reserved) # 初始化CAN通道参数(波特率、工作模式等) config = VCI_INIT_CONFIG() can_dll.VCI_InitCAN(device_type, device_index, can_channel, byref(config)) ``` 3. **数据收发示例** ```python # 发送数据 send_frame = VCI_CAN_OBJ(ID=0x123, Data=[0x01, 0x02]) can_dll.VCI_Transmit(device_type, device_index, can_channel, byref(send_frame), 1) # 接收数据 recv_frames = (VCI_CAN_OBJ * 1000)() ret = can_dll.VCI_Receive(device_type, device_index, can_channel, byref(recv_frames), 1000, 100) ``` --- #### 四、注意事项 1. 确保开发板与分析仪的**波特率一致**,否则无法通信。 2. 若驱动安装失败,尝试以管理员权限运行安装程序或禁用驱动程序强制签名。 3. 调试时建议先通过`CANTest`验证硬件连接,再进行二次开发。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

丿乐灬学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值