scq-vue 1.0.1 → 1.0.3
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 +87 -3
- package/dist/scq-vue.es.js +7349 -156
- package/dist/scq-vue.umd.js +19 -1
- package/dist/style.css +1 -1
- package/dist/types/components/ChatMessage/ChatMessage.vue.d.ts +18 -0
- package/dist/types/components/ChatMessage/index.d.ts +5 -0
- package/dist/types/index.d.ts +252 -1
- package/package.json +8 -2
- package/styles/chat-message.css +132 -0
- package/styles/index.css +1 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# scq-vue
|
|
2
2
|
|
|
3
|
-
Vue 3 component library with Button and
|
|
3
|
+
Vue 3 component library with Button, Input and ChatMessage.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -23,25 +23,109 @@ import 'scq-vue/style.css'
|
|
|
23
23
|
createApp(App).use(ScqVue).mount('#app')
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
After global install, you can use component tags directly in templates:
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<template>
|
|
30
|
+
<scq-button type="primary">Primary</scq-button>
|
|
31
|
+
<scq-input v-model="value" placeholder="Please input" />
|
|
32
|
+
<scq-chat-message :message="message" role="ai" :timestamp="Date.now()" />
|
|
33
|
+
</template>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Notes:
|
|
37
|
+
- Use prefixed tag names only: `scq-button`, `scq-input`, `scq-chat-message`
|
|
38
|
+
|
|
26
39
|
### On-demand import
|
|
27
40
|
|
|
28
41
|
```ts
|
|
29
|
-
import {
|
|
42
|
+
import { createApp } from 'vue'
|
|
43
|
+
import App from './App.vue'
|
|
44
|
+
import { ScqButton, ScqInput, ScqChatMessage } from 'scq-vue'
|
|
30
45
|
import 'scq-vue/style.css'
|
|
46
|
+
|
|
47
|
+
const app = createApp(App)
|
|
48
|
+
app.use(ScqButton)
|
|
49
|
+
app.use(ScqInput)
|
|
50
|
+
app.use(ScqChatMessage)
|
|
51
|
+
app.mount('#app')
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then use in templates:
|
|
55
|
+
|
|
56
|
+
```vue
|
|
57
|
+
<template>
|
|
58
|
+
<scq-button>Default</scq-button>
|
|
59
|
+
<scq-input v-model="value" />
|
|
60
|
+
<scq-chat-message :message="message" role="user" :show-time="false" />
|
|
61
|
+
</template>
|
|
31
62
|
```
|
|
32
63
|
|
|
33
64
|
### On-demand style import
|
|
34
65
|
|
|
35
66
|
```ts
|
|
36
|
-
import {
|
|
67
|
+
import { ScqButton, ScqInput, ScqChatMessage } from 'scq-vue'
|
|
37
68
|
import 'scq-vue/styles/button.css'
|
|
38
69
|
import 'scq-vue/styles/input.css'
|
|
70
|
+
import 'scq-vue/styles/chat-message.css'
|
|
39
71
|
```
|
|
40
72
|
|
|
41
73
|
## Components
|
|
42
74
|
|
|
43
75
|
- Button
|
|
44
76
|
- Input
|
|
77
|
+
- ChatMessage
|
|
78
|
+
|
|
79
|
+
## ChatMessage
|
|
80
|
+
|
|
81
|
+
ChatMessage is designed for chat scenarios and supports API response data rendering directly.
|
|
82
|
+
|
|
83
|
+
### Features
|
|
84
|
+
|
|
85
|
+
- Supports plain text, JSON and Markdown content
|
|
86
|
+
- Supports code highlighting (Markdown code blocks and JSON view)
|
|
87
|
+
- Supports two message roles: AI and user
|
|
88
|
+
- Supports configurable time display
|
|
89
|
+
|
|
90
|
+
### Basic example
|
|
91
|
+
|
|
92
|
+
```vue
|
|
93
|
+
<template>
|
|
94
|
+
<scq-chat-message
|
|
95
|
+
:message="apiData"
|
|
96
|
+
role="ai"
|
|
97
|
+
content-type="auto"
|
|
98
|
+
:show-time="true"
|
|
99
|
+
:timestamp="Date.now()"
|
|
100
|
+
/>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<script setup lang="ts">
|
|
104
|
+
const apiData = {
|
|
105
|
+
id: 'msg_001',
|
|
106
|
+
text: 'This is response data from API',
|
|
107
|
+
code: 'const x = 1',
|
|
108
|
+
}
|
|
109
|
+
</script>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Props
|
|
113
|
+
|
|
114
|
+
| Prop | Description | Type | Default |
|
|
115
|
+
| --- | --- | --- | --- |
|
|
116
|
+
| message | Message data from API | unknown | - |
|
|
117
|
+
| role | Message role | `ai` \| `user` | `ai` |
|
|
118
|
+
| contentType | Content type | `auto` \| `text` \| `markdown` \| `json` | `auto` |
|
|
119
|
+
| showTime | Whether to display timestamp | boolean | true |
|
|
120
|
+
| timestamp | Message time value | string \| number \| Date \| null | null |
|
|
121
|
+
| timeFormatter | Custom time formatter | `(value) => string` | - |
|
|
122
|
+
|
|
123
|
+
### Content type behavior
|
|
124
|
+
|
|
125
|
+
- `auto`: detect JSON string / Markdown / plain text automatically
|
|
126
|
+
- `text`: force plain text rendering
|
|
127
|
+
- `markdown`: force Markdown rendering
|
|
128
|
+
- `json`: force JSON pretty rendering
|
|
45
129
|
|
|
46
130
|
<!-- ## Development
|
|
47
131
|
|