开源问卷平台DWSurvey开发配置记录

后端目录及配置

后端目录

后端目录

复制代码
.
├─ src # 工作目录
│  ├─ main
│  ├─ ├─ java
│  ├─ ├─ ├─ net
│  ├─ ├─ ├─ ├─ diaowen
│  ├─ ├─ ├─ ├─ ├─ common # 公共类目录,如LOGIN、SMS、Storage...
│  ├─ ├─ ├─ ├─ ├─ dwsurvey
│  ├─ ├─ ├─ ├─ ├─ ├─ common # 调问公共类目录
│  ├─ ├─ ├─ ├─ ├─ ├─ config # springboot配置目录
│  ├─ ├─ ├─ ├─ ├─ ├─ controller 控制层目录
│  ├─ ├─ ├─ ├─ ├─ ├─ dao 数据层目录
│  ├─ ├─ ├─ ├─ ├─ ├─ entity 实体类目录
│  ├─ ├─ ├─ ├─ ├─ ├─ service 业务层目录
│  ├─ ├─ resource # 配置文件目录
│  ├─ ├─ ├─ application.yml # 配置入口
│  ├─ ├─ ├─ application-dev.yml # 开发环境配置
│  ├─ ├─ ├─ application-prod.yml # 生产环境配置
│  ├─ ├─ ├─ application-test.yml # 测试环境配置
└─ pom.xml # maven包管理

后端配置

通常配置哪些

此处只介绍几处可能会修改的关键配置 通常情况下你只需要修改 mysql 及 elasticsearch 连接信息

不配置 elasticsearch 影响

如果体验预览可以不配置 elasticsearch,但这会使得统计报告无法使用,不影响系统其它功能。

src/main/resources/application-dev.yml

yml

复制代码
dwsurvey:
  # 用户模式切换,暂且保持默认 local, test,demo
  site: "local"
# 服务占用的端口号
server:
  port: 8080
  tomcat:
    max-http-form-post-size: -1

# Spring相关配置
spring:
  # 数据库配置
  datasource:
    #type: com.alibaba.druid.pool.DruidDataSource
    # 连接URL
    url: jdbc:mysql://localhost:3306/dwsurvey?useUnicode=true&characterEncoding=utf8
    # 连接账号
    username: root
    # 连接密码
    password: 123456,.
  ...
# 日志配置
# elasticsearch 配置,不配置不会影响正常设计问卷及答卷,但无法使用统计报告
elasticsearch:
  username: elastic
  passwd: A0ThxyWi1gMNJzv7iU7M
  apikey: ==
  hosts: 127.0.0.1:9200 # 多个IP逗号隔开
  cert-name: http_ca.crt
  #  后加的ES参数
  #  协议方式,使用证书这里改成https
  scheme: http
  #  索引统一前缀,默认为空不加前缀, 如果加建议格式如:dw_
  index-prev: oss_
  # 认证方式 noPwd, pwd, cert
  security: noPwd

前端目录及配置

前端目录

社区版目录企业版目录

复制代码
.
├─ build # 构建配置
├─ config # 项目配置
│  ├─ dev.env.js # 开发环境配置
│  ├─ index.js  # 主配置
│  ├─ prod.env.js  # 生产环境配置
│  └─ test.env.js  # 测试环境配置
├─ src
│  ├─ api  # 接口API
│  ├─ assets  # 资源
│  ├─ components  # 项目组件
│  ├─ ├─ common  # 公共组件
│  ├─ ├─ dw-survey-comp  # 问卷相关组件
│  ├─ ├─ ├─ dw-answer-comp  # 回答问卷组件
│  ├─ ├─ ├─ dw-data-comp  # 问卷数据组件
│  ├─ ├─ ├─ dw-design-comp  # 设计问卷组件
│  ├─ ├─ ├─ dw-utils # 一些帮助文件
│  ├─ ├─ layouts # 系统布局组件
│  └─ router # 系统路由配置
│  └─ theme # 系统主题配置
│  └─ utils # 系统工具文件
│  └─ views # 系统页面文件
└─ package.json # 包管理

前端配置

社区版

TIP

开发环境如果使用 localhost 访问不需要修改, 只用修改 config/index.js 里的 dev.proxyTable.target 地址为后端地址

TIP

如果生产打开请修改 config/prod.env.js 修改为前端实现访问地址,然后配置 nginx 转发

config/dev.env.js

js

复制代码
/**
 * 注意:开发环境不需要修改这里
 * 只需要修改 index.js dev.proxyTable.target地址为后端地址
 */
"use strict";
const merge = require("webpack-merge");
const prodEnv = require("./prod.env");

module.exports = merge(prodEnv, {
  NODE_ENV: '"development"',
  // 本地开发环境后端API地址不需要在这个文件配置,在config/index.js里面配置target
  DW_API_URL: '"http://localhost:8081"', //开发环境不需要修改,只需要 config/index.js target
  DW_WEB_URL: '"http://localhost:8081"', //开发环境不需要修改,只需要 config/index.js target
  DW_RESOURCE_URL: '"http://localhost:8080"',
});

config/index.js

js

复制代码
"use strict";
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require("path");

module.exports = {
  dev: {
    // Paths
    assetsSubDirectory: "static",
    assetsPublicPath: "/",
    proxyTable: {
      "/api": {
        target: "http://localhost:8080/", // 本地开发环境只需要修改这个配置,修改为后端服务地址即可
        changeOrigin: true, //如果需要跨域
        pathRewrite: {
          "^/api": "/api",
        },
      },
    },
    ...
  },
  ...
};

企业版

config/.env.development

js

复制代码
/**
 * 注意:修改这里为后端实现地址,
 * 也可以不修改这个,只修改 vite.config server.proxy.target 地址为后端地址
 */
NODE_ENV = "development";
VITE_DW_API_URL = "http://localhost:5173";
VITE_DW_WEB_URL = "http://localhost:5173";
VITE_DW_RESOURCE_URL = "http://localhost:5173";

nginx 配置

token 认证方式

conf.d 目录下面新建 dwsurvey.conf,并配置如下内容

conf.d/dwsurvey.conf

conf

复制代码
server {
    listen 80;
    server_name _;
    root /www/sf/dist;
    index index.html;

    location / {
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    location /api {
         # rewrite ^/api/(.*) /$1 break;
         proxy_pass http://localhost:8899;
    }

    location /file {
         # rewrite ^/api/(.*) /$1 break;
         proxy_pass http://localhost:8899;
    }

    error_page 404 /404.html;
         location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
         location = /50x.html {
    }
}

编辑 nginx.conf 的配置引用 include /etc/nginx/conf.d/dwsurvey.conf; 如下所示

复制代码
include /etc/nginx/conf.d/*.conf;

效果如图

session 认证方式

conf.d 目录下面新建 dwsurvey.conf,并配置如下内容

conf.d/dwsurvey.conf

conf

复制代码
server {
    listen 80;
    server_name _;
    root /www/sf/dist;
    index index.html;

    location / {
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;
         location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
         location = /50x.html {
    }
}

编辑 nginx.conf 的配置引用 include /etc/nginx/conf.d/dwsurvey.conf; 如下所示

复制代码
include /etc/nginx/conf.d/*.conf;

效果如图

相关推荐
枷锁—sha1 分钟前
【SRC】越权漏洞检测
运维·服务器·网络·安全·网络安全·系统安全
UP_Continue16 分钟前
Linux--进程控制
linux·运维·服务器
等什么君!35 分钟前
docker -数据卷技术
运维·docker·容器
wAIxiSeu1 小时前
Github开源项目推荐
开源·github
开源能源管理系统2 小时前
MyEMS开源能源管理系统赋能化纤织造产业绿色转型
开源·能源·能源管理系统·零碳工厂
zhangfeng11332 小时前
ModelScope(魔搭社区)介绍与模型微调全指南 中国版Hugging Face GPU租借平台 一站式开源模型社区与服务平台
人工智能·开源
修己xj3 小时前
FossFLOW:开源等距图表工具,为技术文档注入立体活力!
开源
兆龙电子单片机设计3 小时前
【STM32项目开源】STM32单片机多功能电子秤
stm32·单片机·开源·毕业设计·智能家居
小白跃升坊3 小时前
基于1Panel的AI运维
linux·运维·人工智能·ai大模型·教学·ai agent
向哆哆3 小时前
高校四六级报名管理系统的考试信息模块实现:Flutter × OpenHarmony 跨端开发实践
flutter·开源·鸿蒙·openharmony·开源鸿蒙