lw-cdp-ui 1.5.21 → 1.5.24

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.
@@ -0,0 +1,39 @@
1
+ export const FORM_DATA_GENERATION_RULES = {
2
+ role: 'system',
3
+ content: `
4
+ 你是一个表单数据生成助手,必须严格遵守以下规则:
5
+
6
+ 1. 数据生成规则:
7
+ - 根据表单数据案例和表单数据定义生成表单JSON数据
8
+ - 如果存在当前表单数据,在其基础上修改或补充
9
+ - 如果没有当前数据,根据定义生成全新数据
10
+ - 表单渲染定义中有rules的字段必须生成
11
+
12
+ 2. 输出格式规则:
13
+ - 返回纯净的JSON字符串,不要包含\`\`\`json\`\`\`标记
14
+ - 不要包含任何注释
15
+ - 确保JSON格式完全正确
16
+
17
+ 3. 内容规则:
18
+ - 只处理表单数据生成相关请求
19
+ - 不回答与表单无关的问题
20
+ - 遇到无法处理的请求应回复:"此请求不符合表单数据生成规则"
21
+
22
+ 4. 校验规则:
23
+ - 生成的JSON必须能通过JSON.parse验证
24
+ - 必须包含所有required字段
25
+ - 字段值应符合字段类型定义
26
+ `
27
+ }
28
+
29
+ export const SAFETY_RULES = {
30
+ role: 'system',
31
+ content: `
32
+ 安全规则:
33
+ 1. 不生成任何违法、违规内容
34
+ 2. 不处理个人隐私数据
35
+ 3. 不执行任何可能造成安全风险的操作
36
+ 4. 不得生成除表单JSON以外的其他数据
37
+ 5. 不得生成任何可能被攻击的数据
38
+ `
39
+ }
@@ -0,0 +1,256 @@
1
+ <template>
2
+ <div class="lw-ai">
3
+ <el-popover :visible="visible" placement="bottom" title="AI助手" :width="300">
4
+ <template #reference>
5
+ <div class="ai-btn" :class="{ 'ai-btn-animate': visible }" @click="visible = !visible"> ai </div>
6
+ </template>
7
+ <div class="lw-ai-content">
8
+ <div class="lw-ai-content-body-input">
9
+ <el-input v-model="inputValue" type="textarea" placeholder="请输入你的要求,ai将协助您完成操作" />
10
+ </div>
11
+ <div class="lw-ai-content-body-button">
12
+ <el-button type="primary" @click="send" :loading="loading">发送</el-button>
13
+ </div>
14
+ </div>
15
+ </el-popover>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ import axios from 'axios';
21
+ import { computed, getCurrentInstance, ref, watch } from 'vue';
22
+ import { useRouter } from 'vue-router';
23
+ import { FORM_DATA_GENERATION_RULES, SAFETY_RULES } from './doc/rules.js';
24
+
25
+ export default {
26
+ name: 'LwAi',
27
+ props: {
28
+ modelValue: {
29
+ type: [Object, Array, String, Number, Boolean, Function],
30
+ default: null
31
+ },
32
+ config: {
33
+ type: Object,
34
+ default: null
35
+ },
36
+ doc: {
37
+ type: [Object, String],
38
+ default: null
39
+ }
40
+ },
41
+ setup(props, { emit }) {
42
+ const {
43
+ proxy: { $http, $expression, t, $tool, $bus }
44
+ } = getCurrentInstance()
45
+ const router = useRouter()
46
+ const visible = ref(false)
47
+ const loading = ref(false)
48
+ const inputValue = ref('')
49
+
50
+ let messages = ref([
51
+ FORM_DATA_GENERATION_RULES, // 使用导入的规则
52
+ SAFETY_RULES, // 安全规则
53
+ {
54
+ content: `表单渲染定义:${JSON.stringify(props.config.formItems)}`,
55
+ role: 'system'
56
+ },
57
+ {
58
+ content: `表单案例数据:${typeof props.modelValue === 'object' ? JSON.stringify(props.modelValue) : props.modelValue}`,
59
+ role: 'system'
60
+ }
61
+ ])
62
+
63
+ watch(
64
+ () => props.modelValue,
65
+ (val, old) => {
66
+ let jsonVal = JSON.stringify(val)
67
+ let oldVal = JSON.stringify(old)
68
+ if (val && oldVal !== jsonVal) {
69
+ messages.value.push({
70
+ content: `当前表单数据:${JSON.stringify(val)}`,
71
+ role: 'system'
72
+ })
73
+ }
74
+ }
75
+ )
76
+
77
+ let data = computed(() => {
78
+ let d = {
79
+ messages: messages.value,
80
+ model: 'deepseek-chat',
81
+ frequency_penalty: 0,
82
+ max_tokens: 8192,
83
+ presence_penalty: 0,
84
+ response_format: {
85
+ type: 'text'
86
+ },
87
+ stop: null,
88
+ stream: false,
89
+ stream_options: null,
90
+ temperature: 0.7,
91
+ top_p: 1,
92
+ tools: null,
93
+ tool_choice: 'none',
94
+ logprobs: false,
95
+ top_logprobs: null
96
+ }
97
+
98
+ return JSON.stringify(d)
99
+ })
100
+
101
+ let config = computed(() => {
102
+ return {
103
+ method: 'post',
104
+ maxBodyLength: Infinity,
105
+ url: 'https://api.deepseek.com/chat/completions',
106
+ ai: true,
107
+ headers: {
108
+ 'Content-Type': 'application/json',
109
+ Accept: 'application/json',
110
+ Authorization: 'Bearer sk-58c96a0153654d599d6ff16112f04755'
111
+ },
112
+ data: data.value
113
+ }
114
+ })
115
+ const send = () => {
116
+ loading.value = true
117
+ if (inputValue.value) {
118
+ messages.value.push({
119
+ content: inputValue.value,
120
+ role: 'user'
121
+ })
122
+ }
123
+ axios(config.value)
124
+ .then((response) => {
125
+ console.log(response.data.choices[0].message.content)
126
+ emit('update:modelValue', JSON.parse(response.data.choices[0].message.content))
127
+ })
128
+ .finally(() => {
129
+ loading.value = false
130
+ inputValue.value = ''
131
+ })
132
+ }
133
+
134
+ return {
135
+ send,
136
+ visible,
137
+ loading,
138
+ inputValue
139
+ }
140
+ }
141
+ }
142
+ </script>
143
+ <style lang="scss" scoped>
144
+ .lw-ai {
145
+ position: relative;
146
+
147
+ .ai-btn {
148
+ position: fixed;
149
+ bottom: 80px;
150
+ right: 50px;
151
+ z-index: 99;
152
+
153
+ color: rgba(255, 255, 255, 0.9);
154
+ width: 48px;
155
+ height: 48px;
156
+ display: flex;
157
+ align-items: center;
158
+ justify-content: center;
159
+ border-radius: 50%;
160
+ font-size: 18px;
161
+ font-weight: bold;
162
+ transition: all 0.5s ease;
163
+ cursor: pointer;
164
+ background: linear-gradient(135deg, #d51b275e,
165
+ #ff880075);
166
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
167
+ border: none;
168
+ outline: none;
169
+ overflow: hidden;
170
+ }
171
+
172
+ .ai-btn:hover {
173
+ transform: scale(1.05);
174
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
175
+ }
176
+
177
+ .ai-btn-animate {
178
+ background: transparent;
179
+ color: rgba(255, 255, 255, 0.9);
180
+
181
+ &::after,
182
+ &::before {
183
+ content: '';
184
+ position: absolute;
185
+ top: 0;
186
+ left: 0;
187
+ width: 100%;
188
+ height: 100%;
189
+ border-radius: 50%;
190
+ opacity: 0.7;
191
+ mix-blend-mode: screen;
192
+ animation: morph 8s infinite linear, colors 10s infinite linear;
193
+ z-index: -1;
194
+ }
195
+
196
+ &::after {
197
+ background: linear-gradient(45deg, #d51b275e, #ff880075);
198
+ }
199
+
200
+ &::before {
201
+ background: linear-gradient(135deg, #1b8bd57c, #00ffaa7a);
202
+ animation-delay: 0.5s;
203
+ }
204
+ }
205
+
206
+ @keyframes morph {
207
+ 0% {
208
+ border-radius: 66% 34% 30% 70% / 57% 28% 72% 43%;
209
+ transform: rotate(0deg);
210
+ }
211
+
212
+ 20% {
213
+ border-radius: 58% 42% 38% 62% / 49% 35% 65% 51%;
214
+ }
215
+
216
+ 40% {
217
+ border-radius: 42% 58% 52% 48% / 65% 49% 51% 35%;
218
+ }
219
+
220
+ 60% {
221
+ border-radius: 32% 68% 22% 78% / 71% 16% 84% 29%;
222
+ }
223
+
224
+ 80% {
225
+ border-radius: 67% 33% 57% 43% / 47% 58% 42% 53%;
226
+ }
227
+
228
+ 100% {
229
+ border-radius: 66% 34% 30% 70% / 57% 28% 72% 43%;
230
+ transform: rotate(360deg);
231
+ }
232
+ }
233
+
234
+ @keyframes colors {
235
+ 0% {
236
+ filter: hue-rotate(0deg);
237
+ }
238
+
239
+ 100% {
240
+ filter: hue-rotate(360deg);
241
+ }
242
+ }
243
+
244
+
245
+ }
246
+
247
+ .lw-ai-content {
248
+ .lw-ai-content-body-input {
249
+ margin-bottom: 10px;
250
+ }
251
+
252
+ .lw-ai-content-body-button {
253
+ text-align: right;
254
+ }
255
+ }
256
+ </style>
@@ -444,7 +444,7 @@ export default {
444
444
 
445
445
  // 处理应用显示逻辑
446
446
  let application = [
447
- ...new Set(user.userAuthInfo.menus.map((permission) => permission.split('.')[0].split('_')[0]))
447
+ ...new Set(user.userAuthInfo?.menus?.map((permission) => permission.split('.')[0].split('_')[0]))
448
448
  ]
449
449
  if (this.hasMenuPermission) {
450
450
  user.userAuthInfo.grantedApplications = user.userAuthInfo.grantedApplications.filter((x) =>