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

效果如图

相关推荐
gaize121320 小时前
服务器分类及区别划分!多样化服务器用途体系架构及层次分类
运维·服务器·架构
鲁正杰20 小时前
【运维部署】现代化内网穿透与文件共享方案 (Rust)
运维·开发语言·rust
墨染天姬21 小时前
【AI】各类型开源模型排行
人工智能·开源
济61721 小时前
linux(第七期)--gcc编译软件-- Ubuntu20.04
linux·运维·服务器
OctShop大型商城源码21 小时前
大型多用户商城开源源码_OctShop商城开源源码
开源·多用户商城系统·免费商城·多用户商城源码·免费商城系统
magicodes21 小时前
CodeSpirit-考试预生成方案(开源)
开源
梦梦代码精21 小时前
一个让 AI 应用“快速上线+私有部署+商业变现”的开源方案
人工智能·开源
Sheffield1 天前
今天浅浅的回顾一下Ansible吧
运维
GitCode官方1 天前
参会预告 | AtomGit 邀您共赴 TritonNext 2026 技术大会,解锁 AI 系统与编译生态新机遇
人工智能·开源·atomgit