vue2-client 1.22.7 → 1.22.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.
Files changed (88) hide show
  1. package/.env.his +19 -19
  2. package/.idea/CopilotChatHistory.xml +39 -0
  3. package/.idea/MarsCodeWorkspaceAppSettings.xml +8 -0
  4. package/.idea/af-vue2-client.iml +7 -4
  5. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  6. package/.idea/migrateChatHistory.xml +10 -0
  7. package/package.json +1 -1
  8. package/src/base-client/components/common/HIS/HForm/HForm.vue +1186 -1186
  9. package/src/base-client/components/common/XFormTable/demo.vue +134 -53
  10. package/src/base-client/components/common/XInspectionDetailDrawer/components/InspectionSummary.vue +8 -0
  11. package/src/base-client/components/common/XInspectionDetailDrawer/services/inspectionService.js +6 -1
  12. package/src/base-client/components/common/XMarkdownViewer/demo.vue +102 -102
  13. package/src/base-client/components/his/XTransfer/index.md +327 -327
  14. package/src/pages/WorkflowDetail/WorkFlowDemo4.vue +127 -0
  15. package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformation.vue +417 -417
  16. package/.history/.eslintrc_20260521171150.js +0 -74
  17. package/.history/.eslintrc_20260521171213.js +0 -74
  18. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154443.vue +0 -726
  19. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154700.vue +0 -478
  20. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175435.vue +0 -706
  21. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175450.vue +0 -694
  22. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260611152602.vue +0 -755
  23. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513145941.vue +0 -524
  24. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513153133.vue +0 -731
  25. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513160316.vue +0 -525
  26. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260601144150.vue +0 -1046
  27. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310142713.vue +0 -512
  28. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310145118.vue +0 -511
  29. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260311094834.vue +0 -696
  30. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260320143028.vue +0 -693
  31. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260409101450.vue +0 -677
  32. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508164645.vue +0 -758
  33. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508164714.vue +0 -693
  34. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508171651.vue +0 -716
  35. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260509133717.vue +0 -695
  36. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260509171115.vue +0 -664
  37. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140637.vue +0 -1455
  38. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140935.vue +0 -1441
  39. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513150818.vue +0 -1441
  40. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153119.vue +0 -1442
  41. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153126.vue +0 -1486
  42. package/.history/src/base-client/components/common/XForm/XFormItem_20260513140854.vue +0 -1607
  43. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140403.vue +0 -643
  44. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140829.vue +0 -628
  45. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519142824.vue +0 -104
  46. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519143155.vue +0 -102
  47. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171231.vue +0 -1241
  48. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171441.vue +0 -1223
  49. package/.history/src/base-client/components/his/HAi/HAi_20260612174826.vue +0 -472
  50. package/.history/src/base-client/components/his/HAi/HAi_20260612175839.vue +0 -538
  51. package/.history/src/base-client/components/his/HAi/HAi_20260615103331.vue +0 -650
  52. package/.history/src/base-client/components/his/XHDescriptions/XHDescriptions_20260424134504.vue +0 -1469
  53. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171133.vue +0 -788
  54. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171151.vue +0 -780
  55. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511170841.vue +0 -585
  56. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511171138.vue +0 -787
  57. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260512141830.vue +0 -739
  58. package/.history/src/components/STable/index_20260409155138.js +0 -806
  59. package/.history/src/components/STable/index_20260409155218.js +0 -814
  60. package/.history/src/expression/core/Expression_20260305164427.js +0 -1371
  61. package/.history/src/expression/core/Expression_20260305170258.js +0 -1358
  62. package/.history/src/expression/core/Program_20260305111830.js +0 -944
  63. package/.history/src/expression/core/Program_20260305112041.js +0 -931
  64. package/.history/src/logic/LogicRunner_20260304154306.js +0 -170
  65. package/.history/src/logic/LogicRunner_20260304155553.js +0 -112
  66. package/.history/src/logic/LogicRunner_20260305105834.js +0 -112
  67. package/.history/src/logic/LogicRunner_20260305112718.js +0 -129
  68. package/.history/src/logic/LogicRunner_20260305182436.js +0 -133
  69. package/.history/src/logic/LogicRunner_20260306151301.js +0 -213
  70. package/.history/src/logic/LogicRunner_20260306152419.js +0 -213
  71. package/.history/src/logic/plugins/common/DateTools_20260305154159.js +0 -61
  72. package/.history/src/logic/plugins/common/DateTools_20260305154217.js +0 -44
  73. package/.history/src/logic/plugins/common/DateTools_20260305161014.js +0 -44
  74. package/.history/src/logic/plugins/common/HttpTools_20260305164352.js +0 -80
  75. package/.history/src/logic/plugins/common/HttpTools_20260305170258.js +0 -75
  76. package/.history/src/logic/plugins/common/HttpTools_20260305171634.js +0 -75
  77. package/.history/src/logic/plugins/common/HttpTools_20260306152419.js +0 -72
  78. package/.history/src/services/api/restTools_20260427142149.js +0 -245
  79. package/.history/src/services/api/restTools_20260427142853.js +0 -230
  80. package/.history/src/services/api/restTools_20260519135558.js +0 -230
  81. package/.history/src/services/api/restTools_20260519140825.js +0 -230
  82. package/.history/src/services/api/restTools_20260519151223.js +0 -230
  83. package/.history/src/utils/indexedDB_20260306150918.js +0 -593
  84. package/.history/src/utils/indexedDB_20260306151301.js +0 -586
  85. package/.idea/codeStyles/Project.xml +0 -62
  86. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  87. package/.idea/misc.xml +0 -6
  88. package/preview-input-box.html +0 -180
@@ -2,35 +2,54 @@
2
2
  <a-card :bordered="false">
3
3
  <x-form-table
4
4
  title="示例表单"
5
- :queryParamsName="queryParamsName"
5
+ queryParamsName="scanCodeAndNFCRUD"
6
6
  :fixedAddForm="fixedAddForm"
7
7
  :externalSelectedRowKeys="selectedKeys"
8
+ :defaultPageSize="100"
9
+ :pageSizeArray="['100','200']"
8
10
  @action="action"
9
11
  @selectRow="selectRow"
10
12
  @columnClick="columnClick"
11
13
  @ceshi="ceshi"
12
- @rowDblClick="rowDblClick"
13
- serviceName="af-revenue"
14
+ @startService="startService"
15
+ serviceName="af-safecheck"
14
16
  ref="xFormTable"
15
17
  :reserveSpaceForButtons="true"
16
- @tableBaseEnter="tableBaseEnter"
17
- @addFormSubmit="addFormSubmit"
18
- ></x-form-table>
18
+ >
19
+ </x-form-table>
20
+ <a-modal
21
+ v-model="formModalVisible"
22
+ title="工单回访"
23
+ :zIndex="1002"
24
+ width="50vw"
25
+ :destroy-on-close="true"
26
+ @cancel="formModalVisible = false"
27
+ @ok="ok"
28
+ >
29
+ <x-add-native-form
30
+ ref="xForm"
31
+ />
32
+ </a-modal>
33
+ <button @click="backDealData">提交</button>
19
34
  </a-card>
20
35
  </template>
21
36
 
22
37
  <script>
23
38
  import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable.vue'
39
+ import XAddNativeForm from '@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'
24
40
  import { microDispatch } from '@vue2-client/utils/microAppUtils'
41
+ import {getConfigByNameAsync, runLogic} from '@vue2-client/services/api/common'
42
+
25
43
  export default {
26
44
  name: 'Demo',
27
45
  components: {
28
- XFormTable
46
+ XFormTable,
47
+ XAddNativeForm,
29
48
  },
30
- data() {
49
+ data () {
31
50
  return {
32
51
  // 查询配置文件名
33
- queryParamsName: 'UserFilesListCRUD',
52
+ queryParamsName: 'ceshiCRUD',
34
53
  // 查询配置左侧tree
35
54
  xTreeConfigName: 'addressType',
36
55
  // 新增表单固定值
@@ -43,41 +62,32 @@ export default {
43
62
  selectedKeys: [],
44
63
  selected: {
45
64
  keys: [],
46
- rows: []
47
- }
65
+ rows: [],
66
+ },
67
+ formModalVisible: false,
48
68
  }
49
69
  },
50
-
51
70
  methods: {
52
- tableBaseEnter(...args) {
53
- const [attr, value, currentRecord, currentIndex, nextRecord, nextIndex] = args
54
- console.log('====>', attr, value, currentRecord, currentIndex, nextRecord, nextIndex)
55
-
56
- console.log('当前行:', currentIndex, '下一行:', nextIndex)
57
- if (!nextIndex) {
58
- this.$message.warning('没有下一行')
59
- return
60
- }
61
- // 跳转到下一行的同一列
62
- this.$refs.xFormTable.$refs.xTable.focusInput(nextIndex, attr.model)
63
- setTimeout(() => {
64
- this.$refs.xFormTable.$refs.xTable.focusInput(nextIndex, attr.model)
65
- }, 10)
66
- },
67
- handleCustomQuery() {
68
- this.$refs.xFormTable.queryTable({
69
- uf_f_alias: 'XianFeng',
70
- uf_f_card_id: '10500030'
71
+ backDealData () {
72
+ this.$refs.xFormTable.$refs.xForm.backDealData().then(data => {
73
+ console.log('backDealData', data)
74
+ console.log('selected', this.$refs.xFormTable.$refs.xForm?.form)
71
75
  })
72
76
  },
73
- rowDblClick(record) {
74
- console.log('rowDblClick', record)
75
- },
76
77
  // input框 行編輯參數傳遞
77
- ceshi(...args) {
78
+ ceshi (...args) {
78
79
  // attr, value, currentRecord, currentIndex, nextRecord, nextIndex
79
- const [attr, value, currentRecord, currentIndex, nextRecord, nextIndex] = args
80
- console.log('ceshi', attr, value, currentRecord, currentIndex, nextRecord, nextIndex)
80
+ const [attr, value, currentRecord, currentIndex, nextRecord, nextIndex] =
81
+ args
82
+ console.log(
83
+ 'ceshi',
84
+ attr,
85
+ value,
86
+ currentRecord,
87
+ currentIndex,
88
+ nextRecord,
89
+ nextIndex
90
+ )
81
91
  // 示例:当按下 Enter 键且有下一行时,跳转到下一行的同一列
82
92
  // 可以在这里执行业务逻辑(例如:保存数据)
83
93
  console.log('当前行:', currentIndex, '下一行:', nextIndex)
@@ -88,44 +98,115 @@ export default {
88
98
  // 跳转到下一行的同一列
89
99
  this.$refs.xFormTable.$refs.xTable.focusInput(nextIndex, attr.model)
90
100
  },
91
- test() {
101
+ test () {
92
102
  this.$refs.xFormTable.setTableData([])
93
103
  },
94
- defaultF() {
104
+ defaultF () {
95
105
  this.$refs.xFormTable.setTableSize('default')
96
106
  },
97
- middleF() {
107
+ middleF () {
98
108
  this.$refs.xFormTable.setTableSize('middle')
99
109
  },
100
- smallF() {
110
+ smallF () {
101
111
  this.$refs.xFormTable.setTableSize('small')
102
112
  },
103
- columnClick(key, value, record) {
113
+ columnClick (key, value, record) {
104
114
  microDispatch({
105
115
  type: 'v3route',
106
116
  path: '/bingliguanli/dianzibingliluru',
107
- props: { selected: arguments[0].his_f_admission_id }
117
+ props: { selected: arguments[0].his_f_admission_id },
108
118
  })
109
119
  },
110
- action(record, id, actionType) {
111
- this.detailVisible = true
112
- console.log('触发了详情操作', record, id, actionType)
120
+ startService (record, id, actionType) {
121
+ getConfigByNameAsync('测试Form', 'af-safecheck').then(config => {
122
+ this.formModalVisible = true
123
+ this.$nextTick(
124
+ () => {
125
+ this.formModalVisible = true
126
+ this.$refs.xForm.init({
127
+ formItems: config.formJson,
128
+ title: '工单回访',
129
+ businessType: '新增',
130
+ ...config,
131
+ fixedAddForm: {
132
+ Images:[
133
+ {
134
+ 'uid': 1850,
135
+ 'url': '/resource/af-system/images/3de85050493f4404ad3d0a00d53bca12.png',
136
+ 'name': '3de85050493f4404ad3d0a00d53bca12.png'
137
+ }
138
+ ],
139
+ f_image1:[
140
+ {
141
+ 'uid': 1850,
142
+ 'url': '/resource/af-system/images/3de85050493f4404ad3d0a00d53bca12.png',
143
+ 'name': '3de85050493f4404ad3d0a00d53bca12.png'
144
+ }
145
+ ],
146
+ signs: [
147
+ {
148
+ 'uid': 1850,
149
+ 'url': '/resource/af-system/images/3de85050493f4404ad3d0a00d53bca12.png',
150
+ 'name': '3de85050493f4404ad3d0a00d53bca12.png'
151
+ }
152
+ ],
153
+ },
154
+ modifyModelData: {
155
+ data: {
156
+ Images:[
157
+ {
158
+ 'uid': 1850,
159
+ 'url': '/resource/af-system/images/3de85050493f4404ad3d0a00d53bca12.png',
160
+ 'name': '3de85050493f4404ad3d0a00d53bca12.png'
161
+ }
162
+ ],
163
+ f_image1:[
164
+ {
165
+ 'uid': 1850,
166
+ 'url': '/resource/af-system/images/3de85050493f4404ad3d0a00d53bca12.png',
167
+ 'name': '3de85050493f4404ad3d0a00d53bca12.png'
168
+ }
169
+ ],
170
+ f_image2: [
171
+ {
172
+ 'uid': 1850,
173
+ 'url': '/resource/af-system/images/3de85050493f4404ad3d0a00d53bca12.png',
174
+ 'name': '3de85050493f4404ad3d0a00d53bca12.png'
175
+ }
176
+ ],
177
+ },
178
+ signs: [
179
+ {
180
+ 'uid': 1850,
181
+ 'url': '/resource/af-system/images/3de85050493f4404ad3d0a00d53bca12.png',
182
+ 'name': '3de85050493f4404ad3d0a00d53bca12.png'
183
+ }
184
+ ],
185
+ },
186
+ })
187
+ })
188
+ })
189
+ // this.detailVisible = true
190
+ // console.log('触发了详情操作', record, id, actionType)
191
+ },
192
+ async ok () {
193
+ const res = await this.$refs.xForm.asyncSubmit()
194
+ await runLogic('ceshwewei', res.realForm)
113
195
  },
114
- onClose() {
196
+ onClose () {
115
197
  this.detailVisible = false
116
198
  // 关闭详情之后重新查询表单
117
199
  this.$refs.xFormTable.refreshTable(true)
118
200
  },
119
- selectRow(selectedRowKeys, selectedRows) {
201
+ selectRow (selectedRowKeys, selectedRows) {
120
202
  this.selected = {
121
203
  keys: selectedRowKeys,
122
- rows: selectedRows
204
+ rows: selectedRows,
123
205
  }
206
+ console.log('selectedDemo', this.selected)
124
207
  },
125
- addFormSubmit(params, callback){
126
- callback()
127
- }
128
- }
208
+ },
209
+ computed: {},
129
210
  }
130
211
  </script>
131
212
 
@@ -51,6 +51,14 @@
51
51
  <div class="kv-value">{{ basicInfo.f_address || '——' }}</div>
52
52
  </div>
53
53
 
54
+ <div v-if="!safeCheckWebConfig?.safeCheckResult?.hideRealPosition" class="kv-item kv-item-wide">
55
+ <div class="kv-label">
56
+ <a-icon type="environment" />
57
+ 实时定位
58
+ </div>
59
+ <div class="kv-value">{{ basicInfo?.f_data?.f_real_location || '——' }}</div>
60
+ </div>
61
+
54
62
  <div class="kv-item">
55
63
  <div class="kv-label">
56
64
  <a-icon type="clock-circle" />
@@ -225,6 +225,10 @@ class InspectionService {
225
225
  const checkResultJson = apiData.checkResultJson || []
226
226
  const signatureForm = apiData.signatureForm || {}
227
227
  const historyList = apiData.historyList || []
228
+ let redundantData = {}
229
+ if (checkPaper?.f_data && checkPaper?.f_data !== '' && checkPaper.f_data !== null && checkPaper.f_data !== '{}') {
230
+ redundantData = JSON.parse(checkPaper.f_data) || {}
231
+ }
228
232
  return {
229
233
  basicInfo: {
230
234
  id: checkPaper.id,
@@ -245,7 +249,8 @@ class InspectionService {
245
249
  f_approved: checkPaper.f_approved,
246
250
  f_approved_time: checkPaper.f_approved_time,
247
251
  f_approved_name: checkPaper.f_approved_name,
248
- f_approved_note: checkPaper.f_approved_note
252
+ f_approved_note: checkPaper.f_approved_note,
253
+ f_data: redundantData,
249
254
  },
250
255
  historyList,
251
256
  deviceList: await this.extractDeviceList(checkResultJson),
@@ -1,102 +1,102 @@
1
- <template>
2
- <div style="padding: 16px">
3
- <h2>XMarkdownViewer Demo</h2>
4
-
5
- <div style="margin: 12px 0; padding: 12px; background: #f5f5f5; border-radius: 4px">
6
- <h4 style="margin: 0 0 8px 0">流式 AI 调用示例</h4>
7
- <div style="margin-bottom: 8px">
8
- <input
9
- v-model="userMessage"
10
- type="text"
11
- placeholder="输入消息"
12
- style="width: 300px; padding: 6px 8px; border: 1px solid #ddd; border-radius: 4px"
13
- @keyup.enter="sendMessage"
14
- >
15
- <button
16
- type="button"
17
- style="margin-left: 8px; padding: 6px 16px; background: #1890ff; color: #fff; border: none; border-radius: 4px; cursor: pointer"
18
- @click="sendMessage"
19
- >
20
- 发送
21
- </button>
22
- <button
23
- v-if="isStreaming"
24
- type="button"
25
- style="margin-left: 8px; padding: 6px 16px; background: #ff4d4f; color: #fff; border: none; border-radius: 4px; cursor: pointer"
26
- @click="stopMessage"
27
- >
28
- 停止
29
- </button>
30
- </div>
31
- <div v-if="isStreaming" style="color: #1890ff; font-size: 12px">AI 正在思考中...</div>
32
- </div>
33
-
34
- <div style="margin: 8px 0; color: #666; font-size: 12px">
35
- <span v-if="fileName">当前文件:{{ fileName }}({{ md.length }} 字符)</span>
36
- <span v-else-if="md">当前内容:流式响应({{ md.length }} 字符)</span>
37
- <span v-else>请输入消息并点击发送</span>
38
- </div>
39
-
40
- <x-markdown-viewer ref="viewer" :markdown="md" />
41
- </div>
42
- </template>
43
-
44
- <script>
45
- import XMarkdownViewer from './XMarkdownViewer.vue'
46
-
47
- export default {
48
- name: 'XMarkdownViewerDemo',
49
- components: {
50
- XMarkdownViewer
51
- },
52
- data () {
53
- return {
54
- md: '',
55
- fileName: '',
56
- userMessage: '',
57
- isStreaming: false,
58
- currentStream: null
59
- }
60
- },
61
- methods: {
62
- async sendMessage () {
63
- const message = this.userMessage.trim()
64
- if (!message) return
65
-
66
- const viewer = this.$refs.viewer
67
- if (!viewer || typeof viewer.callAiStream !== 'function') {
68
- console.warn('[Demo] viewer 不存在或没有 callAiStream 方法')
69
- return
70
- }
71
-
72
- // 开始时显示提示
73
- viewer.receiveMarkdownString('### 思考中,请稍后...\n')
74
- this.isStreaming = true
75
-
76
- // 调用流式接口
77
- const stream = viewer.callAiStream(message, {
78
- onChunk: (text) => {
79
- viewer.receiveMarkdownString('### 思考中,请稍后...\n\n' + viewer.getStreamContent())
80
- },
81
- onEnd: (fullContent) => {
82
- viewer.receiveMarkdownString(fullContent)
83
- this.isStreaming = false
84
- },
85
- onError: (error) => {
86
- viewer.receiveMarkdownString('### 抱歉,发生了错误\n\n' + error)
87
- this.isStreaming = false
88
- }
89
- })
90
-
91
- this.currentStream = stream
92
- },
93
- stopMessage () {
94
- if (this.currentStream && typeof this.currentStream.stop === 'function') {
95
- this.currentStream.stop()
96
- this.isStreaming = false
97
- }
98
- }
99
- }
100
- }
101
- </script>
102
-
1
+ <template>
2
+ <div style="padding: 16px">
3
+ <h2>XMarkdownViewer Demo</h2>
4
+
5
+ <div style="margin: 12px 0; padding: 12px; background: #f5f5f5; border-radius: 4px">
6
+ <h4 style="margin: 0 0 8px 0">流式 AI 调用示例</h4>
7
+ <div style="margin-bottom: 8px">
8
+ <input
9
+ v-model="userMessage"
10
+ type="text"
11
+ placeholder="输入消息"
12
+ style="width: 300px; padding: 6px 8px; border: 1px solid #ddd; border-radius: 4px"
13
+ @keyup.enter="sendMessage"
14
+ >
15
+ <button
16
+ type="button"
17
+ style="margin-left: 8px; padding: 6px 16px; background: #1890ff; color: #fff; border: none; border-radius: 4px; cursor: pointer"
18
+ @click="sendMessage"
19
+ >
20
+ 发送
21
+ </button>
22
+ <button
23
+ v-if="isStreaming"
24
+ type="button"
25
+ style="margin-left: 8px; padding: 6px 16px; background: #ff4d4f; color: #fff; border: none; border-radius: 4px; cursor: pointer"
26
+ @click="stopMessage"
27
+ >
28
+ 停止
29
+ </button>
30
+ </div>
31
+ <div v-if="isStreaming" style="color: #1890ff; font-size: 12px">AI 正在思考中...</div>
32
+ </div>
33
+
34
+ <div style="margin: 8px 0; color: #666; font-size: 12px">
35
+ <span v-if="fileName">当前文件:{{ fileName }}({{ md.length }} 字符)</span>
36
+ <span v-else-if="md">当前内容:流式响应({{ md.length }} 字符)</span>
37
+ <span v-else>请输入消息并点击发送</span>
38
+ </div>
39
+
40
+ <x-markdown-viewer ref="viewer" :markdown="md" />
41
+ </div>
42
+ </template>
43
+
44
+ <script>
45
+ import XMarkdownViewer from './XMarkdownViewer.vue'
46
+
47
+ export default {
48
+ name: 'XMarkdownViewerDemo',
49
+ components: {
50
+ XMarkdownViewer
51
+ },
52
+ data () {
53
+ return {
54
+ md: '',
55
+ fileName: '',
56
+ userMessage: '',
57
+ isStreaming: false,
58
+ currentStream: null
59
+ }
60
+ },
61
+ methods: {
62
+ async sendMessage () {
63
+ const message = this.userMessage.trim()
64
+ if (!message) return
65
+
66
+ const viewer = this.$refs.viewer
67
+ if (!viewer || typeof viewer.callAiStream !== 'function') {
68
+ console.warn('[Demo] viewer 不存在或没有 callAiStream 方法')
69
+ return
70
+ }
71
+
72
+ // 开始时显示提示
73
+ viewer.receiveMarkdownString('### 思考中,请稍后...\n')
74
+ this.isStreaming = true
75
+
76
+ // 调用流式接口
77
+ const stream = viewer.callAiStream(message, {
78
+ onChunk: (text) => {
79
+ viewer.receiveMarkdownString('### 思考中,请稍后...\n\n' + viewer.getStreamContent())
80
+ },
81
+ onEnd: (fullContent) => {
82
+ viewer.receiveMarkdownString(fullContent)
83
+ this.isStreaming = false
84
+ },
85
+ onError: (error) => {
86
+ viewer.receiveMarkdownString('### 抱歉,发生了错误\n\n' + error)
87
+ this.isStreaming = false
88
+ }
89
+ })
90
+
91
+ this.currentStream = stream
92
+ },
93
+ stopMessage () {
94
+ if (this.currentStream && typeof this.currentStream.stop === 'function') {
95
+ this.currentStream.stop()
96
+ this.isStreaming = false
97
+ }
98
+ }
99
+ }
100
+ }
101
+ </script>
102
+