
chairemobilite/evolutionEvolution是一个旅行调查平台,其独特之处在于支持旅行日记功能,参与者可记录一天内的所有行程。该平台允许开发灵活的问卷,包含多个任意部分,支持复杂条件、验证、标签和选项,所有这些都可通过脚本使用先前的任何答案。
使用此平台的调查是完整的应用程序,通过TypeScript脚本定义问题和部分。通常,调查应用分为两个独立网站:一个供参与者直接填写问卷,另一个用于管理、监控、验证调查,以及为参与者和电话访问员提供技术支持。
本仓库在example/demo_survey文件夹中包含一个示例旅行调查,可复制此目录并开始编辑自定义调查。
若Linux系统已安装Node.js(18.x或20.x版本),可跳过此步骤。
bashsudo apt update sudo apt install nodejs curl node -v curl --version curl -sL https://deb.nodesource.com/setup_20.x -o /tmp/nodesource_setup.sh sudo bash /tmp/nodesource_setup.sh sudo apt install nodejs node -v
若Linux系统已安装Yarn,可跳过此步骤。
bashsudo npm install -g yarn yarn -v
Linux用户需按以下说明安装依赖。
bashsudo apt update sudo apt install postgresql postgis psql --version # 为postgres用户创建密码(可选) sudo -u postgres psql -c "ALTER USER postgres PASSWORD '<密码>'"
以下是Windows系统的依赖安装说明:
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads下载PostgreSQLpsql --version验证PostgreSQL版本以下是应用准备和编译的步骤:
.env文件(可复制.env.example文件)并进行项目配置.env文件中的Postgres连接字符串,如需使用Google地图,需创建新的Google地图API密钥envPG_CONNECTION_STRING_PREFIX = "postgres://postgres:<密码>@localhost:5432/" GOOGLE_API_KEY = "<你的GoogleApiKey>"
git submodule init && git submodule update:获取Transition子模块yarn install或yarn:下载应用所需依赖包yarn compile:将TypeScript文件转换为JavaScriptyarn setup:为当前项目设置数据库yarn migrate:使用最新更改更新数据库模式yarn create-user:在数据库中创建新用户,该用户可登录Web界面。可通过以下参数以非交互模式运行:yarn create-user --username <用户名> --email <邮箱> --password <明文密码> [--first_name <名> --last_name <姓> --[no-]admin --[no-]valid --[no-]confirmed --prefs <偏好设置JSON字符串>]。例如,创建具有英语偏好的管理员用户:yarn create-user --username admin --email admin@example.org --password MyAdminPassword --admin --prefs '{ "lang": "en" }'示例应用包含两个独立应用。本地开发时,参与者应用默认运行在8080端口,管理应用运行在8082端口。每个应用需构建客户端应用并运行服务器。
yarn build:dev或yarn build:prod:分别以开发模式(含完整调试代码)或生产模式(含压缩代码以提升性能)构建客户端应用yarn start:启动服务器,监听8080端口参与者应用可通过http://localhost:8080访问。
yarn build:admin:dev或yarn build:admin:prod:分别以开发模式和生产模式构建管理应用HOST=http://localhost:8082 yarn start:admin --port 8082:启动服务器并监听8082端口,同时覆盖HOST环境变量以匹配管理应用URL更新应用或切换到可能更改transition子模块的分支时,运行以下命令确保应用正确更新:
bash# 拉取分支 git checkout main git pull origin main # 更新应用 yarn reset-submodules yarn yarn compile yarn migrate
Evolution支持使用Playwright运行UI测试。调查需实现自己的测试,但evolution-frontend在tests/ui-testing文件夹中提供了库。
查看examples/demo_survey/tests文件夹获取UI测试示例。
要为demo_survey应用运行测试,按以下步骤操作:
复制仓库中的配置文件到测试目录,并根据需要修改构建:
bashcp packages/evolution-frontend/playwright-example.config.ts survey/playwright.config.ts
安装Playwright依赖和浏览器:
bashyarn test:ui:install-dependencies
(可通过npx playwright install --with-deps firefox等命令指定安装特定浏览器,详见Playwright文档)
启动应用:
bashyarn build:dev 或 yarn build:prod yarn start
运行测试:
bashyarn test:survey
注:在项目定义的test:survey脚本中,需添加LOCALE_DIR环境变量以注册当前项目的翻译。例如,在demo_survey项目中,脚本定义为:"test:survey": "LOCALE_DIR=$(pwd)/locales npx playwright test"
每个测试需获取自己的执行上下文。以下是启动应用UI测试的示例:
jsimport { test } from '@playwright/test'; import * as testHelpers from 'evolution-frontend/tests/ui-testing/testHelpers'; import * as surveyTestHelpers from 'evolution-frontend/tests/ui-testing/surveyTestHelpers'; import { SurveyObjectDetector } from 'evolution-frontend/tests/ui-testing/SurveyObjectDetectors'; const context = { page: null as any, objectDetector: new SurveyObjectDetector(), title: '', widgetTestCounters: {} }; // 配置测试为串行模式(依次运行) test.describe.configure({ mode: 'serial' }); // 初始化测试页面并添加到上下文 test.beforeAll(async ({ browser }) => { context.page = await testHelpers.initializeTestPage(browser, context.objectDetector); }); // 打开页面并***登录 surveyTestHelpers.startAndLoginAnonymously({ context, title: '魁北克长途旅行', hasUser: false }); // TODO 添加测试用例 // 测试结束时登出 surveyTestHelpers.logout({ context });
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务