Skip to content

'bugFix'#200

Open
UCTooCom wants to merge 1 commit intoopentiny:devfrom
UCTooCom:fix/dependency-and-config-issues
Open

'bugFix'#200
UCTooCom wants to merge 1 commit intoopentiny:devfrom
UCTooCom:fix/dependency-and-config-issues

Conversation

@UCTooCom
Copy link
Copy Markdown

@UCTooCom UCTooCom commented Mar 27, 2026

Fix: 依赖版本冲突和配置问题修复

问题描述

在本地开发环境启动 TinyPro 项目时遇到多个依赖版本冲突和配置问题,导致前后端无法正常运行。

修复内容

1. 依赖版本冲突修复

后端 (template/nestJs)

  • ESLint 版本冲突: 8.42.08.57.0
    • 原因:与 @typescript-eslint/eslint-plugin 7.18.0 版本不兼容
    • 修复:更新 eslint 到兼容版本

前端 (template/tinyvue)

  • @opentiny/vue-theme 版本不匹配: 3.28.03.29.0
    • 原因:与 @opentiny/vue 3.29.0 版本不匹配
    • 修复:更新 vue-theme 到匹配版本

2. 后端配置问题修复

.env 文件格式

  • 移除配置值中的空格和引号
  • 添加缺失的配置项:
    • REFRESH_TOKEN_TTL
    • DEVICE_LIMIT
    • CORS_ORIGIN

JWT Token 配置

  • 修复 ACCESS_TOKEN_VALIDITY_SEC 配置错误
  • 确保 token 过期时间设置正确

3. 前端配置问题修复

.env 文件格式

  • 移除配置值中的空格

Vite 代理配置

  • 移除错误的路径重写配置
  • 确保 API 代理正确转发请求

修改文件

  • template/nestJs/package.json - 更新 eslint 版本
  • template/nestJs/src/generateMigration.ts - 修复生成迁移脚本
  • template/tinyvue/.env - 修复环境变量格式
  • template/tinyvue/config/vite.config.dev.ts - 移除错误的代理配置
  • template/tinyvue/package.json - 更新 vue-theme 版本

测试验证

✅ 后端服务正常运行 (http://localhost:3000)
✅ 前端服务正常运行 (http://localhost:3031)
✅ API 代理正确转发请求
✅ 登录功能完全正常

相关 Issue

修复本地开发环境启动失败的问题

类型

  • Bug 修复
  • 新功能
  • 破坏性变更
  • 文档更新

Checklist

  • 代码遵循项目的编码规范
  • 已进行自测
  • 修改不会引入新的问题
  • 文档已更新(如需要)

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated ESLint to version 8.57.0.
    • Updated Vue theme package to version 3.29.0.
  • Bug Fixes

    • Fixed environment variable parsing by removing unexpected whitespace.
    • Fixed API proxy configuration to correctly forward requests to the server.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Walkthrough

This PR updates dependencies (ESLint, Vue theme), normalizes environment variable formatting in the TinyVue template, removes a proxy rewrite function from Vite configuration, and adds async handling to Prettier formatting in the NestJS migration generator.

Changes

Cohort / File(s) Summary
NestJS Template
template/nestJs/package.json, template/nestJs/src/generateMigration.ts
ESLint devDependency updated from 8.42.0 to 8.57.0; prettier.format() call now awaited for async operation handling.
TinyVue Configuration
template/tinyvue/config/vite.config.dev.ts, template/tinyvue/.env
Removed proxy rewrite function that stripped VITE_BASE_API prefix; normalized whitespace in environment variable values (VITE_SERVER_HOST, VITE_MOCK_HOST, VITE_USE_MOCK, VITE_MOCK_IGNORE).
TinyVue Dependencies
template/tinyvue/package.json
Updated @opentiny/vue-theme version from ~3.28.0 to ~3.29.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hops with glee through template lands,
ESLint freshened, code so clean,
Prettier awaits with gentle hands,
Vite's proxy trimmed, a smoother scene,
Vue theme gleams, version new—
All templates blessed, I hop to you!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'bugFix' is vague and generic, failing to convey the specific nature of the changes or which issues are being addressed. Provide a more descriptive title that indicates the primary changes, such as 'Fix dependency versions and environment configuration issues' or 'Resolve ESLint, theme, and Vite proxy configuration'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
template/tinyvue/package.json (1)

39-39: Align OpenTiny package versions to prevent minor-version skew.

The current mix of @opentiny/vue (^3.28.0), the ~3.28.0 packages, and @opentiny/vue-theme (~3.29.0) can result in different minor versions across the same package family on fresh installs. Consider aligning all OpenTiny packages to consistent minor versions (either all ~3.28.0 or all ~3.29.0) to avoid potential compatibility issues.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@template/tinyvue/package.json` at line 39, Update the OpenTiny dependency
versions so they are all on the same minor release to avoid skew; specifically
change "@opentiny/vue-theme" (currently "~3.29.0") to match the other OpenTiny
packages (e.g., use "~3.28.0" if other entries like "@opentiny/vue" are
"^3.28.0", or else align all to "~3.29.0"), ensuring the package.json entries
for "@opentiny/vue", "@opentiny/vue-theme" and any other "@opentiny/*" packages
share the same minor version pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@template/tinyvue/.env`:
- Line 5: The consumer code in login-info.vue misinterprets
import.meta.env.VITE_USE_MOCK (a string per env.d.ts) as a boolean; update the
logic to explicitly parse the string (e.g., compute a boolean like useMock =
import.meta.env.VITE_USE_MOCK === 'true') and then use that boolean in the
existing condition and any downstream branches so "false" no longer evaluates as
truthy.

---

Nitpick comments:
In `@template/tinyvue/package.json`:
- Line 39: Update the OpenTiny dependency versions so they are all on the same
minor release to avoid skew; specifically change "@opentiny/vue-theme"
(currently "~3.29.0") to match the other OpenTiny packages (e.g., use "~3.28.0"
if other entries like "@opentiny/vue" are "^3.28.0", or else align all to
"~3.29.0"), ensuring the package.json entries for "@opentiny/vue",
"@opentiny/vue-theme" and any other "@opentiny/*" packages share the same minor
version pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7ec6cec5-8148-40fb-af16-93120b46def8

📥 Commits

Reviewing files that changed from the base of the PR and between a059fef and 36f8648.

📒 Files selected for processing (5)
  • template/nestJs/package.json
  • template/nestJs/src/generateMigration.ts
  • template/tinyvue/.env
  • template/tinyvue/config/vite.config.dev.ts
  • template/tinyvue/package.json
💤 Files with no reviewable changes (1)
  • template/tinyvue/config/vite.config.dev.ts

VITE_MOCK_IGNORE= /api/user/userInfo,/api/user/login,/api/user/register,/api/employee/getEmployee
VITE_SERVER_HOST=http://127.0.0.1:3000
VITE_MOCK_HOST=http://127.0.0.1:8848
VITE_USE_MOCK=false
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all usages and check whether env string is explicitly compared/parsing to boolean.
rg -n -C2 'VITE_USE_MOCK' template/tinyvue/src

Repository: opentiny/tiny-pro

Length of output: 1873


VITE_USE_MOCK=false is a string, not a boolean—the consumer code at line 61 of login-info.vue will not work as intended.

The condition if (!import.meta.env.VITE_USE_MOCK) treats the string "false" as truthy, causing the logic to invert. When this environment variable is set to "false", the condition evaluates to false, and the intended mock-disabled behavior does not execute.

The type declaration at env.d.ts line 20 confirms VITE_USE_MOCK: string, yet the documentation claims it is a Boolean. Fix the consumer code to explicitly parse the string: const useMock = import.meta.env.VITE_USE_MOCK === 'true'.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@template/tinyvue/.env` at line 5, The consumer code in login-info.vue
misinterprets import.meta.env.VITE_USE_MOCK (a string per env.d.ts) as a
boolean; update the logic to explicitly parse the string (e.g., compute a
boolean like useMock = import.meta.env.VITE_USE_MOCK === 'true') and then use
that boolean in the existing condition and any downstream branches so "false" no
longer evaluates as truthy.

@kagol kagol requested a review from GaoNeng-wWw March 30, 2026 03:39
Comment on lines -20 to -24
rewrite: (path: string) =>
path.replace(
new RegExp(`${env.VITE_BASE_API}`),
'',
),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边不rewrite的话,发送的就是 /api/xxx 了. 但后端没有 /api 前缀

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry,这是我项目中定制的一个业务逻辑,因为我的后端服务有/api前缀,这个修改不应该带入到tiny-pro的版本中

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry,这是我项目中定制的一个业务逻辑,因为我的后端服务有/api前缀,这个修改不应该带入到tiny-pro的版本中

嗯嗯,由时间的话可以提交一个commit~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants