From 99ac95ecdf37d9de8a61b4375376569436966bdf Mon Sep 17 00:00:00 2001 From: Nick Zeng Date: Wed, 5 Nov 2025 16:34:40 +0800 Subject: [PATCH] dataflow project init commit --- .gitignore | 182 ++++++++++++++++++ backend/.env.example | 17 ++ backend/.gitignore | 16 ++ backend/.gitlab-ci.yml | 57 ++++++ backend/.php-cs-fixer.php | 106 ++++++++++ backend/.phpstorm.meta.php | 12 ++ backend/Dockerfile | 54 ++++++ backend/LICENSE | 21 ++ backend/README.md | 63 ++++++ backend/app/Constants/ErrorCode.php | 25 +++ backend/app/Controller/AbstractController.php | 30 +++ backend/app/Controller/IndexController.php | 27 +++ backend/app/Exception/BusinessException.php | 29 +++ .../Exception/Handler/AppExceptionHandler.php | 38 ++++ .../app/Listener/DbQueryExecutedListener.php | 66 +++++++ .../ResumeExitCoordinatorListener.php | 35 ++++ backend/app/Model/Model.php | 19 ++ backend/bin/hyperf.php | 31 +++ backend/composer.json | 77 ++++++++ backend/config/autoload/annotations.php | 21 ++ backend/config/autoload/aspects.php | 13 ++ backend/config/autoload/cache.php | 19 ++ backend/config/autoload/commands.php | 13 ++ backend/config/autoload/databases.php | 41 ++++ backend/config/autoload/dependencies.php | 13 ++ backend/config/autoload/devtool.php | 44 +++++ backend/config/autoload/exceptions.php | 19 ++ backend/config/autoload/listeners.php | 15 ++ backend/config/autoload/logger.php | 30 +++ backend/config/autoload/middlewares.php | 15 ++ backend/config/autoload/processes.php | 13 ++ backend/config/autoload/server.php | 50 +++++ backend/config/config.php | 33 ++++ backend/config/container.php | 21 ++ backend/config/routes.php | 18 ++ backend/deploy.test.yml | 30 +++ backend/docker-compose.yml | 18 ++ backend/phpstan.neon.dist | 14 ++ backend/phpunit.xml.dist | 16 ++ backend/test/Cases/ExampleTest.php | 27 +++ backend/test/HttpTestCase.php | 45 +++++ backend/test/bootstrap.php | 30 +++ frontend/.editorconfig | 8 + frontend/.gitattributes | 1 + frontend/.gitignore | 39 ++++ frontend/.prettierrc.json | 6 + frontend/.vscode/extensions.json | 10 + frontend/README.md | 73 +++++++ frontend/e2e/tsconfig.json | 4 + frontend/e2e/vue.spec.ts | 8 + frontend/env.d.ts | 1 + frontend/eslint.config.ts | 34 ++++ frontend/index.html | 13 ++ frontend/package.json | 53 +++++ frontend/playwright.config.ts | 110 +++++++++++ frontend/public/favicon.ico | Bin 0 -> 4286 bytes frontend/src/App.vue | 85 ++++++++ frontend/src/assets/base.css | 86 +++++++++ frontend/src/assets/logo.svg | 1 + frontend/src/assets/main.css | 36 ++++ frontend/src/components/HelloWorld.vue | 41 ++++ frontend/src/components/TheWelcome.vue | 95 +++++++++ frontend/src/components/WelcomeItem.vue | 87 +++++++++ .../components/__tests__/HelloWorld.spec.ts | 11 ++ .../src/components/icons/IconCommunity.vue | 7 + .../components/icons/IconDocumentation.vue | 7 + .../src/components/icons/IconEcosystem.vue | 7 + frontend/src/components/icons/IconSupport.vue | 7 + frontend/src/components/icons/IconTooling.vue | 19 ++ frontend/src/main.ts | 14 ++ frontend/src/router/index.ts | 23 +++ frontend/src/stores/counter.ts | 12 ++ frontend/src/views/AboutView.vue | 15 ++ frontend/src/views/HomeView.vue | 9 + frontend/tsconfig.app.json | 12 ++ frontend/tsconfig.json | 14 ++ frontend/tsconfig.node.json | 19 ++ frontend/tsconfig.vitest.json | 11 ++ frontend/vite.config.ts | 22 +++ frontend/vitest.config.ts | 14 ++ gitignore.example | 182 ++++++++++++++++++ 81 files changed, 2659 insertions(+) create mode 100644 .gitignore create mode 100644 backend/.env.example create mode 100644 backend/.gitignore create mode 100644 backend/.gitlab-ci.yml create mode 100644 backend/.php-cs-fixer.php create mode 100644 backend/.phpstorm.meta.php create mode 100644 backend/Dockerfile create mode 100644 backend/LICENSE create mode 100644 backend/README.md create mode 100644 backend/app/Constants/ErrorCode.php create mode 100644 backend/app/Controller/AbstractController.php create mode 100644 backend/app/Controller/IndexController.php create mode 100644 backend/app/Exception/BusinessException.php create mode 100644 backend/app/Exception/Handler/AppExceptionHandler.php create mode 100644 backend/app/Listener/DbQueryExecutedListener.php create mode 100644 backend/app/Listener/ResumeExitCoordinatorListener.php create mode 100644 backend/app/Model/Model.php create mode 100644 backend/bin/hyperf.php create mode 100644 backend/composer.json create mode 100644 backend/config/autoload/annotations.php create mode 100644 backend/config/autoload/aspects.php create mode 100644 backend/config/autoload/cache.php create mode 100644 backend/config/autoload/commands.php create mode 100644 backend/config/autoload/databases.php create mode 100644 backend/config/autoload/dependencies.php create mode 100644 backend/config/autoload/devtool.php create mode 100644 backend/config/autoload/exceptions.php create mode 100644 backend/config/autoload/listeners.php create mode 100644 backend/config/autoload/logger.php create mode 100644 backend/config/autoload/middlewares.php create mode 100644 backend/config/autoload/processes.php create mode 100644 backend/config/autoload/server.php create mode 100644 backend/config/config.php create mode 100644 backend/config/container.php create mode 100644 backend/config/routes.php create mode 100644 backend/deploy.test.yml create mode 100644 backend/docker-compose.yml create mode 100644 backend/phpstan.neon.dist create mode 100644 backend/phpunit.xml.dist create mode 100644 backend/test/Cases/ExampleTest.php create mode 100644 backend/test/HttpTestCase.php create mode 100644 backend/test/bootstrap.php create mode 100644 frontend/.editorconfig create mode 100644 frontend/.gitattributes create mode 100644 frontend/.gitignore create mode 100644 frontend/.prettierrc.json create mode 100644 frontend/.vscode/extensions.json create mode 100644 frontend/README.md create mode 100644 frontend/e2e/tsconfig.json create mode 100644 frontend/e2e/vue.spec.ts create mode 100644 frontend/env.d.ts create mode 100644 frontend/eslint.config.ts create mode 100644 frontend/index.html create mode 100644 frontend/package.json create mode 100644 frontend/playwright.config.ts create mode 100644 frontend/public/favicon.ico create mode 100644 frontend/src/App.vue create mode 100644 frontend/src/assets/base.css create mode 100644 frontend/src/assets/logo.svg create mode 100644 frontend/src/assets/main.css create mode 100644 frontend/src/components/HelloWorld.vue create mode 100644 frontend/src/components/TheWelcome.vue create mode 100644 frontend/src/components/WelcomeItem.vue create mode 100644 frontend/src/components/__tests__/HelloWorld.spec.ts create mode 100644 frontend/src/components/icons/IconCommunity.vue create mode 100644 frontend/src/components/icons/IconDocumentation.vue create mode 100644 frontend/src/components/icons/IconEcosystem.vue create mode 100644 frontend/src/components/icons/IconSupport.vue create mode 100644 frontend/src/components/icons/IconTooling.vue create mode 100644 frontend/src/main.ts create mode 100644 frontend/src/router/index.ts create mode 100644 frontend/src/stores/counter.ts create mode 100644 frontend/src/views/AboutView.vue create mode 100644 frontend/src/views/HomeView.vue create mode 100644 frontend/tsconfig.app.json create mode 100644 frontend/tsconfig.json create mode 100644 frontend/tsconfig.node.json create mode 100644 frontend/tsconfig.vitest.json create mode 100644 frontend/vite.config.ts create mode 100644 frontend/vitest.config.ts create mode 100644 gitignore.example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c3b3bbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,182 @@ +# ============================================ +# 前后端分离项目 .gitignore 示例文件 +# 后端:Hyperf 3.1 | 前端:Vite + Vue3 + AntDV 4 +# ============================================ + +# ==================== 后端 (Hyperf/PHP) ==================== +backend/vendor/ +backend/runtime/ +backend/.env +backend/.phpintel/ +backend/*.cache +backend/.phpunit* +backend/phpstan.neon +backend/phpunit.xml +backend/.php_cs.cache +backend/.php-cs-fixer.cache +backend/composer.lock + +# ==================== 前端 (Vue3/Vite) ==================== +frontend/node_modules/ +frontend/dist/ +frontend/dist-ssr/ +frontend/.DS_Store +frontend/coverage/ +frontend/*.local +frontend/.eslintcache +frontend/*.tsbuildinfo +frontend/package-lock.json +frontend/pnpm-lock.yaml +frontend/yarn.lock + +# 前端日志文件 +frontend/logs/ +frontend/*.log +frontend/npm-debug.log* +frontend/yarn-debug.log* +frontend/yarn-error.log* +frontend/pnpm-debug.log* +frontend/lerna-debug.log* + +# 前端测试相关 +frontend/test-results/ +frontend/playwright-report/ +frontend/__screenshots__/ +frontend/cypress/videos/ +frontend/cypress/screenshots/ + +# ==================== 数据目录 ==================== +# 数据库文件 +data/*.db +data/*.sqlite +data/*.sqlite3 + +# 临时数据文件 +data/*.tmp +data/*.temp +data/*.bak +data/*.backup + +# 数据导出文件 +data/exports/ +data/cache/ +data/logs/ + +# ==================== 文档目录 ==================== +# 文档生成文件 +docs/.vuepress/dist/ +docs/.vuepress/.cache/ +docs/.vuepress/.temp/ +docs/node_modules/ + +# 文档草稿 +docs/*.draft.md +docs/*.wip.md + +# ==================== IDE & 编辑器 ==================== +# VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# JetBrains IDEs (PhpStorm, WebStorm, IntelliJ) +.idea/ +*.iml +*.iws +*.ipr +.idea_modules/ + +# Eclipse +.buildpath +.project +.settings/ + +# Sublime Text +*.sublime-project +*.sublime-workspace + +# Vim +*.swp +*.swo +*~ +.*.sw? + +# ==================== 操作系统 ==================== +# macOS +.DS_Store +.AppleDouble +.LSOverride +._* +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Windows +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +Desktop.ini +$RECYCLE.BIN/ +*.lnk + +# Linux +.directory +.Trash-* +.nfs* + +# ==================== 环境配置 ==================== +# 环境变量文件 +.env +.env.local +.env.*.local +.env.development +.env.production +.env.staging + +# ==================== Docker ==================== +docker-compose.override.yml +.dockerignore + +# ==================== 版本控制 ==================== +*.patch +*.diff + +# ==================== 临时文件 ==================== +*.tmp +*.temp +*.log +*.bak +*.swp +*.swo +*~ + +# ==================== 依赖锁文件(可选)==================== +# 如果团队使用统一的包管理器,可以取消注释以下行 +# composer.lock +# package-lock.json +# yarn.lock +# pnpm-lock.yaml + +# ==================== 构建产物 ==================== +build/ +dist/ +out/ + +# ==================== 其他 ==================== +# 调试文件 +*.map +*.orig + +# 压缩文件 +*.zip +*.tar.gz +*.rar +*.7z diff --git a/backend/.env.example b/backend/.env.example new file mode 100644 index 0000000..6879583 --- /dev/null +++ b/backend/.env.example @@ -0,0 +1,17 @@ +APP_NAME=skeleton +APP_ENV=dev + +DB_DRIVER=mysql +DB_HOST=localhost +DB_PORT=3306 +DB_DATABASE=hyperf +DB_USERNAME=root +DB_PASSWORD= +DB_CHARSET=utf8mb4 +DB_COLLATION=utf8mb4_unicode_ci +DB_PREFIX= + +REDIS_HOST=localhost +REDIS_AUTH=(null) +REDIS_PORT=6379 +REDIS_DB=0 \ No newline at end of file diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..c69291b --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,16 @@ +.buildpath +.settings/ +.project +*.patch +.idea/ +.git/ +runtime/ +vendor/ +.phpintel/ +.env +.DS_Store +.phpunit* +*.cache +.vscode/ +/phpstan.neon +/phpunit.xml diff --git a/backend/.gitlab-ci.yml b/backend/.gitlab-ci.yml new file mode 100644 index 0000000..a5fccae --- /dev/null +++ b/backend/.gitlab-ci.yml @@ -0,0 +1,57 @@ +# usermod -aG docker gitlab-runner + +stages: + - build + - deploy + +variables: + PROJECT_NAME: hyperf + REGISTRY_URL: registry-docker.org + +build_test_docker: + stage: build + before_script: +# - git submodule sync --recursive +# - git submodule update --init --recursive + script: + - docker build . -t $PROJECT_NAME + - docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:test + - docker push $REGISTRY_URL/$PROJECT_NAME:test + only: + - test + tags: + - builder + +deploy_test_docker: + stage: deploy + script: + - docker stack deploy -c deploy.test.yml --with-registry-auth $PROJECT_NAME + only: + - test + tags: + - test + +build_docker: + stage: build + before_script: +# - git submodule sync --recursive +# - git submodule update --init --recursive + script: + - docker build . -t $PROJECT_NAME + - docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME + - docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:latest + - docker push $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME + - docker push $REGISTRY_URL/$PROJECT_NAME:latest + only: + - tags + tags: + - builder + +deploy_docker: + stage: deploy + script: + - echo SUCCESS + only: + - tags + tags: + - builder diff --git a/backend/.php-cs-fixer.php b/backend/.php-cs-fixer.php new file mode 100644 index 0000000..204686a --- /dev/null +++ b/backend/.php-cs-fixer.php @@ -0,0 +1,106 @@ +setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + '@Symfony' => true, + '@DoctrineAnnotation' => true, + '@PhpCsFixer' => true, + 'header_comment' => [ + 'comment_type' => 'PHPDoc', + 'header' => $header, + 'separate' => 'none', + 'location' => 'after_declare_strict', + ], + 'array_syntax' => [ + 'syntax' => 'short', + ], + 'list_syntax' => [ + 'syntax' => 'short', + ], + 'concat_space' => [ + 'spacing' => 'one', + ], + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => true, + 'import_functions' => null, + ], + 'blank_line_before_statement' => [ + 'statements' => [ + 'declare', + ], + ], + 'general_phpdoc_annotation_remove' => [ + 'annotations' => [ + 'author', + ], + ], + 'ordered_imports' => [ + 'imports_order' => [ + 'class', 'function', 'const', + ], + 'sort_algorithm' => 'alpha', + ], + 'single_line_comment_style' => [ + 'comment_types' => [ + ], + ], + 'yoda_style' => [ + 'always_move_variable' => false, + 'equal' => false, + 'identical' => false, + ], + 'phpdoc_align' => [ + 'align' => 'left', + ], + 'multiline_whitespace_before_semicolons' => [ + 'strategy' => 'no_multi_line', + ], + 'constant_case' => [ + 'case' => 'lower', + ], + 'class_attributes_separation' => true, + 'combine_consecutive_unsets' => true, + 'declare_strict_types' => true, + 'linebreak_after_opening_tag' => true, + 'lowercase_static_reference' => true, + 'no_useless_else' => true, + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'not_operator_with_space' => false, + 'ordered_class_elements' => true, + 'php_unit_strict' => false, + 'phpdoc_separation' => false, + 'single_quote' => true, + 'standardize_not_equals' => true, + 'multiline_comment_opening_closing' => true, + 'single_line_empty_body' => false, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('public') + ->exclude('runtime') + ->exclude('vendor') + ->in(__DIR__) + ) + ->setUsingCache(false); diff --git a/backend/.phpstorm.meta.php b/backend/.phpstorm.meta.php new file mode 100644 index 0000000..c8b6300 --- /dev/null +++ b/backend/.phpstorm.meta.php @@ -0,0 +1,12 @@ + '@'])); + override(\Hyperf\Context\Context::get(0), map(['' => '@'])); + override(\make(0), map(['' => '@'])); + override(\di(0), map(['' => '@'])); + override(\Hyperf\Support\make(0), map(['' => '@'])); + override(\Hyperf\Support\optional(0), type(0)); + override(\Hyperf\Tappable\tap(0), type(0)); +} diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..4905614 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,54 @@ +# Default Dockerfile +# +# @link https://www.hyperf.io +# @document https://hyperf.wiki +# @contact group@hyperf.io +# @license https://github.com/hyperf/hyperf/blob/master/LICENSE + +FROM hyperf/hyperf:8.3-alpine-v3.19-swoole +LABEL maintainer="Hyperf Developers " version="1.0" license="MIT" app.name="Hyperf" + +## +# ---------- env settings ---------- +## +# --build-arg timezone=Asia/Shanghai +ARG timezone + +ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ + APP_ENV=prod \ + SCAN_CACHEABLE=(true) + +# update +RUN set -ex \ + # show php version and extensions + && php -v \ + && php -m \ + && php --ri swoole \ + # ---------- some config ---------- + && cd /etc/php* \ + # - config PHP + && { \ + echo "upload_max_filesize=128M"; \ + echo "post_max_size=128M"; \ + echo "memory_limit=1G"; \ + echo "date.timezone=${TIMEZONE}"; \ + } | tee conf.d/99_overrides.ini \ + # - config timezone + && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ + && echo "${TIMEZONE}" > /etc/timezone \ + # ---------- clear works ---------- + && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \ + && echo -e "\033[42;37m Build Completed :).\033[0m\n" + +WORKDIR /opt/www + +# Composer Cache +# COPY ./composer.* /opt/www/ +# RUN composer install --no-dev --no-scripts + +COPY . /opt/www +RUN composer install --no-dev -o && php bin/hyperf.php + +EXPOSE 9501 + +ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"] diff --git a/backend/LICENSE b/backend/LICENSE new file mode 100644 index 0000000..c35d3f5 --- /dev/null +++ b/backend/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Hyperf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..7d7a10d --- /dev/null +++ b/backend/README.md @@ -0,0 +1,63 @@ +# Introduction + +This is a skeleton application using the Hyperf framework. This application is meant to be used as a starting place for those looking to get their feet wet with Hyperf Framework. + +# Requirements + +Hyperf has some requirements for the system environment, it can only run under Linux and Mac environment, but due to the development of Docker virtualization technology, Docker for Windows can also be used as the running environment under Windows. + +The various versions of Dockerfile have been prepared for you in the [hyperf/hyperf-docker](https://github.com/hyperf/hyperf-docker) project, or directly based on the already built [hyperf/hyperf](https://hub.docker.com/r/hyperf/hyperf) Image to run. + +When you don't want to use Docker as the basis for your running environment, you need to make sure that your operating environment meets the following requirements: + + - PHP >= 8.1 + - Any of the following network engines + - Swoole PHP extension >= 5.0,with `swoole.use_shortname` set to `Off` in your `php.ini` + - Swow PHP extension >= 1.3 + - JSON PHP extension + - Pcntl PHP extension + - OpenSSL PHP extension (If you need to use the HTTPS) + - PDO PHP extension (If you need to use the MySQL Client) + - Redis PHP extension (If you need to use the Redis Client) + - Protobuf PHP extension (If you need to use the gRPC Server or Client) + +# Installation using Composer + +The easiest way to create a new Hyperf project is to use [Composer](https://getcomposer.org/). If you don't have it already installed, then please install as per [the documentation](https://getcomposer.org/download/). + +To create your new Hyperf project: + +```bash +composer create-project hyperf/hyperf-skeleton path/to/install +``` + +If your development environment is based on Docker you can use the official Composer image to create a new Hyperf project: + +```bash +docker run --rm -it -v $(pwd):/app composer create-project --ignore-platform-reqs hyperf/hyperf-skeleton path/to/install +``` + +# Getting started + +Once installed, you can run the server immediately using the command below. + +```bash +cd path/to/install +php bin/hyperf.php start +``` + +Or if in a Docker based environment you can use the `docker-compose.yml` provided by the template: + +```bash +cd path/to/install +docker-compose up +``` + +This will start the cli-server on port `9501`, and bind it to all network interfaces. You can then visit the site at `http://localhost:9501/` which will bring up Hyperf default home page. + +## Hints + +- A nice tip is to rename `hyperf-skeleton` of files like `composer.json` and `docker-compose.yml` to your actual project name. +- Take a look at `config/routes.php` and `app/Controller/IndexController.php` to see an example of a HTTP entrypoint. + +**Remember:** you can always replace the contents of this README.md file to something that fits your project description. diff --git a/backend/app/Constants/ErrorCode.php b/backend/app/Constants/ErrorCode.php new file mode 100644 index 0000000..3a66e7b --- /dev/null +++ b/backend/app/Constants/ErrorCode.php @@ -0,0 +1,25 @@ +request->input('user', 'Hyperf'); + $method = $this->request->getMethod(); + + return [ + 'method' => $method, + 'message' => "Hello {$user}.", + ]; + } +} diff --git a/backend/app/Exception/BusinessException.php b/backend/app/Exception/BusinessException.php new file mode 100644 index 0000000..043add2 --- /dev/null +++ b/backend/app/Exception/BusinessException.php @@ -0,0 +1,29 @@ +logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); + $this->logger->error($throwable->getTraceAsString()); + return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); + } + + public function isValid(Throwable $throwable): bool + { + return true; + } +} diff --git a/backend/app/Listener/DbQueryExecutedListener.php b/backend/app/Listener/DbQueryExecutedListener.php new file mode 100644 index 0000000..5804bb7 --- /dev/null +++ b/backend/app/Listener/DbQueryExecutedListener.php @@ -0,0 +1,66 @@ +logger = $container->get(LoggerFactory::class)->get('sql'); + } + + public function listen(): array + { + return [ + QueryExecuted::class, + ]; + } + + /** + * @param QueryExecuted $event + */ + public function process(object $event): void + { + if ($event instanceof QueryExecuted) { + $sql = $event->sql; + if (! Arr::isAssoc($event->bindings)) { + $position = 0; + foreach ($event->bindings as $value) { + $position = strpos($sql, '?', $position); + if ($position === false) { + break; + } + $value = "'{$value}'"; + $sql = substr_replace($sql, $value, $position, 1); + $position += strlen($value); + } + } + + $this->logger->info(sprintf('[%s] %s', $event->time, $sql)); + } + } +} diff --git a/backend/app/Listener/ResumeExitCoordinatorListener.php b/backend/app/Listener/ResumeExitCoordinatorListener.php new file mode 100644 index 0000000..eff2e0b --- /dev/null +++ b/backend/app/Listener/ResumeExitCoordinatorListener.php @@ -0,0 +1,35 @@ +resume(); + } +} diff --git a/backend/app/Model/Model.php b/backend/app/Model/Model.php new file mode 100644 index 0000000..6fc31f1 --- /dev/null +++ b/backend/app/Model/Model.php @@ -0,0 +1,19 @@ +get(Hyperf\Contract\ApplicationInterface::class); + $application->run(); +})(); diff --git a/backend/composer.json b/backend/composer.json new file mode 100644 index 0000000..713c6b7 --- /dev/null +++ b/backend/composer.json @@ -0,0 +1,77 @@ +{ + "name": "hyperf/hyperf-skeleton", + "type": "project", + "keywords": [ + "php", + "swoole", + "framework", + "hyperf", + "microservice", + "middleware" + ], + "description": "A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.", + "license": "Apache-2.0", + "require": { + "php": ">=8.1", + "hyperf/cache": "~3.1.0", + "hyperf/command": "~3.1.0", + "hyperf/config": "~3.1.0", + "hyperf/db-connection": "~3.1.0", + "hyperf/engine": "^2.10", + "hyperf/framework": "~3.1.0", + "hyperf/guzzle": "~3.1.0", + "hyperf/http-server": "~3.1.0", + "hyperf/logger": "~3.1.0", + "hyperf/memory": "~3.1.0", + "hyperf/process": "~3.1.0", + "hyperf/constants": "~3.1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.0", + "hyperf/devtool": "~3.1.0", + "hyperf/testing": "~3.1.0", + "mockery/mockery": "^1.0", + "phpstan/phpstan": "^1.0", + "swoole/ide-helper": "^5.0" + }, + "suggest": { + "ext-openssl": "Required to use HTTPS.", + "ext-json": "Required to use JSON.", + "ext-pdo": "Required to use MySQL Client.", + "ext-pdo_mysql": "Required to use MySQL Client.", + "ext-redis": "Required to use Redis Client." + }, + "autoload": { + "psr-4": { + "App\\": "app/" + }, + "files": [] + }, + "autoload-dev": { + "psr-4": { + "HyperfTest\\": "./test/" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "optimize-autoloader": true, + "sort-packages": true + }, + "extra": [], + "scripts": { + "post-root-package-install": [ + "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" + ], + "post-autoload-dump": [ + "rm -rf runtime/container" + ], + "test": "co-phpunit --prepend test/bootstrap.php --colors=always", + "cs-fix": "php-cs-fixer fix $1", + "analyse": "phpstan analyse --memory-limit 300M", + "start": [ + "Composer\\Config::disableProcessTimeout", + "php ./bin/hyperf.php start" + ] + } +} diff --git a/backend/config/autoload/annotations.php b/backend/config/autoload/annotations.php new file mode 100644 index 0000000..1423a25 --- /dev/null +++ b/backend/config/autoload/annotations.php @@ -0,0 +1,21 @@ + [ + 'paths' => [ + BASE_PATH . '/app', + ], + 'ignore_annotations' => [ + 'mixin', + ], + ], +]; diff --git a/backend/config/autoload/aspects.php b/backend/config/autoload/aspects.php new file mode 100644 index 0000000..f46bd96 --- /dev/null +++ b/backend/config/autoload/aspects.php @@ -0,0 +1,13 @@ + [ + 'driver' => Hyperf\Cache\Driver\RedisDriver::class, + 'packer' => Hyperf\Codec\Packer\PhpSerializerPacker::class, + 'prefix' => 'c:', + 'skip_cache_results' => [], + ], +]; diff --git a/backend/config/autoload/commands.php b/backend/config/autoload/commands.php new file mode 100644 index 0000000..f46bd96 --- /dev/null +++ b/backend/config/autoload/commands.php @@ -0,0 +1,13 @@ + [ + 'driver' => env('DB_DRIVER', 'mysql'), + 'host' => env('DB_HOST', 'localhost'), + 'database' => env('DB_DATABASE', 'hyperf'), + 'port' => env('DB_PORT', 3306), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => env('DB_CHARSET', 'utf8'), + 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'), + 'prefix' => env('DB_PREFIX', ''), + 'pool' => [ + 'min_connections' => 1, + 'max_connections' => 10, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60), + ], + 'commands' => [ + 'gen:model' => [ + 'path' => 'app/Model', + 'force_casts' => true, + 'inheritance' => 'Model', + ], + ], + ], +]; diff --git a/backend/config/autoload/dependencies.php b/backend/config/autoload/dependencies.php new file mode 100644 index 0000000..f46bd96 --- /dev/null +++ b/backend/config/autoload/dependencies.php @@ -0,0 +1,13 @@ + [ + 'amqp' => [ + 'consumer' => [ + 'namespace' => 'App\\Amqp\\Consumer', + ], + 'producer' => [ + 'namespace' => 'App\\Amqp\\Producer', + ], + ], + 'aspect' => [ + 'namespace' => 'App\\Aspect', + ], + 'command' => [ + 'namespace' => 'App\\Command', + ], + 'controller' => [ + 'namespace' => 'App\\Controller', + ], + 'job' => [ + 'namespace' => 'App\\Job', + ], + 'listener' => [ + 'namespace' => 'App\\Listener', + ], + 'middleware' => [ + 'namespace' => 'App\\Middleware', + ], + 'Process' => [ + 'namespace' => 'App\\Processes', + ], + ], +]; diff --git a/backend/config/autoload/exceptions.php b/backend/config/autoload/exceptions.php new file mode 100644 index 0000000..b848177 --- /dev/null +++ b/backend/config/autoload/exceptions.php @@ -0,0 +1,19 @@ + [ + 'http' => [ + Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, + App\Exception\Handler\AppExceptionHandler::class, + ], + ], +]; diff --git a/backend/config/autoload/listeners.php b/backend/config/autoload/listeners.php new file mode 100644 index 0000000..8a2c7a2 --- /dev/null +++ b/backend/config/autoload/listeners.php @@ -0,0 +1,15 @@ + [ + 'handler' => [ + 'class' => Monolog\Handler\StreamHandler::class, + 'constructor' => [ + 'stream' => BASE_PATH . '/runtime/logs/hyperf.log', + 'level' => Monolog\Logger::DEBUG, + ], + ], + 'formatter' => [ + 'class' => Monolog\Formatter\LineFormatter::class, + 'constructor' => [ + 'format' => null, + 'dateFormat' => 'Y-m-d H:i:s', + 'allowInlineLineBreaks' => true, + ], + ], + ], +]; diff --git a/backend/config/autoload/middlewares.php b/backend/config/autoload/middlewares.php new file mode 100644 index 0000000..49bdec2 --- /dev/null +++ b/backend/config/autoload/middlewares.php @@ -0,0 +1,15 @@ + [ + ], +]; diff --git a/backend/config/autoload/processes.php b/backend/config/autoload/processes.php new file mode 100644 index 0000000..f46bd96 --- /dev/null +++ b/backend/config/autoload/processes.php @@ -0,0 +1,13 @@ + SWOOLE_PROCESS, + 'servers' => [ + [ + 'name' => 'http', + 'type' => Server::SERVER_HTTP, + 'host' => '0.0.0.0', + 'port' => 9501, + 'sock_type' => SWOOLE_SOCK_TCP, + 'callbacks' => [ + Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], + ], + 'options' => [ + // Whether to enable request lifecycle event + 'enable_request_lifecycle' => false, + ], + ], + ], + 'settings' => [ + Constant::OPTION_ENABLE_COROUTINE => true, + Constant::OPTION_WORKER_NUM => swoole_cpu_num(), + Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid', + Constant::OPTION_OPEN_TCP_NODELAY => true, + Constant::OPTION_MAX_COROUTINE => 100000, + Constant::OPTION_OPEN_HTTP2_PROTOCOL => true, + Constant::OPTION_MAX_REQUEST => 100000, + Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024, + Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, + ], + 'callbacks' => [ + Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], + Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], + Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], + ], +]; diff --git a/backend/config/config.php b/backend/config/config.php new file mode 100644 index 0000000..418135e --- /dev/null +++ b/backend/config/config.php @@ -0,0 +1,33 @@ + env('APP_NAME', 'skeleton'), + 'app_env' => env('APP_ENV', 'dev'), + 'scan_cacheable' => env('SCAN_CACHEABLE', false), + StdoutLoggerInterface::class => [ + 'log_level' => [ + LogLevel::ALERT, + LogLevel::CRITICAL, + LogLevel::DEBUG, + LogLevel::EMERGENCY, + LogLevel::ERROR, + LogLevel::INFO, + LogLevel::NOTICE, + LogLevel::WARNING, + ], + ], +]; diff --git a/backend/config/container.php b/backend/config/container.php new file mode 100644 index 0000000..c82a0e8 --- /dev/null +++ b/backend/config/container.php @@ -0,0 +1,21 @@ + + + + + ./test + + + + + + + + ./app + + + diff --git a/backend/test/Cases/ExampleTest.php b/backend/test/Cases/ExampleTest.php new file mode 100644 index 0000000..789ff67 --- /dev/null +++ b/backend/test/Cases/ExampleTest.php @@ -0,0 +1,27 @@ +get('/')->assertOk()->assertSee('Hyperf'); + } +} diff --git a/backend/test/HttpTestCase.php b/backend/test/HttpTestCase.php new file mode 100644 index 0000000..da07e66 --- /dev/null +++ b/backend/test/HttpTestCase.php @@ -0,0 +1,45 @@ +client = make(Client::class); + } + + public function __call($name, $arguments) + { + return $this->client->{$name}(...$arguments); + } +} diff --git a/backend/test/bootstrap.php b/backend/test/bootstrap.php new file mode 100644 index 0000000..818d1d8 --- /dev/null +++ b/backend/test/bootstrap.php @@ -0,0 +1,30 @@ +get(Hyperf\Contract\ApplicationInterface::class); diff --git a/frontend/.editorconfig b/frontend/.editorconfig new file mode 100644 index 0000000..3b510aa --- /dev/null +++ b/frontend/.editorconfig @@ -0,0 +1,8 @@ +[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,css,scss,sass,less,styl}] +charset = utf-8 +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +max_line_length = 100 diff --git a/frontend/.gitattributes b/frontend/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/frontend/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..7414e0e --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,39 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +*.tsbuildinfo + +.eslintcache + +# Cypress +/cypress/videos/ +/cypress/screenshots/ + +# Vitest +__screenshots__/ + +test-results/ +playwright-report/ diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json new file mode 100644 index 0000000..29a2402 --- /dev/null +++ b/frontend/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://json.schemastore.org/prettierrc", + "semi": false, + "singleQuote": true, + "printWidth": 100 +} diff --git a/frontend/.vscode/extensions.json b/frontend/.vscode/extensions.json new file mode 100644 index 0000000..0777b2e --- /dev/null +++ b/frontend/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "Vue.volar", + "vitest.explorer", + "ms-playwright.playwright", + "dbaeumer.vscode-eslint", + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode" + ] +} diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..e359651 --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,73 @@ +# . + +This template should help get you started developing with Vue 3 in Vite. + +## Recommended IDE Setup + +[VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur). + +## Recommended Browser Setup + +- Chromium-based browsers (Chrome, Edge, Brave, etc.): + - [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd) + - [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters) +- Firefox: + - [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/) + - [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/) + +## Type Support for `.vue` Imports in TS + +TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types. + +## Customize configuration + +See [Vite Configuration Reference](https://vite.dev/config/). + +## Project Setup + +```sh +npm install +``` + +### Compile and Hot-Reload for Development + +```sh +npm run dev +``` + +### Type-Check, Compile and Minify for Production + +```sh +npm run build +``` + +### Run Unit Tests with [Vitest](https://vitest.dev/) + +```sh +npm run test:unit +``` + +### Run End-to-End Tests with [Playwright](https://playwright.dev) + +```sh +# Install browsers for the first run +npx playwright install + +# When testing on CI, must build the project first +npm run build + +# Runs the end-to-end tests +npm run test:e2e +# Runs the tests only on Chromium +npm run test:e2e -- --project=chromium +# Runs the tests of a specific file +npm run test:e2e -- tests/example.spec.ts +# Runs the tests in debug mode +npm run test:e2e -- --debug +``` + +### Lint with [ESLint](https://eslint.org/) + +```sh +npm run lint +``` diff --git a/frontend/e2e/tsconfig.json b/frontend/e2e/tsconfig.json new file mode 100644 index 0000000..f31fe71 --- /dev/null +++ b/frontend/e2e/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@tsconfig/node22/tsconfig.json", + "include": ["./**/*"] +} diff --git a/frontend/e2e/vue.spec.ts b/frontend/e2e/vue.spec.ts new file mode 100644 index 0000000..fc116a9 --- /dev/null +++ b/frontend/e2e/vue.spec.ts @@ -0,0 +1,8 @@ +import { test, expect } from '@playwright/test'; + +// See here how to get started: +// https://playwright.dev/docs/intro +test('visits the app root url', async ({ page }) => { + await page.goto('/'); + await expect(page.locator('h1')).toHaveText('You did it!'); +}) diff --git a/frontend/env.d.ts b/frontend/env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/frontend/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/frontend/eslint.config.ts b/frontend/eslint.config.ts new file mode 100644 index 0000000..0a90260 --- /dev/null +++ b/frontend/eslint.config.ts @@ -0,0 +1,34 @@ +import { globalIgnores } from 'eslint/config' +import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript' +import pluginVue from 'eslint-plugin-vue' +import pluginVitest from '@vitest/eslint-plugin' +import pluginPlaywright from 'eslint-plugin-playwright' +import skipFormatting from '@vue/eslint-config-prettier/skip-formatting' + +// To allow more languages other than `ts` in `.vue` files, uncomment the following lines: +// import { configureVueProject } from '@vue/eslint-config-typescript' +// configureVueProject({ scriptLangs: ['ts', 'tsx'] }) +// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup + +export default defineConfigWithVueTs( + { + name: 'app/files-to-lint', + files: ['**/*.{ts,mts,tsx,vue}'], + }, + + globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']), + + pluginVue.configs['flat/essential'], + vueTsConfigs.recommended, + + { + ...pluginVitest.configs.recommended, + files: ['src/**/__tests__/*'], + }, + + { + ...pluginPlaywright.configs['flat/recommended'], + files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'], + }, + skipFormatting, +) diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..9e5fc8f --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..8ce5afd --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,53 @@ +{ + "name": "dataflow-frontend", + "version": "0.0.0", + "private": true, + "type": "module", + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "scripts": { + "dev": "vite", + "build": "run-p type-check \"build-only {@}\" --", + "preview": "vite preview", + "test:unit": "vitest", + "test:e2e": "playwright test", + "build-only": "vite build", + "type-check": "vue-tsc --build", + "lint": "eslint . --fix --cache", + "format": "prettier --write src/" + }, + "dependencies": { + "@tailwindcss/vite": "^4.1.16", + "ant-design-vue": "^4.2.6", + "pinia": "^3.0.3", + "tailwindcss": "^4.1.16", + "vue": "^3.5.22", + "vue-router": "^4.6.3" + }, + "devDependencies": { + "@playwright/test": "^1.56.1", + "@tsconfig/node22": "^22.0.2", + "@types/jsdom": "^27.0.0", + "@types/node": "^22.18.11", + "@vitejs/plugin-vue": "^6.0.1", + "@vitejs/plugin-vue-jsx": "^5.1.1", + "@vitest/eslint-plugin": "^1.3.23", + "@vue/eslint-config-prettier": "^10.2.0", + "@vue/eslint-config-typescript": "^14.6.0", + "@vue/test-utils": "^2.4.6", + "@vue/tsconfig": "^0.8.1", + "eslint": "^9.37.0", + "eslint-plugin-playwright": "^2.2.2", + "eslint-plugin-vue": "~10.5.0", + "jiti": "^2.6.1", + "jsdom": "^27.0.1", + "npm-run-all2": "^8.0.4", + "prettier": "3.6.2", + "typescript": "~5.9.0", + "vite": "^7.1.11", + "vite-plugin-vue-devtools": "^8.0.3", + "vitest": "^3.2.4", + "vue-tsc": "^3.1.1" + } +} diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts new file mode 100644 index 0000000..5ece956 --- /dev/null +++ b/frontend/playwright.config.ts @@ -0,0 +1,110 @@ +import process from 'node:process' +import { defineConfig, devices } from '@playwright/test' + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './e2e', + /* Maximum time one test can run for. */ + timeout: 30 * 1000, + expect: { + /** + * Maximum time expect() should wait for the condition to be met. + * For example in `await expect(locator).toHaveText();` + */ + timeout: 5000, + }, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ + actionTimeout: 0, + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: process.env.CI ? 'http://localhost:4173' : 'http://localhost:5173', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + + /* Only on CI systems run the tests headless */ + headless: !!process.env.CI, + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { + ...devices['Desktop Chrome'], + }, + }, + { + name: 'firefox', + use: { + ...devices['Desktop Firefox'], + }, + }, + { + name: 'webkit', + use: { + ...devices['Desktop Safari'], + }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { + // ...devices['Pixel 5'], + // }, + // }, + // { + // name: 'Mobile Safari', + // use: { + // ...devices['iPhone 12'], + // }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { + // channel: 'msedge', + // }, + // }, + // { + // name: 'Google Chrome', + // use: { + // channel: 'chrome', + // }, + // }, + ], + + /* Folder for test artifacts such as screenshots, videos, traces, etc. */ + // outputDir: 'test-results/', + + /* Run your local dev server before starting the tests */ + webServer: { + /** + * Use the dev server by default for faster feedback loop. + * Use the preview server on CI for more realistic testing. + * Playwright will re-use the local server if there is already a dev-server running. + */ + command: process.env.CI ? 'npm run preview' : 'npm run dev', + port: process.env.CI ? 4173 : 5173, + reuseExistingServer: !process.env.CI, + }, +}) diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/frontend/src/App.vue b/frontend/src/App.vue new file mode 100644 index 0000000..7905b05 --- /dev/null +++ b/frontend/src/App.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/frontend/src/assets/base.css b/frontend/src/assets/base.css new file mode 100644 index 0000000..8816868 --- /dev/null +++ b/frontend/src/assets/base.css @@ -0,0 +1,86 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); + } +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: + color 0.5s, + background-color 0.5s; + line-height: 1.6; + font-family: + Inter, + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + Roboto, + Oxygen, + Ubuntu, + Cantarell, + 'Fira Sans', + 'Droid Sans', + 'Helvetica Neue', + sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/frontend/src/assets/logo.svg b/frontend/src/assets/logo.svg new file mode 100644 index 0000000..7565660 --- /dev/null +++ b/frontend/src/assets/logo.svg @@ -0,0 +1 @@ + diff --git a/frontend/src/assets/main.css b/frontend/src/assets/main.css new file mode 100644 index 0000000..db82133 --- /dev/null +++ b/frontend/src/assets/main.css @@ -0,0 +1,36 @@ +@import './base.css'; +@import 'tailwindcss'; + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + font-weight: normal; +} + +a, +.green { + text-decoration: none; + color: hsla(160, 100%, 37%, 1); + transition: 0.4s; + padding: 3px; +} + +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } +} + +@media (min-width: 1024px) { + body { + display: flex; + place-items: center; + } + + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } +} diff --git a/frontend/src/components/HelloWorld.vue b/frontend/src/components/HelloWorld.vue new file mode 100644 index 0000000..d174cf8 --- /dev/null +++ b/frontend/src/components/HelloWorld.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/frontend/src/components/TheWelcome.vue b/frontend/src/components/TheWelcome.vue new file mode 100644 index 0000000..8b731d9 --- /dev/null +++ b/frontend/src/components/TheWelcome.vue @@ -0,0 +1,95 @@ + + + diff --git a/frontend/src/components/WelcomeItem.vue b/frontend/src/components/WelcomeItem.vue new file mode 100644 index 0000000..6d7086a --- /dev/null +++ b/frontend/src/components/WelcomeItem.vue @@ -0,0 +1,87 @@ + + + diff --git a/frontend/src/components/__tests__/HelloWorld.spec.ts b/frontend/src/components/__tests__/HelloWorld.spec.ts new file mode 100644 index 0000000..2533202 --- /dev/null +++ b/frontend/src/components/__tests__/HelloWorld.spec.ts @@ -0,0 +1,11 @@ +import { describe, it, expect } from 'vitest' + +import { mount } from '@vue/test-utils' +import HelloWorld from '../HelloWorld.vue' + +describe('HelloWorld', () => { + it('renders properly', () => { + const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } }) + expect(wrapper.text()).toContain('Hello Vitest') + }) +}) diff --git a/frontend/src/components/icons/IconCommunity.vue b/frontend/src/components/icons/IconCommunity.vue new file mode 100644 index 0000000..2dc8b05 --- /dev/null +++ b/frontend/src/components/icons/IconCommunity.vue @@ -0,0 +1,7 @@ + diff --git a/frontend/src/components/icons/IconDocumentation.vue b/frontend/src/components/icons/IconDocumentation.vue new file mode 100644 index 0000000..6d4791c --- /dev/null +++ b/frontend/src/components/icons/IconDocumentation.vue @@ -0,0 +1,7 @@ + diff --git a/frontend/src/components/icons/IconEcosystem.vue b/frontend/src/components/icons/IconEcosystem.vue new file mode 100644 index 0000000..c3a4f07 --- /dev/null +++ b/frontend/src/components/icons/IconEcosystem.vue @@ -0,0 +1,7 @@ + diff --git a/frontend/src/components/icons/IconSupport.vue b/frontend/src/components/icons/IconSupport.vue new file mode 100644 index 0000000..7452834 --- /dev/null +++ b/frontend/src/components/icons/IconSupport.vue @@ -0,0 +1,7 @@ + diff --git a/frontend/src/components/icons/IconTooling.vue b/frontend/src/components/icons/IconTooling.vue new file mode 100644 index 0000000..660598d --- /dev/null +++ b/frontend/src/components/icons/IconTooling.vue @@ -0,0 +1,19 @@ + + diff --git a/frontend/src/main.ts b/frontend/src/main.ts new file mode 100644 index 0000000..5dcad83 --- /dev/null +++ b/frontend/src/main.ts @@ -0,0 +1,14 @@ +import './assets/main.css' + +import { createApp } from 'vue' +import { createPinia } from 'pinia' + +import App from './App.vue' +import router from './router' + +const app = createApp(App) + +app.use(createPinia()) +app.use(router) + +app.mount('#app') diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts new file mode 100644 index 0000000..3e49915 --- /dev/null +++ b/frontend/src/router/index.ts @@ -0,0 +1,23 @@ +import { createRouter, createWebHistory } from 'vue-router' +import HomeView from '../views/HomeView.vue' + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes: [ + { + path: '/', + name: 'home', + component: HomeView, + }, + { + path: '/about', + name: 'about', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/AboutView.vue'), + }, + ], +}) + +export default router diff --git a/frontend/src/stores/counter.ts b/frontend/src/stores/counter.ts new file mode 100644 index 0000000..b6757ba --- /dev/null +++ b/frontend/src/stores/counter.ts @@ -0,0 +1,12 @@ +import { ref, computed } from 'vue' +import { defineStore } from 'pinia' + +export const useCounterStore = defineStore('counter', () => { + const count = ref(0) + const doubleCount = computed(() => count.value * 2) + function increment() { + count.value++ + } + + return { count, doubleCount, increment } +}) diff --git a/frontend/src/views/AboutView.vue b/frontend/src/views/AboutView.vue new file mode 100644 index 0000000..756ad2a --- /dev/null +++ b/frontend/src/views/AboutView.vue @@ -0,0 +1,15 @@ + + + diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue new file mode 100644 index 0000000..d5c0217 --- /dev/null +++ b/frontend/src/views/HomeView.vue @@ -0,0 +1,9 @@ + + + diff --git a/frontend/tsconfig.app.json b/frontend/tsconfig.app.json new file mode 100644 index 0000000..913b8f2 --- /dev/null +++ b/frontend/tsconfig.app.json @@ -0,0 +1,12 @@ +{ + "extends": "@vue/tsconfig/tsconfig.dom.json", + "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], + "exclude": ["src/**/__tests__/*"], + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + + "paths": { + "@/*": ["./src/*"] + } + } +} diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json new file mode 100644 index 0000000..100cf6a --- /dev/null +++ b/frontend/tsconfig.json @@ -0,0 +1,14 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.node.json" + }, + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.vitest.json" + } + ] +} diff --git a/frontend/tsconfig.node.json b/frontend/tsconfig.node.json new file mode 100644 index 0000000..a83dfc9 --- /dev/null +++ b/frontend/tsconfig.node.json @@ -0,0 +1,19 @@ +{ + "extends": "@tsconfig/node22/tsconfig.json", + "include": [ + "vite.config.*", + "vitest.config.*", + "cypress.config.*", + "nightwatch.conf.*", + "playwright.config.*", + "eslint.config.*" + ], + "compilerOptions": { + "noEmit": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + + "module": "ESNext", + "moduleResolution": "Bundler", + "types": ["node"] + } +} diff --git a/frontend/tsconfig.vitest.json b/frontend/tsconfig.vitest.json new file mode 100644 index 0000000..7d1d8ce --- /dev/null +++ b/frontend/tsconfig.vitest.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.app.json", + "include": ["src/**/__tests__/*", "env.d.ts"], + "exclude": [], + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo", + + "lib": [], + "types": ["node", "jsdom"] + } +} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts new file mode 100644 index 0000000..e4ae87c --- /dev/null +++ b/frontend/vite.config.ts @@ -0,0 +1,22 @@ +import { fileURLToPath, URL } from 'node:url' + +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' +import vueDevTools from 'vite-plugin-vue-devtools' +import tailwindcss from '@tailwindcss/vite' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [ + vue(), + vueJsx(), + vueDevTools(), + tailwindcss(), + ], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)) + }, + }, +}) diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts new file mode 100644 index 0000000..c328717 --- /dev/null +++ b/frontend/vitest.config.ts @@ -0,0 +1,14 @@ +import { fileURLToPath } from 'node:url' +import { mergeConfig, defineConfig, configDefaults } from 'vitest/config' +import viteConfig from './vite.config' + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + environment: 'jsdom', + exclude: [...configDefaults.exclude, 'e2e/**'], + root: fileURLToPath(new URL('./', import.meta.url)), + }, + }), +) diff --git a/gitignore.example b/gitignore.example new file mode 100644 index 0000000..c3b3bbf --- /dev/null +++ b/gitignore.example @@ -0,0 +1,182 @@ +# ============================================ +# 前后端分离项目 .gitignore 示例文件 +# 后端:Hyperf 3.1 | 前端:Vite + Vue3 + AntDV 4 +# ============================================ + +# ==================== 后端 (Hyperf/PHP) ==================== +backend/vendor/ +backend/runtime/ +backend/.env +backend/.phpintel/ +backend/*.cache +backend/.phpunit* +backend/phpstan.neon +backend/phpunit.xml +backend/.php_cs.cache +backend/.php-cs-fixer.cache +backend/composer.lock + +# ==================== 前端 (Vue3/Vite) ==================== +frontend/node_modules/ +frontend/dist/ +frontend/dist-ssr/ +frontend/.DS_Store +frontend/coverage/ +frontend/*.local +frontend/.eslintcache +frontend/*.tsbuildinfo +frontend/package-lock.json +frontend/pnpm-lock.yaml +frontend/yarn.lock + +# 前端日志文件 +frontend/logs/ +frontend/*.log +frontend/npm-debug.log* +frontend/yarn-debug.log* +frontend/yarn-error.log* +frontend/pnpm-debug.log* +frontend/lerna-debug.log* + +# 前端测试相关 +frontend/test-results/ +frontend/playwright-report/ +frontend/__screenshots__/ +frontend/cypress/videos/ +frontend/cypress/screenshots/ + +# ==================== 数据目录 ==================== +# 数据库文件 +data/*.db +data/*.sqlite +data/*.sqlite3 + +# 临时数据文件 +data/*.tmp +data/*.temp +data/*.bak +data/*.backup + +# 数据导出文件 +data/exports/ +data/cache/ +data/logs/ + +# ==================== 文档目录 ==================== +# 文档生成文件 +docs/.vuepress/dist/ +docs/.vuepress/.cache/ +docs/.vuepress/.temp/ +docs/node_modules/ + +# 文档草稿 +docs/*.draft.md +docs/*.wip.md + +# ==================== IDE & 编辑器 ==================== +# VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# JetBrains IDEs (PhpStorm, WebStorm, IntelliJ) +.idea/ +*.iml +*.iws +*.ipr +.idea_modules/ + +# Eclipse +.buildpath +.project +.settings/ + +# Sublime Text +*.sublime-project +*.sublime-workspace + +# Vim +*.swp +*.swo +*~ +.*.sw? + +# ==================== 操作系统 ==================== +# macOS +.DS_Store +.AppleDouble +.LSOverride +._* +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Windows +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +Desktop.ini +$RECYCLE.BIN/ +*.lnk + +# Linux +.directory +.Trash-* +.nfs* + +# ==================== 环境配置 ==================== +# 环境变量文件 +.env +.env.local +.env.*.local +.env.development +.env.production +.env.staging + +# ==================== Docker ==================== +docker-compose.override.yml +.dockerignore + +# ==================== 版本控制 ==================== +*.patch +*.diff + +# ==================== 临时文件 ==================== +*.tmp +*.temp +*.log +*.bak +*.swp +*.swo +*~ + +# ==================== 依赖锁文件(可选)==================== +# 如果团队使用统一的包管理器,可以取消注释以下行 +# composer.lock +# package-lock.json +# yarn.lock +# pnpm-lock.yaml + +# ==================== 构建产物 ==================== +build/ +dist/ +out/ + +# ==================== 其他 ==================== +# 调试文件 +*.map +*.orig + +# 压缩文件 +*.zip +*.tar.gz +*.rar +*.7z