Commit fc688d3d by liimin

docs(repo): 添加协作约定并更新质量检查配置

- 新增 AGENTS.md 文件定义仓库协作约定和工作规则
- 添加防御性检查工作流 defense.yml 包含 lint/type/contract 等检查
- 更新 prettierignore 和 stylelintignore 配置忽略特定目录
- 在 package.json 中新增多个质量检查脚本命令
- 配置 lefthook pre-push 钩子执行智能检查
- 更新 eslint 配置忽略 uniappX 目录的存量问题
- 优化多个 uniappX 项目的代码格式和配置文件
- 调整 github actions codeql 工作流配置简化语言检测
1 parent 058d6dae
Showing 118 changed files with 2091 additions and 1431 deletions
# 对于大多数项目而言,此工作流文件无需修改,你只需将其提交至代码仓库即可。
# 你也可以根据需要修改此文件,以此覆盖默认的待分析语言集合,或配置自定义查询语句、构建逻辑。
# ******** 注意事项 ********
# 我们已尝试自动检测你代码仓库中的开发语言。请务必检查下方定义的 language 矩阵,确认其包含的 CodeQL 支持语言集准确无误。
# 使用 GitHub CodeQL 对代码进行静态安全分析。
# 当前仓库以 JavaScript / TypeScript 为主,因此只启用 `javascript-typescript`。
# 使用 GitHub CodeQL 对代码进行静态安全分析,检测潜在的代码漏洞和安全问题。
name: CodeQL
name: "CodeQL"
# 触发条件:
# 推送到 main 分支
# PR 到 main 分支
# 每周日午夜定时运行(0 35 * * 0)
on:
push:
branches: ["main"]
......@@ -23,23 +15,11 @@ jobs:
analyze:
name: Analyze (${{ matrix.language }})
if: github.repository == 'monorepo/venus'
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
# security-events: write - 创建安全事件
# packages: read - 读取包
permissions:
# required for all workflows
runs-on: ubuntu-latest
timeout-minutes: 360
permissions:
security-events: write
# required to fetch internal or private CodeQL packs
packages: read
# only required for workflows in private repositories
actions: read
contents: read
strategy:
......@@ -48,48 +28,23 @@ jobs:
include:
- language: javascript-typescript
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
echo '当前语言被设置为 manual build-mode,请在这里补充项目构建命令。'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
category: "/language:${{ matrix.language }}"
name: defense
on:
pull_request:
push:
branches:
- main
- master
- dev
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.14.0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- name: Install
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm run check:type
- name: Template Contract
run: pnpm run check:template-contract
- name: Review Trigger
run: pnpm run review:trigger
- name: Fitness Fast
run: pnpm run check:fitness -- --tier fast
......@@ -8,6 +8,13 @@ coverage
CODEOWNERS
.nitro
.output
.comate
.lingma
.vscode
**/.hbuilderx
**/uni_modules
**/unpackage
**/devTools
**/*.uvue
**/*.uts
**/*.vue
......@@ -33,4 +40,3 @@ unpackage
!*.wxml
!*.json
......@@ -5,3 +5,4 @@ coverage
miniprogram_npm
uni_modules
wxcomponents
apps/uniappX/**
# Venus Agent 协作约定
## 使命
- 在共享的 `venus` monorepo 中以小步、可回退的方式工作。
- 把仓库视为一个受治理的工程系统,而不是自由发挥的试验场。
- 涉及模板、共享包和工作区工具链时,优先采用 contract-first 的修改方式。
## 阅读顺序
1. 先阅读本文件。
2. 涉及架构判断时,阅读 `docs/architecture/ARCHITECTURE.md`。
3. 涉及执行计划时,阅读 `docs/exec-plans/README.md`。
4. 涉及 AI 失败反馈时,阅读 `docs/issues/ai-failures/README.md`。
5. 涉及质量门禁时,阅读 `docs/fitness/README.md` 及其引用的维度文档。
6. 修改 `packages/cli/templates/**` 前,先阅读 `contracts/templates/*.contract.json`。
## 仓库地图
- `apps/`:生成后的应用与业务代码。
- `packages/cli/`:Venus CLI 及模板交付链路。
- `packages/cli/templates/`:脚手架模板与可选能力。
- `internal/`:共享 lint、tsconfig 与构建策略包。
- `scripts/`:共享自动化入口。
- `contracts/`:可被机器校验的仓库契约。
- `tools/fitness/`:质量执行引擎。
- `docs/`:架构、计划、失败记录与治理证据。
## 工作规则
- 让改动保持在最小但有意义的范围内。
- 如果修改了模板能力,必须在同一次变更中同步更新对应的 contract 和校验逻辑。
- 如果修改了高风险路径,必须补充或更新 `docs/exec-plans/`、`docs/fitness/` 或 `docs/issues/ai-failures/` 中的证据。
- 不要静默修改根级工作区配置行为。
- 优先做增量、可审查的修改,而不是大范围重构。
## 高风险路径
- `packages/cli/**`
- `packages/cli/templates/**`
- `internal/lint-configs/**`
- `internal/tsconfig/**`
- `scripts/build/**`
- `contracts/**`
- 根 `package.json`
- `pnpm-workspace.yaml`
- `lefthook.yml`
- `.github/workflows/**`
## 必备证据
- 模板能力变更:需要 contract 更新和校验结果。
- 共享配置变更:需要执行计划或失败记录中的原因说明。
- 治理脚本变更:需要 fitness 或 smart-check 的验证证据。
## 验证顺序
1. `pnpm lint`
2. `pnpm run check:type`
3. `pnpm run check:template-contract`
4. `pnpm run review:trigger`
5. `pnpm run check:file-budget`
6. `pnpm run check:fitness -- --tier fast`
## 失败处理
- 如果一次改动暴露出缺失的防护规则,要记录到 `docs/issues/ai-failures/`。
- 对于重复出现的失败,要把它沉淀为 contract、hook、脚本或 fitness 规则。
- 不要依赖记忆避免同类问题,能写成仓库规则的就写成仓库规则。
#### 项目介绍
萤火商城V2.0,是2021年全新推出的一款轻量级、高性能、前后端分离的电商系统,支持微信小程序 + H5+ 公众号 + APP,前后端源码完全开源,看见及所得,完美支持二次开发,可学习可商用,让您快速搭建个性化独立商城。
如果对您有帮助,您可以点右上角 “Star” 收藏一下 ,获取第一时间更新,谢谢!
......@@ -31,18 +32,16 @@
5. 打开微信开发者工具 导入 打包完成的项目
6. 检查没有运行错误,在右上方上传小程序
#### UNIAPP-页面展示
![前端展示](https://images.gitee.com/uploads/images/2021/0316/215102_7bcb0802_2166072.png "前端展示.png")
#### 系统演示
![前端演示二维码](https://images.gitee.com/uploads/images/2021/0316/104516_3778337e_2166072.png "111.png")
![前端演示二维码](https://images.gitee.com/uploads/images/2021/0316/104516_3778337e_2166072.png "111.png")
#### 版权须知
1. 允许个人学习研究使用,支持二次开发,允许商业用途(仅限自运营)。
2. 允许商业用途,但仅限自运营,如果商用必须保留版权信息,望自觉遵守。
3. 不允许对程序代码以任何形式任何目的的再发行或出售,否则将追究侵权者法律责任。
\ No newline at end of file
3. 不允许对程序代码以任何形式任何目的的再发行或出售,否则将追究侵权者法律责任。
{
"android": {},
"ios": {}
}
\ No newline at end of file
"android": {},
"ios": {}
}
<!DOCTYPE html>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="static/logo.png" type="image/x-icon" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
var coverSupport =
"CSS" in window &&
typeof CSS.supports === "function" &&
(CSS.supports("top: env(a)") || CSS.supports("top: constant(a)"));
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
(coverSupport ? ", viewport-fit=cover" : "") +
'" />',
);
</script>
<title></title>
<!--preload-links-->
......@@ -18,4 +22,4 @@
<div id="app" class="app-main"><!--app-html--></div>
<script type="module" src="/main"></script>
</body>
</html>
\ No newline at end of file
</html>
{
"pages": [{
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationStyle": "custom"
......@@ -31,9 +32,11 @@
}
}
],
"subPackages": [{
"subPackages": [
{
"root": "pages/subHome",
"pages": [{
"pages": [
{
"path": "search",
"style": {
"navigationBarTitleText": "搜索",
......@@ -58,7 +61,8 @@
},
{
"root": "pages/login",
"pages": [{
"pages": [
{
"path": "login",
"style": {
"navigationBarTitleText": "登录",
......@@ -83,7 +87,8 @@
},
{
"root": "pages/subMoments",
"pages": [{
"pages": [
{
"path": "release-moment",
"style": {
"navigationBarTitleText": "发布动态",
......@@ -108,7 +113,8 @@
},
{
"root": "pages/subMine",
"pages": [{
"pages": [
{
"path": "settings",
"style": {
"navigationBarTitleText": "设置",
......@@ -147,7 +153,8 @@
},
{
"root": "pages/order",
"pages": [{
"pages": [
{
"path": "submit-order-page",
"style": {
"navigationBarTitleText": "提交订单",
......@@ -211,7 +218,8 @@
"selectedColor": "#00b96b",
"backgroundColor": "#fff",
"borderStyle": "white",
"list": [{
"list": [
{
"text": "首页",
"pagePath": "pages/index/index",
"iconPath": "/static/images/tabbar/home.png",
......@@ -244,4 +252,4 @@
]
},
"uniIdRouter": {}
}
\ No newline at end of file
}
// 参考链接 https://doc.dcloud.net.cn/uni-app-x/tutorial/ls-plugin.html#setting
{
"targets": [
"APP-ANDROID"
]
}
\ No newline at end of file
"targets": ["APP-ANDROID"]
}
{
"extends": "@vue/tsconfig/tsconfig.json",
"compilerOptions": {
"ignoreDeprecations": "5.0",
"lib": ["esnext", "dom"],
"experimentalDecorators": true,
"paths": {
"@/*": ["./*"],
"$/*": ["./uni_modules/*"]
},
"resolveJsonModule": true,
"types": ["@dcloudio/types", "vue", "./uni_modules/cool-unix/index.d.ts"],
"noImplicitAny": false,
"outDir": "esbuild",
"sourceMap": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"vueCompilerOptions": {
"extensions": [".vue", ".uvue"]
},
"include": [
"**/*.uts",
"**/*.ts",
"main.ts",
"**/*.uvue",
"**/*.vue",
"App.uvue",
"**/*.d.ts"
],
"exclude": ["node_modules", "dist", "unpackage"]
"extends": "@vue/tsconfig/tsconfig.json",
"compilerOptions": {
"ignoreDeprecations": "5.0",
"lib": ["esnext", "dom"],
"experimentalDecorators": true,
"paths": {
"@/*": ["./*"],
"$/*": ["./uni_modules/*"]
},
"resolveJsonModule": true,
"types": ["@dcloudio/types", "vue", "./uni_modules/cool-unix/index.d.ts"],
"noImplicitAny": false,
"outDir": "esbuild",
"sourceMap": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"vueCompilerOptions": {
"extensions": [".vue", ".uvue"]
},
"include": ["**/*.uts", "**/*.ts", "main.ts", "**/*.uvue", "**/*.vue", "App.uvue", "**/*.d.ts"],
"exclude": ["node_modules", "dist", "unpackage"]
}
......@@ -21,32 +21,32 @@ $uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
/* 文字基本颜色 */
$uni-text-color:#333;//基本色
$uni-text-color-inverse:#fff;//反色
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
$uni-text-color: #333; //基本色
$uni-text-color-inverse: #fff; //反色
$uni-text-color-grey: #999; //辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable:#c0c0c0;
$uni-text-color-disable: #c0c0c0;
/* 背景颜色 */
$uni-bg-color:#fff;
$uni-bg-color-grey:#f8f8f8;
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
$uni-bg-color-mask:rgb(0 0 0 / 40%);//遮罩颜色
$uni-bg-color: #fff;
$uni-bg-color-grey: #f8f8f8;
$uni-bg-color-hover: #f1f1f1; //点击状态颜色
$uni-bg-color-mask: rgb(0 0 0 / 40%); //遮罩颜色
/* 边框颜色 */
$uni-border-color:#c8c7cc;
$uni-border-color: #c8c7cc;
/* 尺寸变量 */
/* 文字尺寸 */
$uni-font-size-sm:12px;
$uni-font-size-base:14px;
$uni-font-size-lg:16px;
$uni-font-size-sm: 12px;
$uni-font-size-base: 14px;
$uni-font-size-lg: 16px;
/* 图片尺寸 */
$uni-img-size-sm:20px;
$uni-img-size-base:26px;
$uni-img-size-lg:40px;
$uni-img-size-sm: 20px;
$uni-img-size-base: 26px;
$uni-img-size-lg: 40px;
/* Border Radius */
$uni-border-radius-sm: 2px;
......@@ -68,9 +68,9 @@ $uni-spacing-col-lg: 12px;
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */
$uni-color-title: #2C405A; // 文章标题颜色
$uni-font-size-title:20px;
$uni-color-title: #2c405a; // 文章标题颜色
$uni-font-size-title: 20px;
$uni-color-subtitle: #555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px;
$uni-font-size-subtitle: 26px;
$uni-color-paragraph: #3f536e; // 文章段落颜色
$uni-font-size-paragraph: 15px;
......@@ -22,7 +22,7 @@
--l-radius-md: 8px;
--l-radius-lg: 12px;
--l-radius-xl: 16px;
--l-radius-a : 100rpx;
--l-radius-a: 100rpx;
/* 接待中心左右模块宽度(1173x768 基准),LayoutService 动态覆盖 */
--l-reception-left-width: 328px;
--l-reception-right-width: 677px;
......
......@@ -5,17 +5,19 @@
HomeFrame 采用现代化的企业级设计语言,融合以下核心设计理念:
### 设计原则
- **视觉层次**:通过阴影、渐变、圆角建立清晰的层级关系
- **微交互**:悬停效果、过渡动画提升用户体验
- **响应式适配**:横竖屏自动切换,多分辨率精确适配
- **一致性**:统一的设计令牌(Design Tokens)确保视觉一致性
### 核心特性
✨ **玻璃态卡片** - `backdrop-filter: blur(10px)` 营造现代感
🌈 **渐变色彩** - 企业级渐变色方案(primary/secondary/success)
💫 **流畅动画** - cubic-bezier 缓动函数实现自然过渡
📐 **精确间距** - 8px 网格系统保证布局规整
🎯 **响应式图标** - Entrance 组件图标尺寸随屏幕自适应
🎯 **响应式图标** - Entrance 组件图标尺寸随屏幕自适应
---
......@@ -34,39 +36,39 @@ HomeFrame 组件采用 **CSS 变量 + layout-root** 的响应式方案,无需
```typescript
// styles/index.vars.uts
export default {
common: {
// 所有场景通用
'--common-title-height': '48px',
// 设计系统变量
'--l-spacing-sm': '8px',
'--l-radius-lg': '16px',
'--l-shadow-md': '0 4px 16px rgba(0, 0, 0, 0.08)',
'--l-bg-card': 'rgba(255, 255, 255, 0.85)',
'--l-gradient-primary': 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
},
portrait: {
// 竖屏专用
'--module-box-height': 'auto',
'--tool-box-min-height': '280px',
'--entrance-icon-size': '52px',
},
landscape: {
// 横屏专用
'--module-box-height': '320px',
'--tool-box-height': '280px',
'--entrance-icon-size': '56px',
},
resolutions: {
// 精确分辨率适配(优先级最高)
'landscape-1024x768': {
'--module-box-height': '360px',
'--entrance-icon-size': '60px',
},
}
}
common: {
// 所有场景通用
"--common-title-height": "48px",
// 设计系统变量
"--l-spacing-sm": "8px",
"--l-radius-lg": "16px",
"--l-shadow-md": "0 4px 16px rgba(0, 0, 0, 0.08)",
"--l-bg-card": "rgba(255, 255, 255, 0.85)",
"--l-gradient-primary": "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
},
portrait: {
// 竖屏专用
"--module-box-height": "auto",
"--tool-box-min-height": "280px",
"--entrance-icon-size": "52px",
},
landscape: {
// 横屏专用
"--module-box-height": "320px",
"--tool-box-height": "280px",
"--entrance-icon-size": "56px",
},
resolutions: {
// 精确分辨率适配(优先级最高)
"landscape-1024x768": {
"--module-box-height": "360px",
"--entrance-icon-size": "60px",
},
},
};
```
## 使用方式
......@@ -74,27 +76,29 @@ export default {
### 1. 在组件中导入配置
```typescript
import pageVars from "./styles/index.vars"
import pageVars from "./styles/index.vars";
```
### 2. 在 SCSS 中使用 CSS 变量
```scss
.module-box {
height: var(--module-box-height);
min-height: var(--tool-box-min-height);
height: var(--module-box-height);
min-height: var(--tool-box-min-height);
}
```
### 3. 无需任何 JavaScript 逻辑
❌ **不需要**:
- 监听屏幕旋转事件
- 手动计算样式
- 条件判断横竖屏
- 动态绑定 `:style`
✅ **只需要**:
- 定义 CSS 变量
- 在 SCSS 中引用
......@@ -103,29 +107,31 @@ import pageVars from "./styles/index.vars"
HomeFrame 布局相关变量简洁命名,间距和字体保留 `l-` 前缀:
### 基础变量
| 变量名 | 说明 | 示例值 |
|--------|------|--------|
| `--module-box-height` | 产品介绍模块高度 | `320px` / `auto` |
| `--tool-box-height` | 展业工具模块高度(横屏) | `280px` |
| `--tool-box-min-height` | 展业工具最小高度(竖屏) | `280px` |
| `--tool-box-margin-bottom` | 展业工具底部间距 | `16px` / `0` |
| `--common-title-height` | 通用标题高度 | `48px` |
| `--tabbar-height` | TabBar 高度 | `60px` / `540px` |
| `--tabbar-icon-size` | TabBar 图标大小 | `24px` / `28px` |
| `--tabbar-width` | TabBar 宽度(横屏) | `120px` |
| `--tabbar-padding` | TabBar 内边距(横屏) | `16px` |
| `--entrance-icon-size` | Entrance 图标尺寸 | `52px` / `56px` |
| `--entrance-item-gap` | Entrance 项目间距 | `20px` / `24px` |
| 变量名 | 说明 | 示例值 |
| -------------------------- | ------------------------ | ---------------- |
| `--module-box-height` | 产品介绍模块高度 | `320px` / `auto` |
| `--tool-box-height` | 展业工具模块高度(横屏) | `280px` |
| `--tool-box-min-height` | 展业工具最小高度(竖屏) | `280px` |
| `--tool-box-margin-bottom` | 展业工具底部间距 | `16px` / `0` |
| `--common-title-height` | 通用标题高度 | `48px` |
| `--tabbar-height` | TabBar 高度 | `60px` / `540px` |
| `--tabbar-icon-size` | TabBar 图标大小 | `24px` / `28px` |
| `--tabbar-width` | TabBar 宽度(横屏) | `120px` |
| `--tabbar-padding` | TabBar 内边距(横屏) | `16px` |
| `--entrance-icon-size` | Entrance 图标尺寸 | `52px` / `56px` |
| `--entrance-item-gap` | Entrance 项目间距 | `20px` / `24px` |
### 设计系统变量
| 变量名 | 说明 | 示例值 |
|--------|------|--------|
| `--l-spacing-*` | 间距变量 (xs/sm/md/lg/xl/2xl/3xl) | `4px` ~ `32px` |
| `--l-font-*` | 字体变量 (xs/sm/md/lg) | `12px` ~ `18px` |
| `--l-radius-*` | 圆角变量 (sm/md/lg/xl) | `8px` ~ `20px` |
| `--l-shadow-*` | 阴影变量 (sm/md/lg) | 多层次阴影 |
| `--l-bg-card` | 卡片背景色 | `rgba(255, 255, 255, 0.85)` |
| `--l-gradient-*` | 渐变色 (primary/secondary/success) | 企业级渐变 |
| 变量名 | 说明 | 示例值 |
| ---------------- | ---------------------------------- | --------------------------- |
| `--l-spacing-*` | 间距变量 (xs/sm/md/lg/xl/2xl/3xl) | `4px` ~ `32px` |
| `--l-font-*` | 字体变量 (xs/sm/md/lg) | `12px` ~ `18px` |
| `--l-radius-*` | 圆角变量 (sm/md/lg/xl) | `8px` ~ `20px` |
| `--l-shadow-*` | 阴影变量 (sm/md/lg) | 多层次阴影 |
| `--l-bg-card` | 卡片背景色 | `rgba(255, 255, 255, 0.85)` |
| `--l-gradient-*` | 渐变色 (primary/secondary/success) | 企业级渐变 |
## 配置层级与优先级
......@@ -145,6 +151,7 @@ resolutions[方向-分辨率] > portrait/landscape > common
## 注意事项
⚠️ **重要**:
- 变量名必须与 `index.vars.uts` 中定义的完全一致
- 分辨率 key 格式:`{方向}-{宽}x{高}`,如 `portrait-393x816`
- UTS 对象属性间必须用逗号分隔
......
......@@ -11,21 +11,22 @@
**使用示例:**
```typescript
import { useRecorder } from '@/composables/useRecorder'
import { useRecorder } from "@/composables/useRecorder";
const { isRecording, startAudio, stopAudio } = useRecorder()
const { isRecording, startAudio, stopAudio } = useRecorder();
// 开始录音
startAudio()
startAudio();
// 停止录音
stopAudio()
stopAudio();
// 强制停止录音
stopAudio(true)
stopAudio(true);
```
**API:**
- `isRecording: Ref<boolean>` - 是否正在录音
- `startAudio(): void` - 开始录音
- `stopAudio(force?: boolean): void` - 停止录音
......@@ -37,21 +38,22 @@ stopAudio(true)
**使用示例:**
```typescript
import { useUploader } from '@/composables/useUploader'
import { useUploader } from "@/composables/useUploader";
const { uploadQueue, isUploading, addToQueue, upload, clearQueue } = useUploader()
const { uploadQueue, isUploading, addToQueue, upload, clearQueue } = useUploader();
// 添加文件到队列
addToQueue('/path/to/file.mp3')
addToQueue("/path/to/file.mp3");
// 执行上传
await upload()
await upload();
// 清空队列
clearQueue()
clearQueue();
```
**API:**
- `uploadQueue: Ref<string[]>` - 上传队列
- `isUploading: Ref<boolean>` - 是否正在上传
- `addToQueue(filePath: string): void` - 添加文件到队列
......@@ -65,21 +67,22 @@ clearQueue()
**使用示例:**
```typescript
import { usePermission } from '@/composables/usePermission'
import { usePermission } from "@/composables/usePermission";
const { checkMicrophonePermission, checkStoragePermission, requestPermission } = usePermission()
const { checkMicrophonePermission, checkStoragePermission, requestPermission } = usePermission();
// 检查麦克风权限
const hasMicPermission = await checkMicrophonePermission()
const hasMicPermission = await checkMicrophonePermission();
// 检查存储权限
const hasStoragePermission = await checkStoragePermission()
const hasStoragePermission = await checkStoragePermission();
// 请求权限
const granted = await requestPermission('microphone')
const granted = await requestPermission("microphone");
```
**API:**
- `checkMicrophonePermission(): Promise<boolean>` - 检查麦克风权限
- `checkStoragePermission(): Promise<boolean>` - 检查存储权限
- `requestPermission(permissionType: string): Promise<boolean>` - 请求权限
......@@ -91,31 +94,26 @@ const granted = await requestPermission('microphone')
**使用示例:**
```typescript
import { useReception } from '@/composables/useReception'
import { useReception } from "@/composables/useReception";
const {
receptionStatus,
showFinishDialog,
startReception,
finishReception,
closeFinishDialog,
clearHistory
} = useReception()
const { receptionStatus, showFinishDialog, startReception, finishReception, closeFinishDialog, clearHistory } =
useReception();
// 开始接待
startReception()
startReception();
// 完成接待
finishReception()
finishReception();
// 关闭完成弹窗
closeFinishDialog()
closeFinishDialog();
// 清除历史
clearHistory()
clearHistory();
```
**API:**
- `receptionStatus: Ref<number>` - 接待状态(0: 未开始, 1: 接待中, 2: 已完成)
- `showFinishDialog: Ref<boolean>` - 是否显示完成弹窗
- `startReception(): void` - 开始接待
......@@ -130,20 +128,21 @@ clearHistory()
**使用示例:**
```typescript
import { useVersionCheck } from '@/composables/useVersionCheck'
import { useVersionCheck } from "@/composables/useVersionCheck";
const { hasNewVersion, versionInfo, checkVersion, doUpdate } = useVersionCheck()
const { hasNewVersion, versionInfo, checkVersion, doUpdate } = useVersionCheck();
// 检查版本
await checkVersion()
await checkVersion();
// 执行更新
if (hasNewVersion.value) {
doUpdate()
doUpdate();
}
```
**API:**
- `hasNewVersion: Ref<boolean>` - 是否有新版本
- `versionInfo: Ref<UTSJSONObject | null>` - 版本信息
- `checkVersion(): Promise<void>` - 检查版本更新
......@@ -189,13 +188,13 @@ async function handleStart(): Promise<void> {
uni.showToast({ title: '需要麦克风权限', icon: 'none' })
return
}
// 清除历史
clearHistory()
// 开始录音
startAudio()
// 开始接待
startReception()
}
......
......@@ -20,11 +20,11 @@
```vue
<template>
<layout-root>
<view class="page">
<view class="item">内容</view>
</view>
</layout-root>
<layout-root>
<view class="page">
<view class="item">内容</view>
</view>
</layout-root>
</template>
```
......@@ -32,52 +32,52 @@
```css
.item {
padding: var(--l-spacing-md);
margin-bottom: var(--l-spacing-lg);
font-size: var(--l-font-base);
border-radius: var(--l-radius-md);
padding: var(--l-spacing-md);
margin-bottom: var(--l-spacing-lg);
font-size: var(--l-font-base);
border-radius: var(--l-radius-md);
}
```
### 3. 变量列表
| 变量 | 说明 | 默认值(1024基准) |
|------|------|-----------------|
| --l-spacing-xs | 间距 | 8px |
| --l-spacing-sm | 间距 | 12px |
| --l-spacing-md | 间距 | 16px |
| --l-spacing-lg | 间距 | 24px |
| --l-spacing-xl | 间距 | 32px |
| --l-spacing-2xl | 间距 | 40px |
| --l-font-xs | 字体 | 12px |
| --l-font-sm | 字体 | 14px |
| --l-font-base | 字体 | 16px |
| --l-font-lg | 字体 | 18px |
| --l-font-xl | 字体 | 20px |
| --l-font-2xl | 字体 | 24px |
| --l-radius-sm | 圆角 | 4px |
| --l-radius-md | 圆角 | 8px |
| --l-radius-lg | 圆角 | 12px |
| --l-radius-xl | 圆角 | 16px |
| 变量 | 说明 | 默认值(1024基准) |
| --------------- | ---- | ---------------- |
| --l-spacing-xs | 间距 | 8px |
| --l-spacing-sm | 间距 | 12px |
| --l-spacing-md | 间距 | 16px |
| --l-spacing-lg | 间距 | 24px |
| --l-spacing-xl | 间距 | 32px |
| --l-spacing-2xl | 间距 | 40px |
| --l-font-xs | 字体 | 12px |
| --l-font-sm | 字体 | 14px |
| --l-font-base | 字体 | 16px |
| --l-font-lg | 字体 | 18px |
| --l-font-xl | 字体 | 20px |
| --l-font-2xl | 字体 | 24px |
| --l-radius-sm | 圆角 | 4px |
| --l-radius-md | 圆角 | 8px |
| --l-radius-lg | 圆角 | 12px |
| --l-radius-xl | 圆角 | 16px |
### 4. JS 中按设计稿缩放
```typescript
import { useLayout } from '@/composables/useLayout'
import { useLayout } from "@/composables/useLayout";
const { scaleSize } = useLayout()
const { scaleSize } = useLayout();
// 设计稿 200px 宽的按钮
const btnWidth = scaleSize(200)
const btnWidth = scaleSize(200);
```
### 5. 模式判断(预留)
```typescript
const { isPad, isPortrait, isDesktop } = useLayout()
const { isPad, isPortrait, isDesktop } = useLayout();
if (isPad.value) {
// pad 布局
// pad 布局
}
```
......
......@@ -5,11 +5,12 @@
## 1. 核心机制
系统基于 **“配置对象 (Configuration Object)”** 模式:
1. **自动检测**:App 启动或窗口调整时,自动获取屏幕宽高。
2. **键值匹配**:生成如 `1024x768` 的 Key。
3. **智能加载**:
* 优先加载对应分辨率的专用配置(如 `landscape/1024x768`)。
* 未匹配则降级使用兜底配置(`landscape/common` 或 `portrait/common`)。
- 优先加载对应分辨率的专用配置(如 `landscape/1024x768`)。
- 未匹配则降级使用兜底配置(`landscape/common` 或 `portrait/common`)。
4. **响应式更新**:配置对象是 Vue Reactive 的,分辨率变化时页面自动更新。
## 2. 目录结构
......@@ -44,35 +45,34 @@ config/resolution-adapt/
```html
<template>
<!-- 必须使用 Layout 包裹,它会自动注入 CSS 类名 -->
<Layout>
<!-- 方式 A: 根类名切换 (CSS) -->
<!-- Layout 组件会自动在根元素加上如 layout-landscape-1920x1080 的类名 -->
<view class="content">
<text class="title">Hello World</text>
</view>
<!-- 方式 B: JS 动态样式 (Style Binding) -->
<view class="dynamic-box"
:style="{ paddingLeft: $resState.config.demo.paddingLeft }">
<!-- 动态图片:使用全局方法 $getResImg 自动选择 @2x/@3x 图片 -->
<image :src="$getResImg($resState.config.demo.heroImageSrc)"
:style="{ width: $resState.config.demo.heroImageWidth }"
mode="widthFix" />
</view>
</Layout>
<!-- 必须使用 Layout 包裹,它会自动注入 CSS 类名 -->
<Layout>
<!-- 方式 A: 根类名切换 (CSS) -->
<!-- Layout 组件会自动在根元素加上如 layout-landscape-1920x1080 的类名 -->
<view class="content">
<text class="title">Hello World</text>
</view>
<!-- 方式 B: JS 动态样式 (Style Binding) -->
<view class="dynamic-box" :style="{ paddingLeft: $resState.config.demo.paddingLeft }">
<!-- 动态图片:使用全局方法 $getResImg 自动选择 @2x/@3x 图片 -->
<image
:src="$getResImg($resState.config.demo.heroImageSrc)"
:style="{ width: $resState.config.demo.heroImageWidth }"
mode="widthFix" />
</view>
</Layout>
</template>
<script setup lang="uts">
// 无需 import 任何分辨率适配相关的代码!
// 无需 import 任何分辨率适配相关的代码!
</script>
<style scoped lang="scss">
// 引入拆分后的样式文件
@import "./styles/common.scss";
@import "./styles/landscape.scss";
@import "./styles/portrait.scss";
// 引入拆分后的样式文件
@import "./styles/common.scss";
@import "./styles/landscape.scss";
@import "./styles/portrait.scss";
</style>
```
......@@ -83,21 +83,21 @@ config/resolution-adapt/
```scss
/* styles/landscape.scss */
.layout {
/* 针对 1920x1080 的覆盖样式 */
&.layout-landscape-1920x1080 {
.title {
font-size: 48rpx;
color: red;
}
}
/* 兜底样式 */
&.layout-landscape-common {
.title {
font-size: 32rpx;
color: blue;
}
}
/* 针对 1920x1080 的覆盖样式 */
&.layout-landscape-1920x1080 {
.title {
font-size: 48rpx;
color: red;
}
}
/* 兜底样式 */
&.layout-landscape-common {
.title {
font-size: 32rpx;
color: blue;
}
}
}
```
......@@ -141,13 +141,13 @@ heroImageSrc: {
2. **编写配置**:复制 `common` 下的文件到新目录并修改数值。
3. **注册分辨率**:
在 `config/resolution-adapt/registry.uts` 中注册新目录。
```typescript
// config/resolution-adapt/registry.uts
import { config as ls_1280 } from './landscape/1280x800/index.uts'
import { config as ls_1280 } from "./landscape/1280x800/index.uts";
const landscapeConfigs = {
// ...
"1280x800": ls_1280 // 新增
} as UTSJSONObject
// ...
"1280x800": ls_1280, // 新增
} as UTSJSONObject;
```
......@@ -6,11 +6,11 @@
## 一、Store 访问
| 禁止 | 推荐 |
|------|------|
| 禁止 | 推荐 |
| ------------------------------- | --------------------------------------------------------------- |
| `store.state.boutique` (弱类型) | **直接导入 state**: `import { state } from '@/store/index.uts'` |
| `store.state.user.xxx` | `state.user.xxx` (强类型访问) |
| 直接 `this.$store.state` | Options API 中使用 `mapState` |
| `store.state.user.xxx` | `state.user.xxx` (强类型访问) |
| 直接 `this.$store.state` | Options API 中使用 `mapState` |
**更新**: 现在 Store 使用 Class 定义 `RootState`,直接导入 `state` 对象即可获得完整的类型推断和代码提示。不再建议将 `state` 强转为 `UTSJSONObject`。
......@@ -18,9 +18,9 @@
## 二、Ref 初始化
| 禁止 | 推荐 |
|------|------|
| `ref(null as any)` | `ref<any | null>(null)` |
| 禁止 | 推荐 |
| -------------------------- | -------- | ------------ |
| `ref(null as any)` | `ref<any | null>(null)` |
| `ref<Comp>(null)` 组件 ref | `ref<any | null>(null)` |
**原因**:`null as any` 在 Kotlin 编译后可能 NPE。
......@@ -29,9 +29,9 @@
## 三、模板 v-for 中的 item
| 禁止 | 推荐 |
|------|------|
| `{{ item['bannerImg'] }}` | `{{ getPkg(item, 'bannerImg') }}` |
| 禁止 | 推荐 |
| -------------------------------------- | ---------------------------------- |
| `{{ item['bannerImg'] }}` | `{{ getPkg(item, 'bannerImg') }}` |
| `:src="item.bannerImg"`(item 为 any) | `:src="getPkg(item, 'bannerImg')"` |
```uts
......@@ -50,9 +50,9 @@ function getPkg(item: any, key: string): any {
## 四、数字 key 的对象映射
| 禁止 | 推荐 |
|------|------|
| `Record<number, X>` + `{ 1: {...}, 0: {...} }` | 用函数映射 |
| 禁止 | 推荐 |
| ------------------------------------------------- | ------------------------------- | ----- |
| `Record<number, X>` + `{ 1: {...}, 0: {...} }` | 用函数映射 |
| `const map = { 1: a, 0: b } as Record<number, X>` | `function getXxx(id: number): X | null` |
```uts
......@@ -69,10 +69,10 @@ function getSceneTypeItem(sceneId: number): SceneTypeItem | null {
## 五、数字格式化
| 禁止 | 推荐 |
|------|------|
| 禁止 | 推荐 |
| ---------------------------- | ---------------------------------------------- |
| `Number(x).toLocaleString()` | `parseFloat((x as any).toString()).toString()` |
| `x.toLocaleString()` | 同上或自定义 formatNumber |
| `x.toLocaleString()` | 同上或自定义 formatNumber |
**原因**:UTS 的 Number 无 toLocaleString。
......@@ -80,10 +80,10 @@ function getSceneTypeItem(sceneId: number): SceneTypeItem | null {
## 六、Storage / JSON 解析
| 禁止 | 推荐 |
|------|------|
| 禁止 | 推荐 |
| ---------------------- | -------------------------- |
| 直接 `JSON.parse(raw)` | 用 `parseStorageJson(key)` |
| `JSON.parse("")` | 判空 + try-catch |
| `JSON.parse("")` | 判空 + try-catch |
```uts
// 参考 api/system-api.uts 中的 parseStorageJson
......
<!DOCTYPE html>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
var coverSupport =
"CSS" in window &&
typeof CSS.supports === "function" &&
(CSS.supports("top: env(a)") || CSS.supports("top: constant(a)"));
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
(coverSupport ? ", viewport-fit=cover" : "") +
'" />',
);
</script>
<title></title>
<!--preload-links-->
......@@ -17,4 +21,4 @@
<div id="app"><!--app-html--></div>
<script type="module" src="/main"></script>
</body>
</html>
\ No newline at end of file
</html>
......@@ -4,8 +4,7 @@
"description": "",
"versionName": "1.0.0",
"versionCode": "127",
"uni-app-x": {
},
"uni-app-x": {},
"quickapp": {},
"mp-weixin": {
"appid": "",
......
......@@ -80,7 +80,7 @@
}
}
],
"easycom": {
"autoscan": true,
"custom": {
......
......@@ -6,7 +6,7 @@
height: 100%;
position: relative;
overflow: hidden;
// 背景层
.bg {
position: absolute;
......@@ -14,7 +14,7 @@
height: 100%;
left: 0;
top: 0;
.bg-image {
width: 100%;
height: 100%;
......@@ -22,7 +22,7 @@
filter: saturate(0.9) brightness(1.05) blur(0.5px);
}
}
// 主布局
.layout {
width: 100%;
......@@ -31,7 +31,7 @@
flex-direction: column;
align-items: center;
position: relative;
// ==================== 步骤条 ====================
.step-box {
height: var(--account-step-height);
......@@ -42,7 +42,7 @@
box-sizing: border-box;
padding: 0 var(--account-padding-horizontal);
margin-top: 20px;
.step-item {
display: flex;
flex-direction: row;
......@@ -50,11 +50,11 @@
margin-right: 20px;
cursor: pointer;
transition: all 0.3s ease;
&:last-child {
margin-right: 0;
}
// 步骤标签
.step-label {
font-weight: 500;
......@@ -62,19 +62,19 @@
color: var(--account-text-tertiary);
transition: all 0.3s ease;
}
.step-label-active {
color: var(--account-primary);
font-weight: 600;
}
// 数字圆圈
.num {
width: var(--account-num-size);
height: var(--account-num-size);
position: relative;
margin-right: 8px;
.text {
width: 100%;
height: 100%;
......@@ -86,19 +86,19 @@
justify-content: center;
overflow: hidden;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
&.text-active {
background-color: #1677ff !important;
box-shadow: 0 2px 8px rgba(22, 119, 255, 0.3) !important;
}
.num-text {
font-weight: 700;
font-size: var(--account-num-fontsize);
color: #ffffff;
}
}
// 激活状态(已完成和当前步骤)
&.active-item {
.text {
......@@ -109,7 +109,7 @@
}
}
}
// ==================== 内容区域 ====================
.content-box {
position: absolute;
......@@ -126,12 +126,12 @@
flex-direction: column;
overflow: hidden;
min-height: 0;
// ==================== 搜索框 ====================
.search-box {
margin: var(--account-content-gap);
position: relative;
.search-input {
width: 100%;
height: var(--account-search-height);
......@@ -141,19 +141,19 @@
padding: 0 16px;
position: relative;
border: 1.5px solid rgba(226, 232, 240, 0.8);
box-shadow:
box-shadow:
0 2px 8px rgba(15, 23, 42, 0.04),
0 4px 16px rgba(15, 23, 42, 0.06);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
&:focus-within {
border-color: rgba(22, 119, 255, 0.5);
box-shadow:
box-shadow:
0 4px 12px rgba(22, 119, 255, 0.1),
0 8px 24px rgba(22, 119, 255, 0.12);
transform: translateY(-1px);
}
.input {
display: flex;
flex-direction: row;
......@@ -161,7 +161,7 @@
height: 100%;
width: 100%;
justify-content: center;
.search-input-text {
font-size: var(--account-search-fontsize);
text-align: center;
......@@ -170,19 +170,19 @@
letter-spacing: 0.3px;
}
}
.icon-search {
margin-left: 6px;
opacity: 0.5;
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}
.placeholder {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
.search-placeholder-text {
font-size: calc(var(--account-search-fontsize) - 1px);
color: #94a3b8;
......@@ -192,7 +192,7 @@
}
}
}
.clear {
position: absolute;
top: 50%;
......@@ -207,14 +207,14 @@
border-radius: 50%;
background: rgba(22, 119, 255, 0.08);
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
&:active {
background: rgba(22, 119, 255, 0.15);
transform: translateY(-50%) scale(0.9);
}
}
}
// ==================== 列表区域 ====================
.list {
display: flex;
......
......@@ -20,10 +20,10 @@
// 淡雅蓝灰背景 - 企业级设计规范(iOS/Android 兼容)
background-color: var(--bg-page);
overflow: hidden;
// 添加装饰性渐变光晕效果
&::before {
content: '';
content: "";
position: absolute;
top: -50%;
right: -20%;
......@@ -33,9 +33,9 @@
border-radius: 50%;
pointer-events: none;
}
&::after {
content: '';
content: "";
position: absolute;
bottom: -30%;
left: -10%;
......@@ -59,7 +59,7 @@
background: rgba(255, 255, 255, 0.98);
backdrop-filter: blur(20px);
border-radius: 24px;
box-shadow:
box-shadow:
0 20px 60px rgba(0, 0, 0, 0.15),
0 0 0 1px rgba(255, 255, 255, 0.5) inset;
animation: cardSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
......@@ -139,7 +139,7 @@
font-size: 15px;
color: #1f2937;
font-weight: 400;
&::placeholder {
color: #9ca3af;
}
......@@ -156,7 +156,7 @@
margin-left: auto;
opacity: 0.6;
transition: opacity 0.2s ease;
&:active {
opacity: 0.4;
}
......@@ -169,11 +169,11 @@
background-color: transparent !important;
border-radius: 8px;
transition: all 0.2s ease;
&:active {
background-color: rgba(102, 126, 234, 0.08);
}
.code-btn-text {
font-size: 13px;
font-weight: 600;
......@@ -184,7 +184,7 @@
.code-disabled {
opacity: 0.5;
.code-btn-text {
color: #9ca3af;
}
......@@ -251,11 +251,11 @@
padding: 4px 0;
cursor: pointer;
transition: opacity 0.2s ease;
&:last-child {
margin-bottom: 0;
}
&:active {
opacity: 0.7;
}
......@@ -269,7 +269,7 @@
font-size: 13px;
color: #6b7280;
line-height: 1.5;
&:nth-child(3) {
color: #667eea;
font-weight: 500;
......@@ -294,7 +294,7 @@
border-radius: 20px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
&:active {
transform: translateX(-50%) scale(0.95);
background: rgba(255, 255, 255, 0.95);
......@@ -315,7 +315,7 @@
margin-left: 8px;
opacity: 0.6;
transition: opacity 0.2s ease;
&:active {
opacity: 0.4;
}
......
......@@ -8,34 +8,35 @@
```typescript
export default {
common: {
'--primary-color': '#1677ff', // 所有场景通用
},
portrait: {
'--padding': '16px', // 竖屏专用
'--columns': '2',
},
landscape: {
'--padding': '32px', // 横屏专用
'--columns': '4',
},
resolutions: {
'portrait-393x816': { // 精确分辨率适配
'--padding': '20px',
},
}
}
common: {
"--primary-color": "#1677ff", // 所有场景通用
},
portrait: {
"--padding": "16px", // 竖屏专用
"--columns": "2",
},
landscape: {
"--padding": "32px", // 横屏专用
"--columns": "4",
},
resolutions: {
"portrait-393x816": {
// 精确分辨率适配
"--padding": "20px",
},
},
};
```
### 2. 在页面中使用
```vue
<template>
<layout-root :page-vars="pageVars">
<view class="container">
<!-- 内容 -->
</view>
</layout-root>
<layout-root :page-vars="pageVars">
<view class="container">
<!-- 内容 -->
</view>
</layout-root>
</template>
<script setup lang="uts">
......@@ -44,19 +45,19 @@ import pageVars from './styles/index.vars'
<style scoped lang="scss">
.container {
padding: var(--padding);
color: var(--primary-color);
padding: var(--padding);
color: var(--primary-color);
}
</style>
```
## 配置层级说明
| 层级 | 优先级 | 使用场景 |
|------|--------|----------|
| `common` | 低 | 所有场景相同的样式 |
| `portrait/landscape` | 中 | 横竖屏不同的布局 |
| `resolutions[方向-分辨率]` | 高 | 特定设备精确适配 |
| 层级 | 优先级 | 使用场景 |
| -------------------------- | ------ | ------------------ |
| `common` | 低 | 所有场景相同的样式 |
| `portrait/landscape` | 中 | 横竖屏不同的布局 |
| `resolutions[方向-分辨率]` | 高 | 特定设备精确适配 |
**合并规则:** 后合并的配置覆盖前面的同名属性
......@@ -65,7 +66,7 @@ import pageVars from './styles/index.vars'
✅ **自动响应** - 全局 mixin 自动监听屏幕旋转,无需手动处理
✅ **Key 格式** - `resolutions` 的 key 为 `{方向}-{宽}x{高}`,如 `portrait-393x816`
✅ **语法注意** - UTS 对象属性间必须用逗号分隔
✅ **调试方法** - 查看控制台 `[useScreenVars]` 日志确认配置生效
✅ **调试方法** - 查看控制台 `[useScreenVars]` 日志确认配置生效
## 常见问题
......
.adapter{
color:var(--adapter-color);
.adapter {
color: var(--adapter-color);
font-size: var(--adapter-fontsize);
}
.test-view{
.test-view {
height: var(--test-view-height);
width: var(--test-view-width);
border: var(--test-view-border-width, 1px) var(--test-view-border-style, solid) var(--test-view-border-color, transparent);
background-color: var(--test-view-bg, transparent);
border: var(--test-view-border-width, 1px) var(--test-view-border-style, solid)
var(--test-view-border-color, transparent);
background-color: var(--test-view-bg, transparent);
border-radius: var(--test-view-border-radius);
display: flex;
align-items: var(--test-view-align-items);
......
.page-container {
width: 100%;
height: 100%;
background: linear-gradient(180deg, #edf4ff 0%, #f4f8ff 36%, #f8fafd 100%);
width: 100%;
height: 100%;
background: linear-gradient(180deg, #edf4ff 0%, #f4f8ff 36%, #f8fafd 100%);
}
.swiper-loading {
width: 100%;
height: 100%;
padding: 12px;
box-sizing: border-box;
width: 100%;
height: 100%;
padding: 12px;
box-sizing: border-box;
}
.swiper-custom-wrap {
width: 100%;
height: 100%;
position: relative;
padding: 0;
box-sizing: border-box;
width: 100%;
height: 100%;
position: relative;
padding: 0;
box-sizing: border-box;
}
.swiper-custom-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
border-radius: 16px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10);
overflow: hidden;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
border-radius: 16px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
overflow: hidden;
}
.equity-hero-head {
width: 100%;
height: 40px;
padding: 0 10px;
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid rgba(226, 236, 248, 0.8);
background: linear-gradient(135deg, rgba(248, 251, 255, 0.95) 0%, rgba(240, 246, 255, 0.95) 100%);
width: 100%;
height: 40px;
padding: 0 10px;
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid rgba(226, 236, 248, 0.8);
background: linear-gradient(135deg, rgba(248, 251, 255, 0.95) 0%, rgba(240, 246, 255, 0.95) 100%);
}
.hero-title-wrap {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
}
.hero-eyebrow {
font-size: 10px;
color: #8ea0ba;
line-height: 12px;
font-size: 10px;
color: #8ea0ba;
line-height: 12px;
}
.hero-title {
margin-top: 0;
font-size: 14px;
font-weight: 700;
color: #1e293b;
line-height: 18px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
margin-top: 0;
font-size: 14px;
font-weight: 700;
color: #1e293b;
line-height: 18px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.hero-indicator-pill {
height: 22px;
min-width: 44px;
padding: 0 8px;
border-radius: 13px;
background: #e9f1ff;
border: 1px solid #cfe0f8;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
height: 22px;
min-width: 44px;
padding: 0 8px;
border-radius: 13px;
background: #e9f1ff;
border: 1px solid #cfe0f8;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.hero-indicator-text {
font-size: 11px;
font-weight: 600;
color: #2a5ecf;
font-size: 11px;
font-weight: 600;
color: #2a5ecf;
}
.equity-swiper-stack {
flex: 1;
width: 100%;
min-height: 0;
position: relative;
padding: 0;
box-sizing: border-box;
flex: 1;
width: 100%;
min-height: 0;
position: relative;
padding: 0;
box-sizing: border-box;
}
.equity-swiper {
width: 100%;
height: 100%;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
width: 100%;
height: 100%;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
}
.equity-swiper-overlay {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 10;
pointer-events: none;
display: flex;
flex-direction: column;
justify-content: flex-end;
background-image: linear-gradient(to top, rgba(30, 58, 138, 0.56) 0%, rgba(30, 58, 138, 0.0) 26%);
border-radius: 10px;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 10;
pointer-events: none;
display: flex;
flex-direction: column;
justify-content: flex-end;
background-image: linear-gradient(to top, rgba(30, 58, 138, 0.56) 0%, rgba(30, 58, 138, 0) 26%);
border-radius: 10px;
}
.swiper-dots {
position: absolute;
left: 0;
right: 0;
bottom: 2px;
display: flex;
flex-direction: row;
justify-content: center;
padding: 0;
position: absolute;
left: 0;
right: 0;
bottom: 2px;
display: flex;
flex-direction: row;
justify-content: center;
padding: 0;
}
.dot {
width: 5px;
height: 5px;
border-radius: 3px;
background: rgba(255, 255, 255, 0.42);
margin: 0 3px;
transition: all 0.3s ease;
width: 5px;
height: 5px;
border-radius: 3px;
background: rgba(255, 255, 255, 0.42);
margin: 0 3px;
transition: all 0.3s ease;
}
.dot.active {
width: 14px;
background: rgba(255, 255, 255, 0.95);
width: 14px;
background: rgba(255, 255, 255, 0.95);
}
.swiper-empty {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.empty-card {
margin: auto;
width: 70%;
min-height: 118px;
border-radius: 18px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
border: 1px solid #e3ecf8;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: auto;
width: 70%;
min-height: 118px;
border-radius: 18px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
border: 1px solid #e3ecf8;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.empty-title {
font-size: 16px;
font-weight: 600;
color: #1e293b;
margin-bottom: 6px;
font-size: 16px;
font-weight: 600;
color: #1e293b;
margin-bottom: 6px;
}
.empty-text {
font-size: 13px;
color: #94a3b8;
font-size: 13px;
color: #94a3b8;
}
.page-container :deep(.right-content-box) {
padding: 6px 0 var(--l-spacing-2xl);
padding: 6px 0 var(--l-spacing-2xl);
}
// 已移除 margin-bottom,由 HomeFrame 统一管理
......@@ -198,15 +198,15 @@
// 请查看:components/HomeFrame/styles/homeframe-*.scss
.detail-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.detail-title {
font-size: 24px;
color: #333;
font-size: 24px;
color: #333;
}
:deep(.layout-portrait-768x1174) .equity-page {
:deep(.start) {
height: 128px;
border-radius: 24px;
margin-bottom: 4px;
}
.equity-hero-head {
height: 52px;
padding: 0 14px;
}
.hero-title {
font-size: 18px;
line-height: 24px;
}
// 所有 module-box/tool-box 相关样式已迁移到 HomeFrame 组件样式文件中
// :deep(.module-box .common-title) {
// height: 56px;
// padding-left: 18px;
// }
//
// :deep(.module-box .title-text) {
// font-size: 18px;
// }
//
// :deep(.tool-box .content-box .entrance-item) {
// margin-bottom: 14px;
// }
:deep(.start) {
height: 128px;
border-radius: 24px;
margin-bottom: 4px;
}
.equity-hero-head {
height: 52px;
padding: 0 14px;
}
.hero-title {
font-size: 18px;
line-height: 24px;
}
// 所有 module-box/tool-box 相关样式已迁移到 HomeFrame 组件样式文件中
// :deep(.module-box .common-title) {
// height: 56px;
// padding-left: 18px;
// }
//
// :deep(.module-box .title-text) {
// font-size: 18px;
// }
//
// :deep(.tool-box .content-box .entrance-item) {
// margin-bottom: 14px;
// }
}
:deep(.layout-portrait-common) .equity-page {
.swiper-custom-content {
border-radius: 14px;
background: rgba(255, 255, 255, 0.92);
}
.equity-hero-head {
height: 44px;
padding: 0 12px;
}
.hero-eyebrow {
font-size: 11px;
line-height: 13px;
}
.hero-title {
font-size: 16px;
line-height: 20px;
}
.hero-indicator-pill {
height: 24px;
min-width: 48px;
padding: 0 10px;
border-radius: 14px;
}
.hero-indicator-text {
font-size: 12px;
}
.equity-swiper,
.equity-swiper-overlay {
border-radius: 10px;
}
.dot {
width: 6px;
height: 6px;
margin: 0 3px;
}
.dot.active {
width: 16px;
}
.empty-card {
width: 78%;
min-height: 126px;
border-radius: 16px;
}
.empty-title {
font-size: 18px;
}
.empty-text {
font-size: 13px;
}
:deep(.right-content-box) {
padding: 6px 0 calc(var(--l-spacing-sm) + 8px);
}
// 已移除 module-box/tool-box 高度相关样式,避免影响 HomeFrame 全局布局
// :deep(.module-box .common-title),
// :deep(.tool-box .common-title) {
// height: 48px;
// padding-left: 16px;
// }
// 所有 module-box/tool-box 相关样式已迁移到 HomeFrame 组件样式文件中
// :deep(.module-box .title-text),
// :deep(.tool-box .title-text) {
// font-size: 16px;
// }
//
// :deep(.tool-box .content-box) {
// padding: 8px 10px 10px;
// }
//
// :deep(.tool-box .content-box .entrance-item) {
// width: 31.5%;
// margin-bottom: 12px;
// }
//
// :deep(.tool-box .content-box .entrance-icon-compact) {
// width: 42px;
// height: 42px;
// }
//
// :deep(.tool-box .content-box .entrance-name-compact) {
// font-size: 12px;
// margin-top: 4px;
// }
.swiper-custom-content {
border-radius: 14px;
background: rgba(255, 255, 255, 0.92);
}
.equity-hero-head {
height: 44px;
padding: 0 12px;
}
.hero-eyebrow {
font-size: 11px;
line-height: 13px;
}
.hero-title {
font-size: 16px;
line-height: 20px;
}
.hero-indicator-pill {
height: 24px;
min-width: 48px;
padding: 0 10px;
border-radius: 14px;
}
.hero-indicator-text {
font-size: 12px;
}
.equity-swiper,
.equity-swiper-overlay {
border-radius: 10px;
}
.dot {
width: 6px;
height: 6px;
margin: 0 3px;
}
.dot.active {
width: 16px;
}
.empty-card {
width: 78%;
min-height: 126px;
border-radius: 16px;
}
.empty-title {
font-size: 18px;
}
.empty-text {
font-size: 13px;
}
:deep(.right-content-box) {
padding: 6px 0 calc(var(--l-spacing-sm) + 8px);
}
// 已移除 module-box/tool-box 高度相关样式,避免影响 HomeFrame 全局布局
// :deep(.module-box .common-title),
// :deep(.tool-box .common-title) {
// height: 48px;
// padding-left: 16px;
// }
// 所有 module-box/tool-box 相关样式已迁移到 HomeFrame 组件样式文件中
// :deep(.module-box .title-text),
// :deep(.tool-box .title-text) {
// font-size: 16px;
// }
//
// :deep(.tool-box .content-box) {
// padding: 8px 10px 10px;
// }
//
// :deep(.tool-box .content-box .entrance-item) {
// width: 31.5%;
// margin-bottom: 12px;
// }
//
// :deep(.tool-box .content-box .entrance-icon-compact) {
// width: 42px;
// height: 42px;
// }
//
// :deep(.tool-box .content-box .entrance-name-compact) {
// font-size: 12px;
// margin-top: 4px;
// }
}
.adapter{
color:var(--adapter-color);
.adapter {
color: var(--adapter-color);
font-size: var(--adapter-fontsize);
}
.test-view{
.test-view {
height: var(--test-view-height);
background-color: var(--test-view-bg, transparent);
background-color: var(--test-view-bg, transparent);
}
.reception-tabs-container{
.reception-tabs-container {
padding: var(--reception-tabs-container-padding);
margin-top: var(--reception-tabs-container-margin-top);
background-color: var(--reception-tabs-container-bgc);
margin-top: var(--reception-tabs-container-margin-top);
background-color: var(--reception-tabs-container-bgc);
}
.reception-main-tabs {
font-size: var(--reception-main-tabs-font-size);
}
\ No newline at end of file
}
.glass-card {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
}
.filter-group {
min-width: 0;
padding: 3px;
border-radius: 8px;
min-width: 0;
padding: 3px;
border-radius: 8px;
}
.filter-group-compact {
padding: 2px;
border-radius: 6px;
padding: 2px;
border-radius: 6px;
}
.filter-tabs-row {
flex-direction: row;
flex: 1;
width: 100%;
height: var(--reception-list-filters-tabs-row-height, 40px);
min-height: var(--reception-list-filters-tabs-row-height, 40px);
flex-direction: row;
flex: 1;
width: 100%;
height: var(--reception-list-filters-tabs-row-height, 40px);
min-height: var(--reception-list-filters-tabs-row-height, 40px);
}
.entry-filter-segmented-wrap {
align-items: stretch;
.un-segmented {
flex: 1;
width: 100%;
border-width: 0;
background-color: rgba(0, 0, 0, 0.04);
border-radius: 10px;
padding: 2px;
}
.un-segmented__item {
border-width: 0;
border-radius: 10px;
.un-segmented__item__text {
color: #64748b;
font-size: var(--reception-list-filters-segmented-font-size, 14px);
}
&--active {
background-color: #ffffff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
.un-segmented__item__text {
color: #1677ff;
font-weight: 600;
}
}
}
align-items: stretch;
.un-segmented {
flex: 1;
width: 100%;
border-width: 0;
background-color: rgba(0, 0, 0, 0.04);
border-radius: 10px;
padding: 2px;
}
.un-segmented__item {
border-width: 0;
border-radius: 10px;
.un-segmented__item__text {
color: #64748b;
font-size: var(--reception-list-filters-segmented-font-size, 14px);
}
&--active {
background-color: #ffffff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
.un-segmented__item__text {
color: #1677ff;
font-weight: 600;
}
}
}
}
.filter-actions {
flex-direction: row;
flex-wrap: nowrap;
flex-grow: 0;
flex-shrink: 0;
margin-left: auto;
flex-direction: row;
flex-wrap: nowrap;
flex-grow: 0;
flex-shrink: 0;
margin-left: auto;
}
// =========================
......@@ -74,28 +74,28 @@
// 基础卡片(等价于 glass-card)
.reception-filter-card {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
}
// 筛选项外壳(等价于 filter-group + filter-group-compact)
.reception-filter-shell {
min-width: 0;
padding: 2px;
border-radius: 6px;
min-width: 0;
padding: 2px;
border-radius: 6px;
}
// “半宽 segmented”容器(从 Primary 本地样式提取,供 Primary/Secondary 复用)
.reception-filter-entry-segmented-half {
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
width: 50%;
max-width: 50%;
min-width: 0;
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
width: 50%;
max-width: 50%;
min-width: 0;
}
// =========================
......@@ -106,82 +106,82 @@
// 基础卡片:卡片外观 + 壳(等价于 reception-filter-card + reception-filter-shell)
.rcf-card {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
}
// 半宽 segmented:rcf-card + 50% 宽度
.rcf-half {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
width: 50%;
max-width: 50%;
min-width: 0;
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
width: 50%;
max-width: 50%;
min-width: 0;
}
// review 区域卡片(用于 Secondary):rcf-card + review-tabs-wrap 的布局外观
.rcf-review-card {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
flex: 1 1 0;
min-width: 0;
background: #f3f7fd;
border: 1px solid #e2e8f0;
border-radius: 10px;
padding: 2px;
box-sizing: border-box;
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
flex: 1 1 0;
min-width: 0;
background: #f3f7fd;
border: 1px solid #e2e8f0;
border-radius: 10px;
padding: 2px;
box-sizing: border-box;
}
// review 区域半宽 segmented:rcf-half + review-tabs-wrap 的布局外观
.rcf-review-half {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
width: 50%;
max-width: 50%;
min-width: 0;
flex: 1 1 0;
min-width: 0;
background: #f3f7fd;
border: 1px solid #e2e8f0;
border-radius: 10px;
padding: 2px;
box-sizing: border-box;
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(226, 232, 240, 1);
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
border-radius: 10px;
flex-direction: column;
min-width: 0;
padding: 2px;
border-radius: 6px;
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
width: 50%;
max-width: 50%;
min-width: 0;
flex: 1 1 0;
min-width: 0;
background: #f3f7fd;
border: 1px solid #e2e8f0;
border-radius: 10px;
padding: 2px;
box-sizing: border-box;
}
{
"targets": [
"APP-ANDROID"
]
}
\ No newline at end of file
"targets": ["APP-ANDROID"]
}
......@@ -13,14 +13,14 @@
## 📦 可用服务列表
| 服务名称 | 类型 | 描述 | 使用场景 |
|---------|------|------|---------|
| `logger` | `Logger` | 日志记录与上传服务 | 记录应用日志、错误追踪 |
| `dbRecord` | `DBRecord` | 数据库记录管理服务 | 接待记录的 CRUD 操作 |
| `fileUpload` | `FileUploadService` | 文件上传服务(支持多策略) | 上传图片、音频等到 OSS |
| `recordSave` | `RecordSave` | 记录保存服务 | 保存接待记录到数据库 |
| `recordService` | `RecordService` | 录音管理服务 | 开始/停止录音、录音控制 |
| `timeoutService` | `TimeoutService` | 超时监控服务 | 监控用户操作,超时自动停止 |
| 服务名称 | 类型 | 描述 | 使用场景 |
| ---------------- | ------------------- | -------------------------- | -------------------------- |
| `logger` | `Logger` | 日志记录与上传服务 | 记录应用日志、错误追踪 |
| `dbRecord` | `DBRecord` | 数据库记录管理服务 | 接待记录的 CRUD 操作 |
| `fileUpload` | `FileUploadService` | 文件上传服务(支持多策略) | 上传图片、音频等到 OSS |
| `recordSave` | `RecordSave` | 记录保存服务 | 保存接待记录到数据库 |
| `recordService` | `RecordService` | 录音管理服务 | 开始/停止录音、录音控制 |
| `timeoutService` | `TimeoutService` | 超时监控服务 | 监控用户操作,超时自动停止 |
## 💡 使用方式
......@@ -35,8 +35,8 @@ services.logger.info("页面加载", "App");
// 使用数据库服务
await services.dbRecord.updateRecord({
id: "123",
status: "completed"
id: "123",
status: "completed",
});
// 使用文件上传服务
......@@ -50,6 +50,7 @@ services.timeoutService.start();
```
**优点:**
- ✅ 统一管理,代码风格一致
- ✅ IDE 智能提示完整
- ✅ 适用于所有场景(业务代码和子服务模块)
......@@ -67,10 +68,12 @@ const result = await fileUpload.uploadFile(filePath);
```
**优点:**
- ✅ 代码更简洁
- ✅ 按需导入,语义清晰
**⚠️ 注意事项:**
- ❌ **仅限业务代码使用**(pages/, components/ 目录)
- ❌ **子服务模块不能使用**(会造成循环依赖)
......@@ -121,11 +124,11 @@ Logger.getInstance().info("消息");
```typescript
// ❌ 子服务模块 → services
import services from "@/services"; // 不要用!
import services from "@/services"; // 不要用!
services.logger.info("消息");
// ❌ 子服务模块 → 命名导出
import { logger } from "@/services"; // 不要用!
import { logger } from "@/services"; // 不要用!
logger.info("消息");
```
......@@ -150,14 +153,15 @@ services.logger.debug("请求参数:" + JSON.stringify(params), "API");
```
**在子服务模块中使用:**
```typescript
// recorder/AudioManager.uts
import { Logger } from "../logger/LoggerCore";
class AudioManager {
start() {
Logger.getInstance().info("开始录音", "AudioManager");
}
start() {
Logger.getInstance().info("开始录音", "AudioManager");
}
}
```
......@@ -171,9 +175,9 @@ const records = await services.dbRecord.getCompletedRecords();
// 更新记录
await services.dbRecord.updateRecord({
id: "123",
receptionStatus: 1,
receptionEndTime: new Date().toISOString()
id: "123",
receptionStatus: 1,
receptionEndTime: new Date().toISOString(),
});
// 删除记录
......@@ -190,8 +194,8 @@ import services from "@/services";
// 上传文件
const result = await services.fileUpload.upload({
filePath: "/path/to/file.mp3",
fileName: "recording.mp3"
filePath: "/path/to/file.mp3",
fileName: "recording.mp3",
});
console.log("上传成功:", result.url);
......@@ -208,11 +212,11 @@ import services from "@/services";
// 保存接待记录
await services.recordSave.save({
id: "123",
receptionStartTime: new Date().toISOString(),
receptionEndTime: new Date().toISOString(),
receptionStatus: 1,
recordUrlList: ["url1", "url2"]
id: "123",
receptionStartTime: new Date().toISOString(),
receptionEndTime: new Date().toISOString(),
receptionStatus: 1,
recordUrlList: ["url1", "url2"],
});
```
......@@ -261,18 +265,18 @@ services.timeoutService.stop();
import services from "@/services";
class DBRecord {
async init() {
services.logger.info("初始化数据库"); // ❌ 循环依赖!
}
async init() {
services.logger.info("初始化数据库"); // ❌ 循环依赖!
}
}
// ✅ 正确:recorder/DBRecord.uts
import { Logger } from "../logger/LoggerCore";
class DBRecord {
async init() {
Logger.getInstance().info("初始化数据库"); // ✅ 正确
}
async init() {
Logger.getInstance().info("初始化数据库"); // ✅ 正确
}
}
```
......@@ -319,21 +323,21 @@ async function initRecords() {
import services from "@/services";
async function startReception() {
try {
// 开始录音
await services.recordService.startAudio();
// 启动超时监控
services.timeoutService.start();
// 记录日志
services.logger.info("开始接待", "Reception");
// 保存初始记录
await services.recordSave.save(initialData);
} catch (error) {
services.logger.error("接待失败:" + error, "Reception");
}
try {
// 开始录音
await services.recordService.startAudio();
// 启动超时监控
services.timeoutService.start();
// 记录日志
services.logger.info("开始接待", "Reception");
// 保存初始记录
await services.recordSave.save(initialData);
} catch (error) {
services.logger.error("接待失败:" + error, "Reception");
}
}
```
......@@ -345,15 +349,15 @@ import { Logger } from "../logger/LoggerCore";
import { DBRecord } from "./DBRecord.uts";
class RecordSave {
async save(data: RecordData) {
try {
Logger.getInstance().info("保存记录", "RecordSave");
await DBRecord.getInstance().insert(data);
} catch (error) {
Logger.getInstance().error("保存失败", "RecordSave");
throw error;
}
}
async save(data: RecordData) {
try {
Logger.getInstance().info("保存记录", "RecordSave");
await DBRecord.getInstance().insert(data);
} catch (error) {
Logger.getInstance().error("保存失败", "RecordSave");
throw error;
}
}
}
```
......@@ -363,18 +367,18 @@ class RecordSave {
import services from "@/services";
async function handleReception() {
try {
await services.recordService.startAudio();
} catch (error) {
// 使用 logger 记录错误
services.logger.error(`启动录音失败:${error}`, "Reception");
// 可以继续处理
uni.showToast({
title: "录音启动失败",
icon: "none"
});
}
try {
await services.recordService.startAudio();
} catch (error) {
// 使用 logger 记录错误
services.logger.error(`启动录音失败:${error}`, "Reception");
// 可以继续处理
uni.showToast({
title: "录音启动失败",
icon: "none",
});
}
}
```
......@@ -386,10 +390,10 @@ async function handleReception() {
import services from "@/services";
// 第一次访问 logger 时才会创建 Logger 实例
services.logger.info("首次访问"); // ← 此时初始化
services.logger.info("首次访问"); // ← 此时初始化
// 后续访问直接使用已创建的实例
services.logger.info("再次访问"); // ← 直接使用实例
services.logger.info("再次访问"); // ← 直接使用实例
```
## 🔧 平台差异
......
.home-frame-container.mode-landscape.res-1080 {
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
.home-frame-container.mode-landscape.res-1920 {
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
.home-frame-container.mode-portrait.res-1080 {
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
.home-frame-container.mode-portrait.res-1920 {
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
.mode-landscape.res-1080 {
......@@ -33,94 +33,94 @@
}
.mode-portrait.res-1080 {
.start {
height: 96px;
}
.start {
height: 96px;
}
}
.mode-portrait.res-1920 {
}
.mode-portrait.res-1080 .login-page {
.layout {
justify-content: flex-start;
align-items: stretch;
padding: 32px 24px;
}
.login {
align-items: stretch;
margin-top: 16px;
max-width: 320px;
margin-left: auto;
margin-right: auto;
}
.login .title {
font-size: 28px;
margin-bottom: 12px;
}
.login .sub-title {
font-size: 14px;
margin: 12px 0 20px;
}
.login .input {
width: 100%;
height: 48px;
border-radius: 24px;
margin-bottom: 16px;
}
.login .btn {
width: 100%;
height: 48px;
margin-top: 8px;
font-size: 18px;
}
.form-footer {
padding-left: 0;
margin-top: 16px;
}
.app-code {
bottom: 12px;
font-size: 10px !important;
line-height: 14px;
left: 50%;
transform: translateX(-50%) scale(0.85);
}
.layout {
justify-content: flex-start;
align-items: stretch;
padding: 32px 24px;
}
.login {
align-items: stretch;
margin-top: 16px;
max-width: 320px;
margin-left: auto;
margin-right: auto;
}
.login .title {
font-size: 28px;
margin-bottom: 12px;
}
.login .sub-title {
font-size: 14px;
margin: 12px 0 20px;
}
.login .input {
width: 100%;
height: 48px;
border-radius: 24px;
margin-bottom: 16px;
}
.login .btn {
width: 100%;
height: 48px;
margin-top: 8px;
font-size: 18px;
}
.form-footer {
padding-left: 0;
margin-top: 16px;
}
.app-code {
bottom: 12px;
font-size: 10px !important;
line-height: 14px;
left: 50%;
transform: translateX(-50%) scale(0.85);
}
}
.mode-portrait.res-1920 .account-page {
}
.mode-portrait.res-1080 .account-page {
.layout {
padding-top: 48px;
padding-bottom: 24px;
}
.content-box {
top: 120px;
bottom: 48px;
width: 94%;
border-radius: 16px;
}
.step-box {
transform: scale(0.9);
}
.box {
padding: 0 16px;
justify-content: flex-start;
}
.box .items {
width: 100%;
margin-bottom: 16px;
}
.layout {
padding-top: 48px;
padding-bottom: 24px;
}
.content-box {
top: 120px;
bottom: 48px;
width: 94%;
border-radius: 16px;
}
.step-box {
transform: scale(0.9);
}
.box {
padding: 0 16px;
justify-content: flex-start;
}
.box .items {
width: 100%;
margin-bottom: 16px;
}
}
......@@ -8,16 +8,16 @@
```typescript
// 直接导入单例对象
import { recordService } from '@/services/recorder/index.uts'
import { recordService } from "@/services/recorder/index.uts";
```
### 开始接待/录音
```typescript
// 开始录音 (自动请求权限)
const success = await recordService.startAudio()
const success = await recordService.startAudio();
if (success) {
console.log('录音已开始')
console.log("录音已开始");
}
```
......@@ -25,10 +25,10 @@ if (success) {
```typescript
// 结束录音并保存记录
await recordService.stopAudio()
await recordService.stopAudio();
// 仅结束录音,不保存记录 (例如用户取消)
await recordService.stopAudio(true)
await recordService.stopAudio(true);
```
## 2. 业务数据更新
......@@ -39,38 +39,27 @@ await recordService.stopAudio(true)
```typescript
const customerInfo = {
customerName: '张三',
phoneNumber: '13800138000',
carModel: 'Model Y'
}
customerName: "张三",
phoneNumber: "13800138000",
carModel: "Model Y",
};
// updateBusinessData(类型,数据)
recordService.updateBusinessData(
'customer',
customerInfo
)
recordService.updateBusinessData("customer", customerInfo);
```
### 更新接待状态
```typescript
// 状态 '1' 表示接待中,'0' 表示结束
recordService.updateBusinessData(
'status',
'1'
)
recordService.updateBusinessData("status", "1");
```
### 更新物料/轨迹点
```typescript
const points = [
{ x: 100, y: 200, time: 1234567890 }
]
recordService.updateBusinessData(
'material',
points
)
const points = [{ x: 100, y: 200, time: 1234567890 }];
recordService.updateBusinessData("material", points);
```
## 3. 获取业务数据
......@@ -79,8 +68,8 @@ recordService.updateBusinessData(
```typescript
// 或者使用通用方法获取特定类型数据
const materialData = await recordService.getBusinessData('material')
console.log('物料数据:', materialData?.receptionCustomerMaterialPointList)
const materialData = await recordService.getBusinessData("material");
console.log("物料数据:", materialData?.receptionCustomerMaterialPointList);
```
### 注意事项
......@@ -100,40 +89,39 @@ console.log('物料数据:', materialData?.receptionCustomerMaterialPointList)
import { IRecorderStrategy } from "../types/strategy.uts";
export class RealEstateStrategy implements IRecorderStrategy {
getName(): string {
return "RealEstateStrategy"
}
// 1. 定义该业务需要的数据库字段
getTableColumns(): string[] {
return [
"houseType TEXT", // 户型
"area INTEGER", // 面积
"budget TEXT" // 预算
]
}
// 2. 指定需要解析为 JSON 的字段
getJsonFields(): string[] {
return [
"houseInfo", // 房屋信息
"customerPreference" // 客户偏好
]
}
// 3. 处理业务数据转换
handle(type: string, data: any | null, recordId: string): null | UTSJSONObject {
// 根据 type 处理 data,返回存入 DB 的 JSON 对象
if (type == 'house_info') {
const info = data as UTSJSONObject
return {
houseType: info['type'],
area: info['area']
}
}
return null
}
getName(): string {
return "RealEstateStrategy";
}
// 1. 定义该业务需要的数据库字段
getTableColumns(): string[] {
return [
"houseType TEXT", // 户型
"area INTEGER", // 面积
"budget TEXT", // 预算
];
}
// 2. 指定需要解析为 JSON 的字段
getJsonFields(): string[] {
return [
"houseInfo", // 房屋信息
"customerPreference", // 客户偏好
];
}
// 3. 处理业务数据转换
handle(type: string, data: any | null, recordId: string): null | UTSJSONObject {
// 根据 type 处理 data,返回存入 DB 的 JSON 对象
if (type == "house_info") {
const info = data as UTSJSONObject;
return {
houseType: info["type"],
area: info["area"],
};
}
return null;
}
}
```
......@@ -142,15 +130,16 @@ export class RealEstateStrategy implements IRecorderStrategy {
在业务初始化时调用:
```typescript
import { RealEstateStrategy } from '@/composables/recorder/strategies/RealEstateStrategy.uts'
import { recordService } from '@/composables/recorder/index.uts'
import { RealEstateStrategy } from "@/composables/recorder/strategies/RealEstateStrategy.uts";
import { recordService } from "@/composables/recorder/index.uts";
// 切换到房产销售策略
const strategy = new RealEstateStrategy()
recordService.setStrategy(strategy)
const strategy = new RealEstateStrategy();
recordService.setStrategy(strategy);
```
切换策略后:
1. `DBRecord` 会自动检查并创建新的数据库字段。
2. `RecordService` 会使用新策略的 `handle` 方法处理数据。
......@@ -216,11 +205,11 @@ recordService.setStrategy(strategy)
```typescript
// ✅ 推荐:在用户输入时立即更新
inputElement.on('change', (e) => {
recordService.updateBusinessData('customer', {
customerName: e.target.value
})
})
inputElement.on("change", (e) => {
recordService.updateBusinessData("customer", {
customerName: e.target.value,
});
});
// ❌ 避免:集中批量更新,可能导致数据丢失
```
......@@ -228,9 +217,8 @@ inputElement.on('change', (e) => {
### 7.2 数据获取选择
```typescript
// ✅ 通用方法(支持所有类型)
const data = await recordService.getBusinessData('material')
const data = await recordService.getBusinessData("material");
```
### 7.3 策略切换
......@@ -238,9 +226,9 @@ const data = await recordService.getBusinessData('material')
```typescript
// ✅ 在应用初始化时切换策略
onLaunch(() => {
const strategy = new CustomStrategy()
recordService.setStrategy(strategy)
})
const strategy = new CustomStrategy();
recordService.setStrategy(strategy);
});
// ❌ 避免在接待过程中切换策略
```
......@@ -250,5 +238,3 @@ onLaunch(() => {
1. 在策略的 `getTableColumns()` 中声明字段
2. 在 `getJsonFields()` 中声明需要 JSON 解析的字段
3. 在 `handle()` 中实现数据处理逻辑
......@@ -21,10 +21,10 @@ import { reactive } from "vue";
// 1. 定义 State 类 (必须包含 static _C 属性以规避编译错误)
export class UserStateType {
static _C: string = "companion"; // 必须存在,解决 UTS 伴生对象报错
token: string | null = null;
userInfo: UTSJSONObject = {};
isLoggedIn: boolean = false;
static _C: string = "companion"; // 必须存在,解决 UTS 伴生对象报错
token: string | null = null;
userInfo: UTSJSONObject = {};
isLoggedIn: boolean = false;
}
// 2. 初始化 State
......@@ -44,8 +44,8 @@ import { state as userState, UserStateType } from "@/store/modules/user.uts";
// ... 其他模块导入
export class RootState {
user: UserStateType = userState;
// ... 其他模块属性
user: UserStateType = userState;
// ... 其他模块属性
}
export const state = reactive(new RootState());
......@@ -60,43 +60,43 @@ Actions 中修改 State 时,由于 UTS 的类型检查,可能需要对 Paylo
```typescript
// store/modules/user.uts
export const actions = {
setUserInfo: (payload: any): any | null => {
// 显式转换类型
const data = payload as UTSJSONObject;
// 逐个属性赋值 (推荐,类型安全)
const s = state as UserStateType;
if (data['name'] != null) {
s.userInfo['name'] = data['name'];
}
// 或者整体赋值 (需确保类型匹配)
// (state as UserStateType).userInfo = data;
return null;
}
}
setUserInfo: (payload: any): any | null => {
// 显式转换类型
const data = payload as UTSJSONObject;
// 逐个属性赋值 (推荐,类型安全)
const s = state as UserStateType;
if (data["name"] != null) {
s.userInfo["name"] = data["name"];
}
// 或者整体赋值 (需确保类型匹配)
// (state as UserStateType).userInfo = data;
return null;
},
};
```
## 如何添加新模块
1. **创建模块文件**: 在 `store/modules/` 下创建 `xxx.uts`。
2. **定义 State 类**:
* 创建 `export class XxxStateType { static _C = "companion"; ... }`。
* 定义所有属性并赋予默认值。
- 创建 `export class XxxStateType { static _C = "companion"; ... }`。
- 定义所有属性并赋予默认值。
3. **导出 State**: `export const state = reactive(new XxxStateType());`。
4. **注册模块 (`store/index.uts`)**:
* **顶部导入**:
- **顶部导入**:
```typescript
import { state as xxxState, XxxStateType } from "@/store/modules/xxx.uts";
import * as xxx from "@/store/modules/xxx.uts"; // 用于动态注册 actions
```
* **添加到 `modules` 数组**: `const modules: any[] = [..., xxx];`
* **添加到 `RootState` 类**:
- **添加到 `modules` 数组**: `const modules: any[] = [..., xxx];`
- **添加到 `RootState` 类**:
```typescript
export class RootState {
// ...
xxx: XxxStateType = xxxState;
// ...
xxx: XxxStateType = xxxState;
}
```
......@@ -111,25 +111,25 @@ export const actions = {
### 直接导入 (推荐)
```typescript
import { state } from '@/store/index.uts'
import { state } from "@/store/index.uts";
// 读取
const token = state.user.token
const token = state.user.token;
// 写入 (通过 dispatch)
import { dispatch } from '@/store/index.uts'
dispatch('user/setToken', 'new-token')
import { dispatch } from "@/store/index.uts";
dispatch("user/setToken", "new-token");
```
### 使用 mapHelpers (Options API)
```typescript
import { mapState, mapGetters } from '@/store/mapHelpers.uts'
import { mapState, mapGetters } from "@/store/mapHelpers.uts";
export default {
computed: {
...mapState(['user']),
...mapGetters(['token'])
}
}
computed: {
...mapState(["user"]),
...mapGetters(["token"]),
},
};
```
......@@ -98,7 +98,6 @@ $uni-font-size-paragraph: 15px;
}
}
.common-title {
width: 100%;
height: 120rpx;
......
......@@ -6,11 +6,12 @@
✅ 所有编译错误已修复
✅ 连接逻辑已简化
✅ 测试工具已准备就绪
✅ 文档已完善
✅ 文档已完善
## 🔄 最新更新(2026-03-18)
已简化 WebSocket 连接逻辑:
- ✅ 移除复杂的候选地址尝试
- ✅ 直接使用配置的 WebSocket 地址
- ✅ 简化登录流程
......@@ -26,13 +27,13 @@
```json
{
"app-android": {
"distribute": {
"modules": {
"uni-websocket": {} // ← 添加这一行
}
}
}
"app-android": {
"distribute": {
"modules": {
"uni-websocket": {} // ← 添加这一行
}
}
}
}
```
......@@ -58,9 +59,9 @@ rm -rf apps/uniappX/uniapp-x-tape/unpackage
```typescript
const config = {
wsUrl: 'ws://192.168.1.237:8081/ws',
token: '你的token', // ← 修改这里
deviceId: '你的deviceId' // ← 修改这里
wsUrl: "ws://192.168.1.237:8081/ws",
token: "你的token", // ← 修改这里
deviceId: "你的deviceId", // ← 修改这里
};
```
......@@ -69,10 +70,10 @@ const config = {
在任意页面添加:
```typescript
import { quickTestNativeWebSocket } from '@/ws';
import { quickTestNativeWebSocket } from "@/ws";
onReady(() => {
quickTestNativeWebSocket();
quickTestNativeWebSocket();
});
```
......@@ -81,6 +82,7 @@ onReady(() => {
## 📚 文档导航
### 新手入门
1. **[简化使用说明.md](./简化使用说明.md)** - 最新简化版使用说明(推荐!)
2. **[快速修复指南.md](./快速修复指南.md)** - 解决运行时错误
3. **[故障排除.md](./故障排除.md)** - 网络连接问题排查
......@@ -88,6 +90,7 @@ onReady(() => {
5. **[使用示例.md](./使用示例.md)** - 代码使用示例
### 技术文档
6. **[README-NATIVE-WS.md](./README-NATIVE-WS.md)** - 原生 WebSocket 使用说明
7. **[修复记录.md](./修复记录.md)** - 完整的修复记录
8. **[重新编译说明.md](./重新编译说明.md)** - 编译缓存清理指南
......@@ -95,25 +98,29 @@ onReady(() => {
## 🛠️ 测试工具
### 1. 快速测试脚本
```typescript
import { quickTestNativeWebSocket } from '@/ws';
import { quickTestNativeWebSocket } from "@/ws";
await quickTestNativeWebSocket();
```
### 2. 直接连接测试(推荐,跳过登录)
```typescript
import { quickTestDirectConnect } from '@/ws';
import { quickTestDirectConnect } from "@/ws";
// 修改 ws/direct-test.uts 中的 wsUrl 配置
await quickTestDirectConnect();
```
### 3. 测试工具类
```typescript
import { nativeWsTest } from '@/ws';
import { nativeWsTest } from "@/ws";
await nativeWsTest.testConnect(url, token, deviceId);
```
### 4. 可视化测试页面
- 文件:`pages/test-ws.uvue`
- 需要在 `pages.json` 中添加路由
......@@ -122,11 +129,13 @@ await nativeWsTest.testConnect(url, token, deviceId);
### 从 socket.io 迁移到原生 WebSocket
**之前(socket.io):**
- 使用特定的握手协议
- 连接路径:`/socket.io/`
- 消息格式:socket.io 包装格式
**现在(原生 WebSocket):**
- 标准 WebSocket 协议
- 连接路径:`/ws` 或 `/websocket`
- 消息格式:纯 JSON 字符串
......@@ -138,6 +147,7 @@ ws://host:port/path?token=YOUR_TOKEN&deviceId=YOUR_DEVICE_ID
```
示例:
```
ws://192.168.1.237:8081/ws?token=abc123&deviceId=device001
```
......@@ -147,20 +157,20 @@ ws://192.168.1.237:8081/ws?token=abc123&deviceId=device001
### 使用主 Ws 类(推荐)
```typescript
import ws from '@/ws';
import ws from "@/ws";
// 连接(自动登录)
await ws.connect();
// 发送消息
await ws.send({
command: 'message',
data: { content: 'Hello' }
command: "message",
data: { content: "Hello" },
});
// 监听消息
ws.setOnMessage((data) => {
console.log('收到消息:', data);
console.log("收到消息:", data);
});
// 关闭连接
......@@ -170,19 +180,15 @@ await ws.close();
### 使用测试工具类
```typescript
import { nativeWsTest } from '@/ws';
import { nativeWsTest } from "@/ws";
// 连接
await nativeWsTest.testConnect(
'ws://192.168.1.237:8081/ws',
'your-token',
'your-device-id'
);
await nativeWsTest.testConnect("ws://192.168.1.237:8081/ws", "your-token", "your-device-id");
// 发送消息
nativeWsTest.send({
command: 'message',
data: { content: 'Test' }
command: "message",
data: { content: "Test" },
});
// 关闭
......@@ -198,15 +204,11 @@ export const HTTP_SERVER: string = "http://192.168.1.237:3000";
export const SOCKET_SERVER: string = "ws://192.168.1.237:8080";
export const wsConfig: WsConfig = {
wsUrl: SOCKET_SERVER,
loginUrl: `${HTTP_SERVER}/login`
wsUrl: SOCKET_SERVER,
loginUrl: `${HTTP_SERVER}/login`,
};
export const WS_LOGIN_URLS: string[] = [
`${HTTP_SERVER}/login`,
`${HTTP_SERVER}/api/login`,
`${HTTP_SERVER}/ws/login`
];
export const WS_LOGIN_URLS: string[] = [`${HTTP_SERVER}/login`, `${HTTP_SERVER}/api/login`, `${HTTP_SERVER}/ws/login`];
```
## 🐛 故障排除
......@@ -214,6 +216,7 @@ export const WS_LOGIN_URLS: string[] = [
### 编译错误
如果遇到编译错误:
1. 检查所有文件是否正确保存
2. 清理编译缓存
3. 重新运行项目
......@@ -221,6 +224,7 @@ export const WS_LOGIN_URLS: string[] = [
### 运行时错误
如果遇到 `NoSuchMethodError` 或 `NoClassDefFoundError`:
1. **必须清理编译缓存**(见快速修复指南)
2. 重新运行项目
3. 如果还不行,卸载应用重装
......@@ -228,6 +232,7 @@ export const WS_LOGIN_URLS: string[] = [
### 连接失败
如果 WebSocket 连接失败:
1. 检查服务端是否运行
2. 确认 IP 地址和端口正确
3. 检查 token 和 deviceId 是否有效
......@@ -238,12 +243,13 @@ export const WS_LOGIN_URLS: string[] = [
### 登录服务器连接失败
如果看到 `Connection refused` 错误:
1. **推荐:使用直接连接方式**(跳过登录)
```typescript
import { quickTestDirectConnect } from '@/ws';
// 修改 ws/direct-test.uts 配置
await quickTestDirectConnect();
```
```typescript
import { quickTestDirectConnect } from "@/ws";
// 修改 ws/direct-test.uts 配置
await quickTestDirectConnect();
```
2. 或者修复登录服务器连接(见故障排除文档)
## 📊 项目结构
......@@ -303,6 +309,7 @@ ws/
## 📞 需要帮助?
如果遇到问题:
1. 查看对应的文档
2. 检查控制台日志
3. 查看服务端日志
......
# Vue3 微前端子应用模板
> 基于 qiankun + Vue3 + Vite + TypeScript 构建的微前端子应用模板
## 📋 目录
- [功能特性](#功能特性)
- [技术栈](#技术栈)
- [快速开始](#快速开始)
- [项目结构](#项目结构)
- [与基座联调](#与基座联调)
- [配置说明](#配置说明)
- [开发指南](#开发指南)
## ✨ 功能特性
- 🚀 **快速启动** - 使用 Vite 构建,HMR 响应迅速
- 🎯 **独立运行** - 支持独立开发和集成运行两种模式
- 🔧 **开箱即用** - 集成路由、状态管理、自动导入等功能
- 💡 **TypeScript** - 完整的类型支持,开发更安全
- 🎨 **现代化 UI** - 精心设计的用户界面和交互体验
- 🔌 **qiankun 集成** - 完整实现 qiankun 生命周期钩子
## 🛠️ 技术栈
- **Vue 3** - 渐进式 JavaScript 框架
- **TypeScript** - 类型安全的 JavaScript 超集
- **Vite** - 新一代前端构建工具
- **Vue Router** - 官方路由管理器
- **Pinia** - 新一代状态管理库
- **qiankun** - 微前端框架
- **vite-plugin-qiankun** - Vite 的 qiankun 插件
## 🚀 快速开始
### 安装依赖
```bash
pnpm install
```
### 启动开发服务器
```bash
pnpm dev
```
访问 `http://localhost:8081` 即可查看应用(独立运行模式)
### 构建生产版本
```bash
pnpm build
```
### 预览生产构建
```bash
pnpm preview
```
## 📁 项目结构
```
micro-app-template/
├── src/
│ ├── views/ # 页面组件
│ │ ├── Home.vue # 首页
│ │ ├── About.vue # 关于页
│ │ ├── User.vue # 用户管理
│ │ ├── Settings.vue # 系统设置
│ │ └── NotFound.vue # 404 页面
│ ├── router/ # 路由配置
│ │ └── index.ts # 路由定义
│ ├── App.vue # 根组件
│ ├── main.ts # 入口文件(包含 qiankun 生命周期)
│ └── style.css # 全局样式
├── index.html # HTML 模板
├── vite.config.ts # Vite 配置(qiankun 集成)
├── tsconfig.json # TypeScript 配置
├── package.json # 项目配置
└── README.md # 项目文档
```
## 🔗 与基座联调
### ⚠️ 重要提示
在启动前,请确保配置正确(已在本次更新中修复):
**子应用配置检查:**
- ✅ `vite.config.ts` - base 配置为 `http://localhost:8081/`
- ✅ `src/router/index.ts` - 导出 `createRouter` 函数
- ✅ `src/main.ts` - 动态创建路由实例
**基座配置检查:**
- ✅ `src/qiankun/apps.ts` - entry 配置为 `http://localhost:8081`
- ✅ `src/views/MicroApp.vue` - 包含 `<div id="subapp-container"></div>`
### 1. 启动子应用
```bash
cd apps/frontend-micro/micro-app-template
pnpm dev
```
子应用会在 `http://localhost:8081` 启动
**验证:**
- 访问 `http://localhost:8081` 应显示子应用
- 控制台显示 "独立运行模式"
### 2. 启动基座应用
```bash
cd apps/frontend-micro/scrm-base
pnpm dev
```
基座会在 `http://localhost:8080` 启动
**验证:**
- 控制台显示 "[qiankun] 微前端框架已启动"
### 3. 在基座中访问子应用
访问 `http://localhost:8080/subapp-vue`,基座会自动加载并挂载子应用
**预期结果:**
- 看到子应用内容(紫色渐变背景)
- 控制台显示生命周期日志
- 运行模式显示 "🔗 基座模式"
**详细测试步骤:** 请查看 [`INTEGRATION_GUIDE.md`](./INTEGRATION_GUIDE.md)
## ⚙️ 配置说明
### 修改子应用端口
在 `vite.config.ts` 中修改 `PORT` 常量:
```typescript
const PORT = 8081; // 修改为你想要的端口
```
### 修改子应用名称
1. 在 `vite.config.ts` 中修改 `APP_NAME`:
```typescript
const APP_NAME = "your-app-name";
```
2. 在基座的 `src/micro-apps.ts` 中添加或修改对应配置:
```typescript
{
name: 'your-app-name',
entry: '//localhost:8081',
container: '#subapp-container',
activeRule: '/your-app-name',
props: {
routerBase: '/your-app-name',
},
}
```
### 路由配置
子应用路由会自动添加基座传递的 `routerBase` 前缀。在独立运行时,路由base为 `/`;在基座中运行时,路由base为基座配置的 `routerBase`(如 `/subapp-vue`)。
## 📝 开发指南
### 独立开发模式
子应用支持完全独立开发,无需启动基座:
```bash
pnpm dev
```
访问 `http://localhost:8081` 进行开发调试
### 集成开发模式
需要测试与基座的集成时:
1. 启动子应用:`pnpm dev`
2. 启动基座:在 scrm-base 目录执行 `pnpm dev`
3. 通过基座访问:`http://localhost:8080/subapp-vue`
### qiankun 生命周期说明
子应用实现了以下 qiankun 生命周期钩子:
- `bootstrap` - 应用初始化,只执行一次
- `mount` - 应用挂载,每次进入都会执行
- `unmount` - 应用卸载,每次离开都会执行
- `update` - 应用更新(可选),主应用下发新 props 时触发
### 环境判断
使用以下方式判断应用是否在 qiankun 环境中运行:
```typescript
import { qiankunWindow } from "vite-plugin-qiankun/dist/helper";
if (qiankunWindow.__POWERED_BY_QIANKUN__) {
console.log("在基座中运行");
} else {
console.log("独立运行");
}
```
## 🔍 常见问题
### 1. 子应用无法加载(白屏)
**原因:**
- 子应用未启动
- entry 地址配置错误
- 容器 ID 不存在
**解决:**
```bash
# 确认子应用运行
curl http://localhost:8081
# 检查基座配置
# scrm-base/src/qiankun/apps.ts
entry: 'http://localhost:8081' // ✅ 使用完整 URL
# 检查容器存在
# scrm-base/src/views/MicroApp.vue
<div id="subapp-container"></div> // ✅ 必须存在
```
### 2. CORS 错误
**控制台显示:**
```
Access to fetch at 'http://localhost:8081/' has been blocked by CORS policy
```
**解决:**
- 确认子应用 `vite.config.ts` 中 `cors: true`
- 确认 headers 配置正确
- 重启子应用服务
### 3. 路由跳转异常
**原因:**
- 路由 base 配置错误
- `routerBase` 未正确传递
**解决:**
```typescript
// ✅ 已修复:子应用动态创建路由
const routerBase = qiankunWindow.__POWERED_BY_QIANKUN__ ? props.routerBase || "/subapp-vue" : "/";
const router = createRouter(routerBase);
```
### 4. 样式冲突
- qiankun 默认开启了样式隔离
- 建议使用 scoped 样式
- 可以在基座的 `start` 配置中调整样式隔离策略
### 5. 生命周期未触发
**原因:**
- 应用名称不一致
- 生命周期钩子未正确导出
**解决:**
```typescript
// vite.config.ts
qiankun("subapp-vue"); // 必须与基座配置一致
// main.ts
export async function bootstrap() {}
export async function mount(props) {}
export async function unmount(props) {}
```
**详细排查指南:** 请查看 [`INTEGRATION_GUIDE.md`](./INTEGRATION_GUIDE.md)
## 📄 License
MIT
## 🤝 贡献
欢迎提交 Issue 和 Pull Request!
<!doctype html>
<html lang="zh-CN" style="
--el-color-primary: #185efe">
<html lang="zh-CN" style="--el-color-primary: #185efe">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
......
{
"$schema": "./component-manifest.schema.json",
"packageName": "@venus/common-ui-vue",
"packageRoot": "packages/common-ui/vue-ui",
"framework": "vue",
"notes": "第一阶段最小组件清单,仅覆盖当前已显式文档化的基础组件,用于后续 AI 组件映射试点。",
"components": [
{
"name": "button",
"exportName": "VButton",
"source": "src/components/VButton.vue",
"category": "action",
"description": "基于 Element Plus 的按钮包装组件,提供统一默认主按钮类型和 block 布局能力。",
"props": [
{
"name": "block",
"type": "boolean",
"description": "是否以整行宽度展示按钮。",
"default": "false"
},
{
"name": "circle",
"type": "boolean",
"description": "是否显示为圆形按钮。"
},
{
"name": "disabled",
"type": "boolean",
"description": "是否禁用按钮。"
},
{
"name": "loading",
"type": "boolean",
"description": "是否展示加载状态。"
},
{
"name": "plain",
"type": "boolean",
"description": "是否使用朴素按钮样式。"
},
{
"name": "round",
"type": "boolean",
"description": "是否显示为圆角按钮。"
},
{
"name": "size",
"type": "'default' | 'large' | 'small'",
"description": "按钮尺寸。"
},
{
"name": "type",
"type": "'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info'",
"description": "按钮视觉类型,未显式指定时默认按 primary 处理。"
}
],
"events": [
{
"name": "click",
"description": "按钮点击事件。",
"payload": "MouseEvent"
}
],
"slots": [
{
"name": "default",
"description": "按钮文本或自定义内容。"
}
],
"figmaMapping": {
"keywords": ["button", "primary action", "secondary action", "cta"],
"nodeTypes": ["COMPONENT", "INSTANCE"],
"variantHints": ["primary", "danger", "loading", "disabled"]
},
"usageGuidance": {
"recommendedScenarios": ["表单提交操作", "卡片或弹窗主操作按钮", "需要整行按钮的移动端入口"],
"avoidScenarios": ["纯文本导航链接", "需要复杂前后缀插槽的按钮排版"],
"dependencies": ["element-plus"]
}
},
{
"name": "input",
"exportName": "VInput",
"source": "src/components/VInput.vue",
"category": "form",
"description": "基于 Element Plus 的输入框包装组件,提供统一外观和常用插槽透传。",
"props": [
{
"name": "block",
"type": "boolean",
"description": "是否按整行宽度展示输入框。",
"default": "false"
},
{
"name": "clearable",
"type": "boolean",
"description": "是否允许一键清空。"
},
{
"name": "disabled",
"type": "boolean",
"description": "是否禁用输入框。"
},
{
"name": "modelValue",
"type": "number | string",
"description": "输入框当前值。"
},
{
"name": "placeholder",
"type": "string",
"description": "占位提示文本。"
},
{
"name": "type",
"type": "string",
"description": "输入框类型,例如 text 或 password。"
}
],
"events": [
{
"name": "update:modelValue",
"description": "输入值变化事件。",
"payload": "number | string"
}
],
"slots": [
{
"name": "prepend",
"description": "输入框前置区域。"
},
{
"name": "append",
"description": "输入框后置区域。"
},
{
"name": "prefix",
"description": "输入框内部前缀内容。"
},
{
"name": "suffix",
"description": "输入框内部后缀内容。"
}
],
"figmaMapping": {
"keywords": ["input", "text field", "form input", "search input", "password field"],
"nodeTypes": ["COMPONENT", "FRAME", "INSTANCE"],
"variantHints": ["with prepend", "with suffix", "password", "disabled"]
},
"usageGuidance": {
"recommendedScenarios": ["表单基础输入项", "登录页账号密码输入", "需要前后缀内容的输入场景"],
"avoidScenarios": ["富文本输入", "多行文本编辑", "复杂搜索工具条的完整封装"],
"dependencies": ["element-plus"]
}
}
]
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://venus.local/contracts/ai/component-manifest.schema.json",
"type": "object",
"required": ["packageName", "packageRoot", "framework", "components"],
"properties": {
"packageName": { "type": "string" },
"packageRoot": { "type": "string" },
"framework": { "type": "string", "enum": ["react", "shared", "vue"] },
"notes": { "type": "string" },
"components": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/component" }
}
},
"additionalProperties": false,
"$defs": {
"prop": {
"type": "object",
"required": ["name", "type", "description"],
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"description": { "type": "string" },
"required": { "type": "boolean" },
"default": { "type": "string" }
},
"additionalProperties": false
},
"event": {
"type": "object",
"required": ["name", "description"],
"properties": {
"name": { "type": "string" },
"description": { "type": "string" },
"payload": { "type": "string" }
},
"additionalProperties": false
},
"slot": {
"type": "object",
"required": ["name", "description"],
"properties": {
"name": { "type": "string" },
"description": { "type": "string" }
},
"additionalProperties": false
},
"figmaMapping": {
"type": "object",
"required": ["keywords", "nodeTypes"],
"properties": {
"keywords": {
"type": "array",
"items": { "type": "string" }
},
"nodeTypes": {
"type": "array",
"items": { "type": "string" }
},
"variantHints": {
"type": "array",
"items": { "type": "string" }
}
},
"additionalProperties": false
},
"usageGuidance": {
"type": "object",
"required": ["recommendedScenarios"],
"properties": {
"recommendedScenarios": {
"type": "array",
"items": { "type": "string" }
},
"avoidScenarios": {
"type": "array",
"items": { "type": "string" }
},
"dependencies": {
"type": "array",
"items": { "type": "string" }
}
},
"additionalProperties": false
},
"component": {
"type": "object",
"required": ["name", "exportName", "source", "category", "description", "figmaMapping", "usageGuidance"],
"properties": {
"name": { "type": "string" },
"exportName": { "type": "string" },
"source": { "type": "string" },
"category": { "type": "string" },
"description": { "type": "string" },
"props": {
"type": "array",
"items": { "$ref": "#/$defs/prop" }
},
"events": {
"type": "array",
"items": { "$ref": "#/$defs/event" }
},
"slots": {
"type": "array",
"items": { "$ref": "#/$defs/slot" }
},
"figmaMapping": { "$ref": "#/$defs/figmaMapping" },
"usageGuidance": { "$ref": "#/$defs/usageGuidance" }
},
"additionalProperties": false
}
}
}
{
"$schema": "../page-schema.schema.json",
"pageId": "user-management-list",
"title": "User Management",
"intent": "list",
"source": {
"kind": "manual",
"reference": "Standard admin list page pilot"
},
"route": {
"path": "/users",
"name": "UserManagementList",
"requiresAuth": true,
"menuTitle": "Users"
},
"layout": {
"shell": "list",
"responsive": true,
"columns": 1
},
"sections": [
{
"id": "filters",
"name": "Filters",
"purpose": "Collect search and filter criteria before querying the table.",
"blocks": [
{
"id": "filter-form",
"kind": "form",
"title": "Search Users",
"componentHint": "FilterToolbar",
"fields": [
{
"id": "keyword",
"label": "Keyword",
"type": "text",
"componentHint": "VInput"
},
{
"id": "status",
"label": "Status",
"type": "select",
"componentHint": "StatusSelect"
}
],
"actions": [
{
"id": "search",
"label": "Search",
"kind": "submit",
"componentHint": "VButton"
},
{
"id": "reset",
"label": "Reset",
"kind": "toggle",
"componentHint": "VButton"
}
]
}
]
},
{
"id": "results",
"name": "Results",
"purpose": "Display queried user records and row-level operations.",
"blocks": [
{
"id": "toolbar-actions",
"kind": "actions",
"title": "Page Actions",
"actions": [
{
"id": "create-user",
"label": "Create User",
"kind": "dialog",
"componentHint": "VButton"
}
]
},
{
"id": "user-table",
"kind": "table",
"title": "User Table",
"description": "Table with pagination, status badge and row actions.",
"componentHint": "DataTable",
"actions": [
{
"id": "view-user",
"label": "View",
"kind": "navigate",
"componentHint": "VButton"
},
{
"id": "edit-user",
"label": "Edit",
"kind": "dialog",
"componentHint": "VButton"
}
]
}
]
}
],
"dataRequirements": [
{
"id": "users-query",
"kind": "query",
"name": "fetchUsers",
"description": "Fetch paginated user list with keyword and status filters."
},
{
"id": "create-user-mutation",
"kind": "mutation",
"name": "createUser",
"description": "Create a user from the toolbar dialog."
}
],
"notes": "Pilot page schema for list-page generation. Blocks are intentionally simple and can be extended later."
}
{
"projectName": "@venus/venus-agentic-base",
"projectRoot": "D:/work/venus/apps/web/venus-agentic/venus-agentic-base",
"framework": "micro-frontend",
"appType": "micro-app",
"workspace": {
"inWorkspace": true,
"workspaceRoot": "D:/work/venus",
"packageName": "@venus/venus-agentic-base",
"packageManager": "pnpm"
},
"directories": {
"srcDir": "src",
"componentDirs": ["src/components"],
"pageDirs": ["src/views"],
"routeFiles": ["src/router/index.ts"],
"storeFiles": [
"src/stores/app.ts",
"src/stores/index.ts",
"src/stores/menu.ts",
"src/stores/permission.ts",
"src/stores/user.ts"
],
"styleDirs": ["src/styles"]
},
"routing": {
"solution": "vue-router",
"menuCoupled": true,
"requiresRegistration": true
},
"stateManagement": {
"solution": "pinia",
"persistence": false
},
"uiStack": {
"componentPackages": ["@venus/common-ui-vue", "element-plus"],
"primaryLibrary": "@venus/common-ui-vue",
"tokenSource": "venus-component-library"
},
"qualityGates": {
"lint": "pnpm lint",
"typecheck": "pnpm run check:type",
"templateContract": "pnpm run check:template-contract",
"reviewTrigger": "pnpm run review:trigger",
"fitness": "pnpm run check:fitness -- --tier fast"
},
"constraints": [
"changes must respect workspace-level quality gates",
"route and shell integration must remain qiankun-compatible",
"prefer existing @venus/common-ui-vue components before introducing raw UI markup",
"new pages should include route registration planning",
"state additions should align with the current pinia store layout"
],
"notes": "Generated by the project-intelligence pilot reader. Refine fields as more project patterns are covered."
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://venus.local/contracts/ai/page-schema.schema.json",
"type": "object",
"required": ["pageId", "title", "source", "layout", "sections"],
"properties": {
"pageId": { "type": "string" },
"title": { "type": "string" },
"intent": {
"type": "string",
"enum": ["dashboard", "detail", "form", "list", "settings", "unknown"]
},
"source": { "$ref": "#/$defs/source" },
"route": { "$ref": "#/$defs/route" },
"layout": { "$ref": "#/$defs/layout" },
"sections": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/section" }
},
"dataRequirements": {
"type": "array",
"items": { "$ref": "#/$defs/dataRequirement" }
},
"notes": { "type": "string" }
},
"additionalProperties": false,
"$defs": {
"source": {
"type": "object",
"required": ["kind"],
"properties": {
"kind": {
"type": "string",
"enum": ["figma-frame", "manual", "mixed", "requirement-text"]
},
"reference": { "type": "string" },
"frameName": { "type": "string" }
},
"additionalProperties": false
},
"route": {
"type": "object",
"properties": {
"path": { "type": "string" },
"name": { "type": "string" },
"requiresAuth": { "type": "boolean" },
"menuTitle": { "type": "string" }
},
"additionalProperties": false
},
"layout": {
"type": "object",
"required": ["shell"],
"properties": {
"shell": {
"type": "string",
"enum": ["blank", "dashboard", "detail", "form", "list", "workspace"]
},
"responsive": { "type": "boolean" },
"columns": { "type": "integer", "minimum": 1 }
},
"additionalProperties": false
},
"action": {
"type": "object",
"required": ["id", "label", "kind"],
"properties": {
"id": { "type": "string" },
"label": { "type": "string" },
"kind": {
"type": "string",
"enum": ["dialog", "navigate", "request", "submit", "toggle"]
},
"componentHint": { "type": "string" }
},
"additionalProperties": false
},
"field": {
"type": "object",
"required": ["id", "label", "type"],
"properties": {
"id": { "type": "string" },
"label": { "type": "string" },
"type": {
"type": "string",
"enum": ["date", "number", "select", "switch", "text", "textarea"]
},
"required": { "type": "boolean" },
"componentHint": { "type": "string" }
},
"additionalProperties": false
},
"block": {
"type": "object",
"required": ["id", "kind"],
"properties": {
"id": { "type": "string" },
"kind": {
"type": "string",
"enum": [
"actions",
"card",
"chart",
"container",
"description",
"form",
"hero",
"list",
"stats",
"table",
"text"
]
},
"title": { "type": "string" },
"description": { "type": "string" },
"componentHint": { "type": "string" },
"figmaNodeId": { "type": "string" },
"fields": {
"type": "array",
"items": { "$ref": "#/$defs/field" }
},
"actions": {
"type": "array",
"items": { "$ref": "#/$defs/action" }
},
"children": {
"type": "array",
"items": { "$ref": "#/$defs/block" }
},
"tokenRefs": {
"type": "array",
"items": { "type": "string" }
}
},
"additionalProperties": false
},
"section": {
"type": "object",
"required": ["id", "name", "blocks"],
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"purpose": { "type": "string" },
"blocks": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/block" }
}
},
"additionalProperties": false
},
"dataRequirement": {
"type": "object",
"required": ["id", "kind", "name"],
"properties": {
"id": { "type": "string" },
"kind": {
"type": "string",
"enum": ["mutation", "query", "static"]
},
"name": { "type": "string" },
"description": { "type": "string" }
},
"additionalProperties": false
}
}
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://venus.local/contracts/ai/project-context.schema.json",
"type": "object",
"required": ["projectName", "projectRoot", "workspace", "framework", "directories", "qualityGates"],
"properties": {
"projectName": { "type": "string" },
"projectRoot": { "type": "string" },
"framework": {
"type": "string",
"enum": ["micro-frontend", "react", "shared", "uniappX", "unknown", "vue"]
},
"appType": {
"type": "string",
"enum": ["admin", "library", "micro-app", "template-output", "tooling", "unknown"]
},
"workspace": { "$ref": "#/$defs/workspace" },
"directories": { "$ref": "#/$defs/directories" },
"routing": { "$ref": "#/$defs/routing" },
"stateManagement": { "$ref": "#/$defs/stateManagement" },
"uiStack": { "$ref": "#/$defs/uiStack" },
"qualityGates": { "$ref": "#/$defs/qualityGates" },
"constraints": {
"type": "array",
"items": { "type": "string" }
},
"notes": { "type": "string" }
},
"additionalProperties": false,
"$defs": {
"workspace": {
"type": "object",
"required": ["inWorkspace"],
"properties": {
"inWorkspace": { "type": "boolean" },
"workspaceRoot": { "type": "string" },
"packageName": { "type": "string" },
"packageManager": {
"type": "string",
"enum": ["npm", "pnpm", "unknown", "yarn"]
}
},
"additionalProperties": false
},
"directories": {
"type": "object",
"required": ["srcDir"],
"properties": {
"srcDir": { "type": "string" },
"componentDirs": {
"type": "array",
"items": { "type": "string" }
},
"pageDirs": {
"type": "array",
"items": { "type": "string" }
},
"routeFiles": {
"type": "array",
"items": { "type": "string" }
},
"storeFiles": {
"type": "array",
"items": { "type": "string" }
},
"styleDirs": {
"type": "array",
"items": { "type": "string" }
}
},
"additionalProperties": false
},
"routing": {
"type": "object",
"properties": {
"solution": {
"type": "string",
"enum": ["file-based", "manual", "react-router", "unknown", "vue-router"]
},
"menuCoupled": { "type": "boolean" },
"requiresRegistration": { "type": "boolean" }
},
"additionalProperties": false
},
"stateManagement": {
"type": "object",
"properties": {
"solution": {
"type": "string",
"enum": ["none", "pinia", "redux", "unknown", "zustand"]
},
"persistence": { "type": "boolean" }
},
"additionalProperties": false
},
"uiStack": {
"type": "object",
"properties": {
"componentPackages": {
"type": "array",
"items": { "type": "string" }
},
"primaryLibrary": { "type": "string" },
"tokenSource": { "type": "string" }
},
"additionalProperties": false
},
"qualityGates": {
"type": "object",
"required": ["lint"],
"properties": {
"lint": { "type": "string" },
"typecheck": { "type": "string" },
"templateContract": { "type": "string" },
"reviewTrigger": { "type": "string" },
"fitness": { "type": "string" }
},
"additionalProperties": false
}
}
}
{
"$schema": "./template-contract.schema.json",
"template": "react",
"templateRoot": "packages/cli/templates/react",
"baseFiles": ["package.json", "index.html", "tsconfig.json", "vite.config.ts", "src/App.tsx", "src/main.tsx"],
"features": {
"router": {
"featurePath": "optional/router",
"overlayFiles": ["_package.merge.json", "src/main.tsx"],
"mergedPackageRequirements": {
"dependencies": ["react-router-dom"]
}
},
"store": {
"featurePath": "optional/store",
"overlayFiles": ["_package.merge.json", "src/components/Counter.tsx", "src/store/counter.ts"],
"mergedPackageRequirements": {
"dependencies": ["zustand"]
}
},
"ui": {
"variants": {
"antd": {
"featurePath": "optional/ui/antd",
"overlayFiles": ["_package.merge.json", "src/ui.tsx"],
"mergedPackageRequirements": {
"dependencies": ["antd"]
}
}
}
},
"eslint": {
"featurePath": "optional/eslint",
"overlayFiles": ["_package.merge.json", "eslint.config.mjs"],
"mergedPackageRequirements": {
"devDependencies": ["eslint", "@venus/eslint-config"],
"scripts": ["lint", "lint:fix"]
}
}
}
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://venus.local/contracts/template-contract.schema.json",
"type": "object",
"required": ["template", "templateRoot", "baseFiles", "features"],
"properties": {
"template": { "type": "string" },
"templateRoot": { "type": "string" },
"baseFiles": {
"type": "array",
"items": { "type": "string" }
},
"features": {
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/feature"
}
}
},
"$defs": {
"packageRequirements": {
"type": "object",
"properties": {
"dependencies": { "type": "array", "items": { "type": "string" } },
"devDependencies": { "type": "array", "items": { "type": "string" } },
"scripts": { "type": "array", "items": { "type": "string" } }
},
"additionalProperties": false
},
"feature": {
"type": "object",
"properties": {
"featurePath": { "type": "string" },
"overlayFiles": { "type": "array", "items": { "type": "string" } },
"mergedPackageRequirements": { "$ref": "#/$defs/packageRequirements" },
"variants": {
"type": "object",
"additionalProperties": {
"type": "object",
"required": ["featurePath", "overlayFiles"],
"properties": {
"featurePath": { "type": "string" },
"overlayFiles": { "type": "array", "items": { "type": "string" } },
"mergedPackageRequirements": { "$ref": "#/$defs/packageRequirements" }
},
"additionalProperties": false
}
}
},
"additionalProperties": false,
"anyOf": [{ "required": ["featurePath", "overlayFiles"] }, { "required": ["variants"] }]
}
}
}
{
"$schema": "./template-contract.schema.json",
"template": "vue",
"templateRoot": "packages/cli/templates/vue",
"baseFiles": [
"package.json",
"index.html",
"tsconfig.json",
"tsconfig.node.json",
"vite.config.ts",
"src/App.vue",
"src/main.ts"
],
"features": {
"axios": {
"featurePath": "optional/axios",
"overlayFiles": ["_package.merge.json"],
"mergedPackageRequirements": {
"dependencies": ["axios"]
}
},
"router": {
"featurePath": "optional/router",
"overlayFiles": ["_package.merge.json", "src/router.ts"],
"mergedPackageRequirements": {
"dependencies": ["vue-router"]
}
},
"store": {
"featurePath": "optional/store",
"overlayFiles": ["_package.merge.json", "src/store/index.ts"],
"mergedPackageRequirements": {
"dependencies": ["pinia"]
}
},
"ui": {
"variants": {
"element-plus": {
"featurePath": "optional/ui/element-plus",
"overlayFiles": ["_package.merge.json", "src/ui.ts"],
"mergedPackageRequirements": {
"dependencies": ["element-plus"]
}
}
}
},
"eslint": {
"featurePath": "optional/eslint",
"overlayFiles": ["_package.merge.json", "eslint.config.mjs"],
"mergedPackageRequirements": {
"devDependencies": ["eslint", "@venus/eslint-config"],
"scripts": ["lint", "lint:fix"]
}
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!