neo-cmp-cli 1.12.7 → 1.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -6
- package/dist/index2.js +1 -1
- package/dist/neo/env.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/{neo-bi-cmps → asset-manage-template}/README.md +65 -10
- package/template/asset-manage-template/docs/README.md +244 -0
- package/template/asset-manage-template/neo.config.js +60 -0
- package/template/{neo-bi-cmps → asset-manage-template}/package.json +28 -16
- package/template/asset-manage-template/src/assets/img/chart.svg +1 -0
- package/template/asset-manage-template/src/components/README.md +3 -0
- package/template/asset-manage-template/src/components/assetManage__c/assetApi.ts +70 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetCreateModal.tsx +260 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetGrid.tsx +48 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetSidebar.tsx +74 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetToolbar.tsx +79 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/assetDisplay.tsx +72 -0
- package/template/asset-manage-template/src/components/assetManage__c/constants.ts +28 -0
- package/template/asset-manage-template/src/components/assetManage__c/index.tsx +258 -0
- package/template/asset-manage-template/src/components/assetManage__c/model.ts +75 -0
- package/template/asset-manage-template/src/components/assetManage__c/style.scss +425 -0
- package/template/asset-manage-template/src/components/assetManage__c/types.ts +60 -0
- package/template/asset-manage-template/src/components/bidList__c/cmps/BidCard.tsx +47 -0
- package/template/asset-manage-template/src/components/bidList__c/constants.ts +6 -0
- package/template/asset-manage-template/src/components/bidList__c/formatUtils.ts +14 -0
- package/template/asset-manage-template/src/components/bidList__c/index.tsx +194 -0
- package/template/asset-manage-template/src/components/bidList__c/model.ts +57 -0
- package/template/asset-manage-template/src/components/bidList__c/style.scss +179 -0
- package/template/asset-manage-template/src/components/bidList__c/types.ts +10 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/BidPackageHeader.tsx +140 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/PackageItemTable.tsx +148 -0
- package/template/asset-manage-template/src/components/bidPackage__c/index.tsx +394 -0
- package/template/asset-manage-template/src/components/bidPackage__c/mainTableColumns.tsx +57 -0
- package/template/asset-manage-template/src/components/bidPackage__c/model.ts +86 -0
- package/template/asset-manage-template/src/components/bidPackage__c/style.scss +256 -0
- package/template/asset-manage-template/src/components/bidPackage__c/types.ts +35 -0
- package/template/asset-manage-template/src/components/bidPackage__c/utils.ts +19 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/axiosFetcher.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/queryObjectData.ts +0 -0
- package/template/asset-manage-template/src/utils/url.ts +82 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/xobjects.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/tsconfig.json +1 -1
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/empty-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +62 -6
- package/template/neo-h5-cmps/neo.config.js +34 -76
- package/template/neo-h5-cmps/package.json +7 -3
- package/template/neo-h5-cmps/src/components/entityList__c/index.tsx +0 -4
- package/template/neo-h5-cmps/src/components/entityList__c/model.ts +10 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/index.tsx +29 -17
- package/template/neo-h5-cmps/src/components/entityTabs__c/model.ts +25 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/style.scss +11 -22
- package/template/neo-h5-cmps/src/components/openChatPageBtn__c/index.tsx +3 -1
- package/template/neo-h5-cmps/src/utils/xobjects.ts +8 -3
- package/template/neo-h5-cmps/tsconfig.json +1 -1
- package/template/neo-order-cmps/package.json +2 -2
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/template/develop/BI /351/241/271/347/233/256/345/210/206/346/236/220/346/212/245/345/221/212.md" +0 -562
- package/template/develop/ChatPage /347/273/204/344/273/266/344/275/277/347/224/250/350/257/264/346/230/216/346/226/207/346/241/243.md" +0 -507
- package/template/develop/EntityGrid Web /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -868
- package/template/develop/EntityList H5 /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -1386
- package/template/develop/GlobalSearch/347/273/204/344/273/266/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -866
- package/template/develop/Neo /344/270/255/345/217/257/347/224/250 amis /347/273/204/344/273/266.md" +0 -1490
- package/template/develop/cmpEventFunctions.ts +0 -257
- package/template/develop/cmpEvents.ts +0 -864
- package/template/develop/comTree/347/224/237/346/210/220/350/277/207/347/250/213/345/210/206/346/236/220.md +0 -469
- package/template/develop/commonModules.js +0 -55
- package/template/develop/components-table.md +0 -50
- package/template/develop/neo-custom-cmp-template/README.md +0 -48
- package/template/develop/neo-custom-cmp-template/docs/README.md +0 -13
- package/template/develop/neo-custom-cmp-template/neo.config.js +0 -121
- package/template/develop/neo-custom-cmp-template/package.json +0 -63
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/README.md +0 -65
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/index.tsx +0 -180
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/model.ts +0 -50
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/style.scss +0 -260
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/README.md +0 -94
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/index.tsx +0 -252
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/model.ts +0 -56
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/style.scss +0 -120
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/README.md +0 -115
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/index.tsx +0 -304
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/model.ts +0 -87
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/style.scss +0 -127
- package/template/develop/neo-custom-cmp-template/src/utils/axiosFetcher.ts +0 -29
- package/template/develop/neo-custom-cmp-template/src/utils/queryObjectData.ts +0 -39
- package/template/develop/neo-custom-cmp-template/src/utils/xobjects.ts +0 -203
- package/template/develop/neo-custom-cmp-template/tsconfig.json +0 -68
- package/template/develop/neo-ui-component-h5.md +0 -105
- package/template/develop/neo-ui-component-web-xregister.md +0 -31
- package/template/develop/neo-ui-component-web.md +0 -292
- package/template/develop/neoCmps.ts +0 -7508
- package/template/develop/neoGlobalSearchInput /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -497
- package/template/develop/pageSchema1.json +0 -744
- package/template/develop//344/272/213/344/273/266/345/212/250/344/275/234/344/277/235/345/255/230/346/265/201/347/250/213/345/210/206/346/236/220.md +0 -390
- package/template/develop//345/215/225/345/205/203/346/265/213/350/257/225/344/275/277/347/224/250/350/257/264/346/230/216.md +0 -1139
- package/template/neo-bi-cmps/.prettierrc.js +0 -12
- package/template/neo-bi-cmps/commitlint.config.js +0 -59
- package/template/neo-bi-cmps/neo.config.js +0 -124
- package/template/neo-bi-cmps/public/css/base.css +0 -283
- package/template/neo-bi-cmps/public/scripts/app/bluebird.js +0 -6679
- package/template/neo-bi-cmps/public/template.html +0 -13
- package/template/neo-bi-cmps/src/assets/css/common.scss +0 -127
- package/template/neo-bi-cmps/src/assets/css/mixin.scss +0 -47
- package/template/neo-bi-cmps/src/assets/img/NeoCRM.jpg +0 -0
- package/template/neo-bi-cmps/src/assets/img/custom-widget.svg +0 -1
- package/template/neo-bi-cmps/src/assets/img/favicon.png +0 -0
- package/template/neo-bi-cmps/src/assets/img/table.svg +0 -1
- package/template/neo-bi-cmps/src/components/targetNumber__c/README.md +0 -100
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/configSchema.ts +0 -253
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.scss +0 -76
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.tsx +0 -148
- package/template/neo-bi-cmps/src/components/targetNumber__c/index.tsx +0 -440
- package/template/neo-bi-cmps/src/components/targetNumber__c/model.ts +0 -128
- package/template/neo-bi-cmps/src/components/targetNumber__c/style.scss +0 -173
- package/template/neo-h5-cmps/src/components/simpleTable__c/README.md +0 -90
- package/template/neo-h5-cmps/src/components/simpleTable__c/index.tsx +0 -277
- package/template/neo-h5-cmps/src/components/simpleTable__c/model.ts +0 -91
- package/template/neo-h5-cmps/src/components/simpleTable__c/style.scss +0 -116
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/@types/neo-ui-common.d.ts +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/commitlint.config.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/css/base.css +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/scripts/app/bluebird.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/template.html +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/common.scss +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/AIBtn.gif +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/aiLogo.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/card-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/contact-form.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/custom-form.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/data-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/detail.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/map.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/search.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/table.svg +0 -0
|
@@ -1,497 +0,0 @@
|
|
|
1
|
-
# neoGlobalSearchInput 组件详细分析文档
|
|
2
|
-
|
|
3
|
-
## 一、组件概述
|
|
4
|
-
|
|
5
|
-
### 1.1 组件简介
|
|
6
|
-
|
|
7
|
-
`neoGlobalSearchInput` 是一个全局搜索输入框组件,用于 H5 端(移动端)的全局搜索功能入口。该组件提供了一个可点击的搜索框,用户点击后会跳转到全局搜索页面进行搜索操作。
|
|
8
|
-
|
|
9
|
-
### 1.2 组件定位
|
|
10
|
-
|
|
11
|
-
- **组件类型**:业务组件(H5 端)
|
|
12
|
-
- **组件分类**:List 组件下的 GlobalSearchList 子组件
|
|
13
|
-
- **组件名称**:`neoGlobalSearchInput`
|
|
14
|
-
- **注册名称**:`neoGlobalSearchInput`(在 Neo UI 框架中的唯一标识)
|
|
15
|
-
- **别名映射**:`xsyGlobalSearchInput` → `neoGlobalSearchInput`(用于首页组件映射)
|
|
16
|
-
|
|
17
|
-
### 1.3 核心特性
|
|
18
|
-
|
|
19
|
-
1. **权限控制**:根据用户权限动态显示/隐藏搜索框
|
|
20
|
-
2. **点击跳转**:点击搜索框跳转到全局搜索页面
|
|
21
|
-
3. **新旧版本兼容**:支持新旧两种全局搜索模式切换
|
|
22
|
-
4. **国际化支持**:支持多语言显示
|
|
23
|
-
5. **Amis 集成**:基于 Amis 框架的 ScopedContext 机制
|
|
24
|
-
|
|
25
|
-
## 二、目录结构
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
neoGlobalSearchInput/
|
|
29
|
-
├── index.tsx # 组件注册文件
|
|
30
|
-
├── component.tsx # 组件主实现文件
|
|
31
|
-
├── interface.tsx # 接口定义文件
|
|
32
|
-
└── styled.ts # 样式定义文件
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 2.1 文件说明
|
|
36
|
-
|
|
37
|
-
| 文件名 | 说明 | 关键内容 |
|
|
38
|
-
|--------|------|----------|
|
|
39
|
-
| `index.tsx` | 组件注册入口 | 使用 `NeoRegister` 注册组件 |
|
|
40
|
-
| `component.tsx` | 组件核心实现 | 包含组件逻辑、生命周期、渲染方法 |
|
|
41
|
-
| `interface.tsx` | 接口定义 | 定义组件的 Props 接口 |
|
|
42
|
-
| `styled.ts` | 样式定义 | 使用 styled-components 定义样式 |
|
|
43
|
-
|
|
44
|
-
## 三、核心功能分析
|
|
45
|
-
|
|
46
|
-
### 3.1 组件注册
|
|
47
|
-
|
|
48
|
-
组件通过 `NeoRegister` 进行注册,注册名称为 `neoGlobalSearchInput`:
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
import { NeoRegister } from 'neo-ui-common'
|
|
52
|
-
NeoRegister({
|
|
53
|
-
name: 'neoGlobalSearchInput'
|
|
54
|
-
})(() => import('./component'))
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### 3.2 组件类结构
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
export default class GlobalSearchInput<T> extends React.Component<
|
|
61
|
-
GlobalSearchInputProps & T,
|
|
62
|
-
ObjectFormState
|
|
63
|
-
>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
- **泛型参数**:`T` - 支持扩展的 Props 类型
|
|
67
|
-
- **继承**:`React.Component`
|
|
68
|
-
- **Props**:`GlobalSearchInputProps & T`
|
|
69
|
-
- **State**:`ObjectFormState`(空对象)
|
|
70
|
-
|
|
71
|
-
### 3.3 ScopedContext 集成
|
|
72
|
-
|
|
73
|
-
组件集成了 Amis 的 `ScopedContext`,用于组件注册和注销:
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
static contextType = ScopedContext
|
|
77
|
-
|
|
78
|
-
componentWillMount() {
|
|
79
|
-
const scoped = this.context as IScopedContext
|
|
80
|
-
scoped.registerComponent(this)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
componentWillUnmount() {
|
|
84
|
-
const scoped = this.context as IScopedContext
|
|
85
|
-
scoped.unRegisterComponent(this)
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**作用**:
|
|
90
|
-
- 在组件挂载时注册到 Amis 的作用域上下文
|
|
91
|
-
- 在组件卸载时从作用域上下文中注销
|
|
92
|
-
- 便于 Amis 框架管理组件生命周期和通信
|
|
93
|
-
|
|
94
|
-
### 3.4 搜索框配置(pageScheme)
|
|
95
|
-
|
|
96
|
-
组件通过 `pageScheme` 方法返回搜索框的配置:
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
pageScheme = () => {
|
|
100
|
-
return {
|
|
101
|
-
type: 'neoSearchBar', // 使用 neoSearchBar 组件
|
|
102
|
-
backgroundColor: '#FFFFFF', // 背景色为白色
|
|
103
|
-
disableCancel: true, // 禁用取消按钮
|
|
104
|
-
disabled: true, // 禁用输入(仅作为入口)
|
|
105
|
-
onClick: () => { // 点击事件处理
|
|
106
|
-
const isNewGlobal = getNeoContext('globalSearchUpgrade2024Enabled')
|
|
107
|
-
NeoNavigator.openUniversalPage({
|
|
108
|
-
pageType: 'GlobalSearchHome',
|
|
109
|
-
stateParams: {
|
|
110
|
-
type: isNewGlobal ? 'neoGlobalSearchHome' : 'GlobalSearchHome'
|
|
111
|
-
}
|
|
112
|
-
})
|
|
113
|
-
},
|
|
114
|
-
placeholder: kiwiIntl('neo.global.search', '全局搜索')
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**配置说明**:
|
|
120
|
-
|
|
121
|
-
| 属性 | 类型 | 说明 |
|
|
122
|
-
|------|------|------|
|
|
123
|
-
| `type` | `string` | 组件类型,使用 `neoSearchBar` |
|
|
124
|
-
| `backgroundColor` | `string` | 搜索框背景颜色 |
|
|
125
|
-
| `disableCancel` | `boolean` | 是否禁用取消按钮 |
|
|
126
|
-
| `disabled` | `boolean` | 是否禁用输入框(设置为 true,仅作为入口) |
|
|
127
|
-
| `onClick` | `function` | 点击搜索框时的回调函数 |
|
|
128
|
-
| `placeholder` | `string` | 搜索框占位符文本(支持国际化) |
|
|
129
|
-
|
|
130
|
-
### 3.5 权限控制
|
|
131
|
-
|
|
132
|
-
组件在渲染时会检查用户的全局搜索权限:
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
render() {
|
|
136
|
-
// 没有全局搜索职能权限时,隐藏搜索框
|
|
137
|
-
const globalSearchPermission = getNeoContext('globalSearchPermission')
|
|
138
|
-
if (!globalSearchPermission) {
|
|
139
|
-
return null
|
|
140
|
-
}
|
|
141
|
-
// ... 正常渲染
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
**权限检查逻辑**:
|
|
146
|
-
- 通过 `getNeoContext('globalSearchPermission')` 获取权限配置
|
|
147
|
-
- 如果没有权限,组件返回 `null`,不渲染任何内容
|
|
148
|
-
- 有权限时,正常渲染搜索框
|
|
149
|
-
|
|
150
|
-
### 3.6 新旧版本兼容
|
|
151
|
-
|
|
152
|
-
组件支持新旧两种全局搜索模式的切换:
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
const isNewGlobal = getNeoContext('globalSearchUpgrade2024Enabled')
|
|
156
|
-
NeoNavigator.openUniversalPage({
|
|
157
|
-
pageType: 'GlobalSearchHome',
|
|
158
|
-
stateParams: {
|
|
159
|
-
// 旧的全局搜索,企微入口用的是GlobalSearchHome组件,APP用的GlobalSearchList组件
|
|
160
|
-
// 新的全局搜索,统一使用neoGlobalSearchHome
|
|
161
|
-
type: isNewGlobal ? 'neoGlobalSearchHome' : 'GlobalSearchHome'
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
**版本切换逻辑**:
|
|
167
|
-
- 通过 `globalSearchUpgrade2024Enabled` 配置项判断是否启用新版本
|
|
168
|
-
- **新版本**:使用 `neoGlobalSearchHome` 组件(统一入口)
|
|
169
|
-
- **旧版本**:使用 `GlobalSearchHome` 组件(企微入口)或 `GlobalSearchList` 组件(APP入口)
|
|
170
|
-
|
|
171
|
-
### 3.7 渲染逻辑
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
render() {
|
|
175
|
-
const globalSearchPermission = getNeoContext('globalSearchPermission')
|
|
176
|
-
if (!globalSearchPermission) {
|
|
177
|
-
return null
|
|
178
|
-
}
|
|
179
|
-
const { render } = this.props
|
|
180
|
-
return <Styled>{render('GlobalSearchInput', this.pageScheme())}</Styled>
|
|
181
|
-
}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
**渲染流程**:
|
|
185
|
-
1. 检查权限,无权限则返回 `null`
|
|
186
|
-
2. 获取 `render` 函数(由 Amis 框架注入)
|
|
187
|
-
3. 使用 `render` 函数渲染 `GlobalSearchInput` 组件
|
|
188
|
-
4. 传入 `pageScheme()` 返回的配置对象
|
|
189
|
-
5. 使用 `Styled` 组件包裹,应用样式
|
|
190
|
-
|
|
191
|
-
## 四、技术实现细节
|
|
192
|
-
|
|
193
|
-
### 4.1 依赖项
|
|
194
|
-
|
|
195
|
-
组件依赖以下模块:
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
import * as React from 'react'
|
|
199
|
-
import { GlobalSearchInputProps } from './interface'
|
|
200
|
-
import { Styled } from './styled'
|
|
201
|
-
import { kiwiIntl, NeoNavigator, getNeoContext } from 'neo-ui-common'
|
|
202
|
-
import { ScopedContext, IScopedContext } from 'amis'
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**依赖说明**:
|
|
206
|
-
|
|
207
|
-
| 模块 | 用途 |
|
|
208
|
-
|------|------|
|
|
209
|
-
| `react` | React 框架 |
|
|
210
|
-
| `neo-ui-common` | Neo UI 公共工具库 |
|
|
211
|
-
| `amis` | Amis 低代码框架 |
|
|
212
|
-
| `styled-components` | CSS-in-JS 样式方案 |
|
|
213
|
-
|
|
214
|
-
### 4.2 接口定义
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
export interface GlobalSearchInputProps {
|
|
218
|
-
[key: string]: any
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
**接口特点**:
|
|
223
|
-
- 使用索引签名,允许接收任意属性
|
|
224
|
-
- 灵活性高,但类型安全性较低
|
|
225
|
-
- 实际使用时主要依赖框架注入的 `render` 属性
|
|
226
|
-
|
|
227
|
-
### 4.3 样式定义
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
import styled from 'styled-components'
|
|
231
|
-
export const Styled = styled.div`
|
|
232
|
-
width: 100%;
|
|
233
|
-
`
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
**样式特点**:
|
|
237
|
-
- 使用 `styled-components` 定义样式
|
|
238
|
-
- 当前样式较简单,仅设置宽度为 100%
|
|
239
|
-
- 注释掉的代码显示了之前可能的样式配置
|
|
240
|
-
|
|
241
|
-
### 4.4 国际化支持
|
|
242
|
-
|
|
243
|
-
组件使用 `kiwiIntl` 进行国际化:
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
placeholder: kiwiIntl('neo.global.search', '全局搜索')
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
**国际化机制**:
|
|
250
|
-
- `kiwiIntl(key, defaultValue)` 函数
|
|
251
|
-
- `key`: 国际化键值 `'neo.global.search'`
|
|
252
|
-
- `defaultValue`: 默认值 `'全局搜索'`
|
|
253
|
-
- 如果找不到对应的国际化文本,使用默认值
|
|
254
|
-
|
|
255
|
-
## 五、使用场景
|
|
256
|
-
|
|
257
|
-
### 5.1 典型使用场景
|
|
258
|
-
|
|
259
|
-
1. **首页搜索入口**:在首页顶部放置全局搜索输入框
|
|
260
|
-
2. **导航栏搜索**:在导航栏中集成搜索功能
|
|
261
|
-
3. **列表页搜索**:在列表页面提供全局搜索入口
|
|
262
|
-
|
|
263
|
-
### 5.2 组件映射
|
|
264
|
-
|
|
265
|
-
组件在首页组件映射中的配置:
|
|
266
|
-
|
|
267
|
-
```typescript
|
|
268
|
-
// packages/neo-ui-component-h5/src/utils/widgetMap.tsx
|
|
269
|
-
export const HomeMappingWidgets = {
|
|
270
|
-
xsyGlobalSearchInput: 'neoGlobalSearchInput', // 全局搜索组件
|
|
271
|
-
// ... 其他组件映射
|
|
272
|
-
}
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
**映射说明**:
|
|
276
|
-
- 后台配置使用 `xsyGlobalSearchInput`
|
|
277
|
-
- 前端实际渲染 `neoGlobalSearchInput` 组件
|
|
278
|
-
- 通过映射表实现前后端组件名称的解耦
|
|
279
|
-
|
|
280
|
-
## 六、使用示例
|
|
281
|
-
|
|
282
|
-
### 6.1 基础使用示例
|
|
283
|
-
|
|
284
|
-
#### 6.1.1 在 Amis Schema 中使用
|
|
285
|
-
|
|
286
|
-
```json
|
|
287
|
-
{
|
|
288
|
-
"type": "page",
|
|
289
|
-
"body": [
|
|
290
|
-
{
|
|
291
|
-
"type": "neoGlobalSearchInput"
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
}
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
#### 6.1.2 在首页配置中使用
|
|
298
|
-
|
|
299
|
-
```json
|
|
300
|
-
{
|
|
301
|
-
"type": "xsyGlobalSearchInput",
|
|
302
|
-
"keyIdentifier": "global-search-input-001"
|
|
303
|
-
}
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
### 6.2 完整页面示例
|
|
307
|
-
|
|
308
|
-
```json
|
|
309
|
-
{
|
|
310
|
-
"type": "page",
|
|
311
|
-
"title": "首页",
|
|
312
|
-
"body": [
|
|
313
|
-
{
|
|
314
|
-
"type": "neoGlobalSearchInput",
|
|
315
|
-
"keyIdentifier": "home-global-search"
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
"type": "neoMenuList",
|
|
319
|
-
"keyIdentifier": "home-menu-list"
|
|
320
|
-
}
|
|
321
|
-
]
|
|
322
|
-
}
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
### 6.3 在 React 组件中使用(不推荐)
|
|
326
|
-
|
|
327
|
-
虽然组件导出了 `GlobalSearchInput`,但通常不直接在 React 组件中使用,而是通过 Amis Schema 配置使用:
|
|
328
|
-
|
|
329
|
-
```typescript
|
|
330
|
-
// 不推荐直接使用
|
|
331
|
-
import { GlobalSearchInput } from 'neo-ui-component-h5'
|
|
332
|
-
|
|
333
|
-
// 推荐通过 Amis Schema 配置使用
|
|
334
|
-
const schema = {
|
|
335
|
-
type: 'neoGlobalSearchInput'
|
|
336
|
-
}
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
### 6.4 权限配置示例
|
|
340
|
-
|
|
341
|
-
在使用组件前,需要确保配置了全局搜索权限:
|
|
342
|
-
|
|
343
|
-
```typescript
|
|
344
|
-
// 在应用初始化时配置
|
|
345
|
-
setNeoContext('globalSearchPermission', true)
|
|
346
|
-
setNeoContext('globalSearchUpgrade2024Enabled', true) // 启用新版本
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
## 七、相关组件
|
|
350
|
-
|
|
351
|
-
### 7.1 关联组件
|
|
352
|
-
|
|
353
|
-
| 组件名称 | 说明 | 关系 |
|
|
354
|
-
|---------|------|------|
|
|
355
|
-
| `neoGlobalSearchHome` | 新版本全局搜索首页 | 点击搜索框后跳转的目标页面 |
|
|
356
|
-
| `GlobalSearchHome` | 旧版本全局搜索首页(企微入口) | 旧版本跳转目标 |
|
|
357
|
-
| `GlobalSearchList` | 旧版本全局搜索列表(APP入口) | 旧版本跳转目标 |
|
|
358
|
-
| `neoSearchBar` | 搜索框基础组件 | 实际渲染的 UI 组件 |
|
|
359
|
-
|
|
360
|
-
neoSearchBar 组件源码位置:packages/neo-ui-component-h5/src/baseUIElement/neoSearchBar。
|
|
361
|
-
备注:neoGlobalSearchHome 是搜索页面(含结果页)
|
|
362
|
-
|
|
363
|
-
### 7.2 组件调用链
|
|
364
|
-
|
|
365
|
-
```
|
|
366
|
-
用户点击搜索框
|
|
367
|
-
↓
|
|
368
|
-
neoGlobalSearchInput (onClick)
|
|
369
|
-
↓
|
|
370
|
-
NeoNavigator.openUniversalPage
|
|
371
|
-
↓
|
|
372
|
-
根据配置跳转到:
|
|
373
|
-
- neoGlobalSearchHome (新版本)
|
|
374
|
-
- GlobalSearchHome (旧版本-企微)
|
|
375
|
-
- GlobalSearchList (旧版本-APP)
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
## 八、注意事项
|
|
379
|
-
|
|
380
|
-
### 8.1 权限要求
|
|
381
|
-
|
|
382
|
-
- **必须配置权限**:使用组件前必须通过 `getNeoContext('globalSearchPermission')` 配置权限
|
|
383
|
-
- **无权限处理**:如果没有权限,组件不会渲染任何内容(返回 `null`)
|
|
384
|
-
- **权限检查时机**:在每次 `render` 时都会检查权限
|
|
385
|
-
|
|
386
|
-
### 8.2 版本兼容性
|
|
387
|
-
|
|
388
|
-
- **新版本启用**:通过 `globalSearchUpgrade2024Enabled` 配置项控制
|
|
389
|
-
- **版本切换**:切换版本时需要确保对应的目标页面组件已正确配置
|
|
390
|
-
- **向后兼容**:组件同时支持新旧两种模式,保证平滑升级
|
|
391
|
-
|
|
392
|
-
### 8.3 样式定制
|
|
393
|
-
|
|
394
|
-
- **当前样式简单**:组件样式定义较简单,主要通过 `neoSearchBar` 组件控制样式
|
|
395
|
-
- **样式扩展**:如需定制样式,可以修改 `styled.ts` 文件或通过 CSS 覆盖
|
|
396
|
-
|
|
397
|
-
### 8.4 性能考虑
|
|
398
|
-
|
|
399
|
-
- **权限检查**:每次渲染都会调用 `getNeoContext`,建议确保该函数性能良好
|
|
400
|
-
- **组件注册**:组件会在挂载时注册到 ScopedContext,卸载时会注销,避免内存泄漏
|
|
401
|
-
|
|
402
|
-
### 8.5 国际化
|
|
403
|
-
|
|
404
|
-
- **占位符文本**:搜索框占位符支持国际化,键值为 `'neo.global.search'`
|
|
405
|
-
- **默认值**:如果找不到国际化文本,会使用默认值 `'全局搜索'`
|
|
406
|
-
|
|
407
|
-
## 九、代码注释说明
|
|
408
|
-
|
|
409
|
-
### 9.1 已注释的代码
|
|
410
|
-
|
|
411
|
-
组件中存在一段已注释的代码,展示了之前的实现方式:
|
|
412
|
-
|
|
413
|
-
```typescript
|
|
414
|
-
// return {
|
|
415
|
-
// type: 'neoSearch',
|
|
416
|
-
// label: kiwiIntl('neo.global.search', '全局搜索'),
|
|
417
|
-
// onClick: () => {
|
|
418
|
-
// NeoNavigator.openUniversalPage({
|
|
419
|
-
// pageType: 'GlobalSearchHome',
|
|
420
|
-
// stateParams: {
|
|
421
|
-
// type: 'GlobalSearchHome'
|
|
422
|
-
// }
|
|
423
|
-
// })
|
|
424
|
-
// }
|
|
425
|
-
// }
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
**说明**:
|
|
429
|
-
- 这是旧版本的实现方式
|
|
430
|
-
- 使用 `neoSearch` 组件类型
|
|
431
|
-
- 没有版本切换逻辑
|
|
432
|
-
- 保留可能是为了参考或回退
|
|
433
|
-
|
|
434
|
-
### 9.2 样式注释
|
|
435
|
-
|
|
436
|
-
`styled.ts` 文件中也有注释掉的样式代码,可能是之前的样式配置:
|
|
437
|
-
|
|
438
|
-
```typescript
|
|
439
|
-
/* .menu-header-search {
|
|
440
|
-
-webkit-box-pack: center;
|
|
441
|
-
justify-content: flex-start;
|
|
442
|
-
height: 40px;
|
|
443
|
-
width: 100%;
|
|
444
|
-
border-radius: 20px;
|
|
445
|
-
color: rgba(48, 48, 48, 100);
|
|
446
|
-
font-size: 16px;
|
|
447
|
-
font-family: PingFangSC-Regular;
|
|
448
|
-
background-color: white;
|
|
449
|
-
} */
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
## 十、扩展建议
|
|
453
|
-
|
|
454
|
-
### 10.1 功能扩展
|
|
455
|
-
|
|
456
|
-
1. **搜索历史**:可以添加搜索历史功能
|
|
457
|
-
2. **快捷搜索**:可以添加快捷搜索入口
|
|
458
|
-
3. **搜索建议**:可以添加搜索建议功能
|
|
459
|
-
4. **自定义样式**:可以添加更多样式配置选项
|
|
460
|
-
|
|
461
|
-
### 10.2 代码优化
|
|
462
|
-
|
|
463
|
-
1. **类型安全**:改进 `GlobalSearchInputProps` 接口定义,提高类型安全性
|
|
464
|
-
2. **性能优化**:考虑使用 `useMemo` 优化 `pageScheme` 方法
|
|
465
|
-
3. **错误处理**:添加错误处理和边界情况处理
|
|
466
|
-
4. **单元测试**:添加完整的单元测试覆盖
|
|
467
|
-
|
|
468
|
-
### 10.3 文档完善
|
|
469
|
-
|
|
470
|
-
1. **API 文档**:完善组件的 API 文档
|
|
471
|
-
2. **使用指南**:提供更详细的使用指南和最佳实践
|
|
472
|
-
3. **示例代码**:提供更多实际使用场景的示例代码
|
|
473
|
-
|
|
474
|
-
## 十一、总结
|
|
475
|
-
|
|
476
|
-
`neoGlobalSearchInput` 是一个功能简洁但重要的全局搜索入口组件。它通过权限控制、版本兼容、国际化支持等特性,为 H5 端提供了统一的全局搜索入口。组件设计遵循了 Neo UI 框架的规范,与 Amis 框架良好集成,可以方便地在页面配置中使用。
|
|
477
|
-
|
|
478
|
-
### 11.1 核心优势
|
|
479
|
-
|
|
480
|
-
1. **简单易用**:配置简单,开箱即用
|
|
481
|
-
2. **权限控制**:内置权限检查机制
|
|
482
|
-
3. **版本兼容**:支持新旧版本平滑切换
|
|
483
|
-
4. **国际化**:支持多语言显示
|
|
484
|
-
|
|
485
|
-
### 11.2 适用场景
|
|
486
|
-
|
|
487
|
-
- 首页搜索入口
|
|
488
|
-
- 导航栏搜索功能
|
|
489
|
-
- 列表页搜索入口
|
|
490
|
-
- 任何需要全局搜索功能的页面
|
|
491
|
-
|
|
492
|
-
---
|
|
493
|
-
|
|
494
|
-
**文档版本**:v1.0
|
|
495
|
-
**最后更新**:2024年
|
|
496
|
-
**维护者**:Neo UI 团队
|
|
497
|
-
|