开源问卷平台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;

效果如图

相关推荐
HelloGitHub1 小时前
《HelloGitHub》第 126 期
开源·github
miofly2 小时前
GitHub 日榜趋势速报 | 2026-09-28
开源·github
miofly7 小时前
GitHub 日榜趋势速报 | 2026-09-27
开源·github
miofly7 小时前
GitHub 日榜趋势速报 | 2026-09-26
开源·github
冬奇Lab7 小时前
一天一个开源项目(第228篇):AX —— Google 开源的「Kubernetes for Agents」,用声明式 YAML 编排十亿级 Agent 任务
人工智能·开源·资讯
天天向上2917 小时前
从零用 Spring AI 搭建 RAG + Tool Calling 岗位分析系统:全流程实战与踩坑记录
开源
冬奇Lab7 小时前
一天一个开源项目(第 227 篇):Strands Agents Harness SDK —— 从「手写 Agent 循环」到「一行代码拿到生产级 Agent」
人工智能·开源
miofly7 小时前
GitHub 日榜趋势速报 | 2026-09-25
开源·github
OpenTiny社区7 小时前
HC 2026 回顾|OpenTiny NEXT 解锁 Web 应用智能化新范式
前端·开源·github
judezh7 小时前
api 容器一直 unhealthy?我把一个 Agent 运行时的健康检查逐条拆了,查出四个问题
运维·docker