- API 路由统一: 移除 /api/h5/,统一 /api/pms/ 入口 - 二进制改名: api-server -> pms-api(与服务名一致) - nginx: 合并 /api/ + /pms/api/ 为 /api/pms/ - 新增 docs/API.md 接口文档 - 后端: CabinetDetail 增加 rssi/pow_fail/address/soc 等字段 - Redis 管道批量读取仓体实时数据(SOC/电压/电流/功率) - DB: 所有 TIMESTAMP 列改为 DATETIME(修复类型不匹配) - 用户管理: 新增创建时间/修改时间列,状态改用 Switch - 角色管理/用户管理: 操作按钮改为图标 - PC 设备详情: 基本信息补全 RSSI/ICCID/电源/地址 - PC 卡片: 通道统计改用 Lucide 图标,颜色统一 - PC 二维码: canvas 渲染,含编号文字,支持右键下载 - H5: 按 uni-app 规范修正导航(navigateTo 替代 reLaunch) - H5: 详情页加返回导航条 - H5: 扫码支持摄像头(jsQR)+ ?id= 参数 - H5: 底部 tabBar 在所有页面常显 - H5: 首页统计改为 6 项(设备/通道/空闲/充电/充满/故障) - H5: 下拉刷新 / 上拉加载 - 产品首页: 添加业务联系 - 文档: 清理过时文件,补充缺失规范章节
2.8 KiB
2.8 KiB
title, impact, impactDescription, type, tags
| title | impact | impactDescription | type | tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| Use Single-File Components with Build Tools | MEDIUM | SFCs provide better DX, scoped styles, and tooling support for Vue applications | efficiency |
|
Use Single-File Components with Build Tools
Impact: MEDIUM - Single-File Components (SFCs) are the recommended way to author Vue components when using a build setup. They provide better organization, scoped styles, and superior tooling support.
SFCs (.vue files) encapsulate template, logic, and styles in a single file. While Vue can work without build tools, SFCs unlock the full power of the framework including <script setup>, scoped CSS, and better IDE support.
Task Checklist
- Use
.vuefiles for components when you have a build setup (Vite, Vue CLI) - Prefer
<script setup>syntax for Composition API - less boilerplate - Use
<style scoped>to prevent CSS leaking between components - Configure IDE with Volar extension for Vue 3 (not Vetur)
Incorrect:
// Defining components without SFC in a build project
// Loses benefits of scoped styles, template compilation, and tooling
// component.js
export default {
template: `
<div class="container">
<h1>{{ title }}</h1>
<button @click="handleClick">Click me</button>
</div>
`,
data() {
return { title: 'Hello' }
},
methods: {
handleClick() { /* ... */ }
}
}
Correct:
<!-- Component.vue - Single-File Component -->
<script setup>
import { ref } from 'vue'
const title = ref('Hello')
function handleClick() {
// ...
}
</script>
<template>
<div class="container">
<h1>{{ title }}</h1>
<button @click="handleClick">Click me</button>
</div>
</template>
<style scoped>
/* Styles only apply to this component */
.container {
padding: 1rem;
}
h1 {
color: #42b883;
}
</style>
SFC Benefits
| Feature | Without SFC | With SFC |
|---|---|---|
| Template syntax highlighting | No | Yes |
| Scoped CSS | Manual (CSS Modules) | Built-in |
| TypeScript support | Basic | Full with Volar |
| Hot Module Replacement | Limited | Full support |
| Build-time optimizations | None | Template compilation |
| IDE autocompletion | Limited | Full support |
When NOT to Use SFCs
<!-- Progressive enhancement - adding Vue to existing HTML -->
<!-- SFCs not needed here -->
<div id="app">
<button @click="count++">{{ count }}</button>
</div>
<script type="module">
import { createApp, ref } from 'vue'
createApp({
setup() {
return { count: ref(0) }
}
}).mount('#app')
</script>