@gindow/vue 1.0.1 → 1.0.2
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 +6 -6
- package/dist/resolver.cjs +1 -0
- package/dist/resolver.d.ts +15 -0
- package/dist/resolver.mjs +16 -0
- package/dist/style.css +1 -2
- package/dist/vue.cjs +1 -0
- package/dist/vue.d.ts +74 -258
- package/dist/vue.mjs +286 -0
- package/package.json +11 -52
- package/src/components/VueIcon.vue +43 -2
- package/src/index.ts +17 -9
- package/src/libs/auto-imports.d.ts +79 -0
- package/src/locale/index.ts +1 -1
- package/src/resolver.ts +19 -0
- package/src/style.css +9 -16
- package/src/utils/index.ts +0 -7
- package/dist/index.cjs +0 -2
- package/dist/index.mjs +0 -451
- package/src/hooks/useChat.ts +0 -135
- package/src/hooks/useNanoid.ts +0 -9
- package/src/hooks/useUpload.ts +0 -59
- package/src/types/chat.ts +0 -62
- package/src/utils/datetime.ts +0 -42
- package/src/utils/download.ts +0 -11
- package/src/utils/get.ts +0 -10
- package/src/utils/platform.ts +0 -38
- package/src/utils/request.ts +0 -146
package/src/types/chat.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export type MessageRole = 'user' | 'assistant' | 'system'
|
|
2
|
-
|
|
3
|
-
export type MessageContentType = 'text' | 'image' | 'code' | 'file'
|
|
4
|
-
|
|
5
|
-
export interface IChatFile {
|
|
6
|
-
id: string
|
|
7
|
-
name: string
|
|
8
|
-
type: string
|
|
9
|
-
size: number
|
|
10
|
-
url?: string
|
|
11
|
-
thumbnail?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface IChatMessageItem {
|
|
15
|
-
id: string
|
|
16
|
-
role: MessageRole
|
|
17
|
-
content: string
|
|
18
|
-
contentType?: MessageContentType
|
|
19
|
-
timestamp: number
|
|
20
|
-
isLoading?: boolean
|
|
21
|
-
isError?: boolean
|
|
22
|
-
files?: IChatFile[]
|
|
23
|
-
metadata?: Record<string, any>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface IChatSession {
|
|
27
|
-
id: string
|
|
28
|
-
title: string
|
|
29
|
-
messages: IChatMessageItem[]
|
|
30
|
-
createdAt: number
|
|
31
|
-
updatedAt: number
|
|
32
|
-
isPinned?: boolean
|
|
33
|
-
isArchived?: boolean
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ISendChatParams {
|
|
37
|
-
content: string
|
|
38
|
-
contentType?: MessageContentType
|
|
39
|
-
files?: IChatFile[]
|
|
40
|
-
sessionId?: string
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface IAIResponse {
|
|
44
|
-
message: IChatMessageItem
|
|
45
|
-
sessionId: string
|
|
46
|
-
suggestions?: string[]
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface IChatConfig {
|
|
50
|
-
placeholder?: string
|
|
51
|
-
maxFileSize?: number
|
|
52
|
-
allowedFileTypes?: string[]
|
|
53
|
-
enableStreaming?: boolean
|
|
54
|
-
showTimestamp?: boolean
|
|
55
|
-
showSuggestions?: boolean
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface ICodeBlock {
|
|
59
|
-
language: string
|
|
60
|
-
code: string
|
|
61
|
-
filename?: string
|
|
62
|
-
}
|
package/src/utils/datetime.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs'
|
|
2
|
-
|
|
3
|
-
export class DateTime {
|
|
4
|
-
|
|
5
|
-
static dayjs = dayjs
|
|
6
|
-
|
|
7
|
-
static s(date?: dayjs.ConfigType, symbol = '/') {
|
|
8
|
-
return DateTime.dayjs(date).format('YYYY/MM/DD HH:mm:ss'.replace(/\//g, symbol))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static m(date?: dayjs.ConfigType, symbol = '/') {
|
|
12
|
-
return DateTime.dayjs(date).format('YYYY/MM/DD HH:mm'.replace(/\//g, symbol))
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static h(date?: dayjs.ConfigType, symbol = '/') {
|
|
16
|
-
return DateTime.dayjs(date).format('YYYY/MM/DD HH'.replace(/\//g, symbol))
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static d(date?: dayjs.ConfigType, symbol = '/') {
|
|
20
|
-
return DateTime.dayjs(date).format('YYYY/MM/DD'.replace(/\//g, symbol))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static M(date?: dayjs.ConfigType, symbol = '/') {
|
|
24
|
-
return DateTime.dayjs(date).format('YYYY/MM'.replace(/\//g, symbol))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static y(date?: dayjs.ConfigType) {
|
|
28
|
-
return DateTime.dayjs(date).format('YYYY')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static date(date?: dayjs.ConfigType, symbol = '/') {
|
|
32
|
-
return DateTime.dayjs(date).format('YYYY/MM/DD'.replace(/\//g, symbol))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static time(date?: dayjs.ConfigType) {
|
|
36
|
-
return DateTime.dayjs(date).format('HH:mm')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static format(date?: dayjs.ConfigType, format = 'YYYY/MM/DD HH:mm:ss') {
|
|
40
|
-
return DateTime.dayjs(date).format(format)
|
|
41
|
-
}
|
|
42
|
-
}
|
package/src/utils/download.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const download = (blob: Blob, filename: string) => {
|
|
2
|
-
const url = URL.createObjectURL(blob)
|
|
3
|
-
const a = document.createElement('a')
|
|
4
|
-
a.href = url
|
|
5
|
-
a.download = filename
|
|
6
|
-
a.style.display = 'none'
|
|
7
|
-
document.body.appendChild(a)
|
|
8
|
-
a.click()
|
|
9
|
-
document.body.removeChild(a)
|
|
10
|
-
URL.revokeObjectURL(url)
|
|
11
|
-
}
|
package/src/utils/get.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const get = (object: any, path: string | string[], defaultValue?: any): any => {
|
|
2
|
-
if (object == null) return defaultValue
|
|
3
|
-
const keys = Array.isArray(path) ? path : path.replace(/\[(\d+)]/g, '.$1').split('.').filter(Boolean)
|
|
4
|
-
let result: any = object
|
|
5
|
-
for (const key of keys) {
|
|
6
|
-
result = result?.[key]
|
|
7
|
-
if (result === undefined) return defaultValue
|
|
8
|
-
}
|
|
9
|
-
return result
|
|
10
|
-
}
|
package/src/utils/platform.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export class Platform {
|
|
2
|
-
|
|
3
|
-
static get userAgent() {
|
|
4
|
-
return window.navigator.userAgent.toLowerCase()
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
static get isFlutter() {
|
|
8
|
-
return Platform.userAgent.match(/flutter/i) !== null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static get isFlutterIOS() {
|
|
12
|
-
return Platform.isFlutter && Platform.isIOS
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static get isWeb() {
|
|
16
|
-
return window.matchMedia('(min-width: 992px)').matches
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static get isMobile() {
|
|
20
|
-
return Platform.userAgent.match(/(phone|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) !== null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static get isIOS() {
|
|
24
|
-
return Platform.userAgent.match(/iphone|ipad|ipod|ios/i) !== null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static get isWechat() {
|
|
28
|
-
return Platform.userAgent.match(/MicroMessenger/i) !== null
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static get isWxwork() {
|
|
32
|
-
return Platform.userAgent.match(/MicroMessenger/i) !== null && Platform.userAgent.match(/wxwork/i) !== null
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static get isMiniprogram() {
|
|
36
|
-
return Platform.userAgent.match(/MicroMessenger/i) !== null && Platform.userAgent.match(/miniprogram/i) !== null
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/utils/request.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance, AxiosResponse } from 'axios'
|
|
2
|
-
import type { IModel } from '../types'
|
|
3
|
-
import { Platform } from './platform'
|
|
4
|
-
import cookie from 'js-cookie'
|
|
5
|
-
import axios from 'axios'
|
|
6
|
-
|
|
7
|
-
const $params = (params: IModel) => {
|
|
8
|
-
const para = { ...params }
|
|
9
|
-
if (typeof para?.search === 'string') return para
|
|
10
|
-
if (para?.search)
|
|
11
|
-
para.search = Object.keys(para.search)
|
|
12
|
-
.filter(item => para.search[item] !== null && para.search[item] !== '')
|
|
13
|
-
.map(item => item + ':' + para.search[item])
|
|
14
|
-
.join(';')
|
|
15
|
-
if (para?.searchFields)
|
|
16
|
-
para.searchFields = Object.keys(para.searchFields)
|
|
17
|
-
.filter(item => para.searchFields[item])
|
|
18
|
-
.map(item => item + ':' + para.searchFields[item])
|
|
19
|
-
.join(';')
|
|
20
|
-
return para
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const request = {
|
|
24
|
-
|
|
25
|
-
baseURL: '',
|
|
26
|
-
publicKey: '',
|
|
27
|
-
headers: { Accept: 'application/json' } as Record<string, string>,
|
|
28
|
-
instance: null as AxiosInstance|null,
|
|
29
|
-
accessToken: 'accessToken',
|
|
30
|
-
|
|
31
|
-
init (config: { baseURL?: string, publicKey?: string } = {}) {
|
|
32
|
-
this.baseURL = config.baseURL ?? ''
|
|
33
|
-
this.publicKey = config.publicKey ?? ''
|
|
34
|
-
|
|
35
|
-
const reload = () => {
|
|
36
|
-
this.delToken()
|
|
37
|
-
location.reload()
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.instance = axios.create({ baseURL: this.baseURL })
|
|
41
|
-
|
|
42
|
-
this.instance.interceptors.request.use(config => {
|
|
43
|
-
const language = localStorage.getItem('locale')
|
|
44
|
-
if (language) config.headers['Accept-Language'] = language
|
|
45
|
-
return config
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
this.instance.interceptors.response.use((response: AxiosResponse) => {
|
|
49
|
-
if (response.config.responseType === 'blob') return response
|
|
50
|
-
else if (response.data.code === 401) return reload()
|
|
51
|
-
else if (response.data.code === 200) return response.data
|
|
52
|
-
else return Promise.reject(response.data)
|
|
53
|
-
}, ({ response }) => Promise.reject(response.data))
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
setToken (token: string, options: { expires?: number, domain?: string } = {}) {
|
|
57
|
-
options = { ...options, domain: '.' + location.hostname }
|
|
58
|
-
cookie.set(this.accessToken, token, options)
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
getToken () {
|
|
62
|
-
return cookie.get(this.accessToken) || ''
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
delToken () {
|
|
66
|
-
cookie.remove(this.accessToken, { domain: '.' + location.hostname })
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
get (url: string, params?: {}, auth = false) { return this.request({ method: 'GET', url, params }, auth) },
|
|
70
|
-
put (url: string, data?: {}, auth = false) { return this.request({ method: 'PUT', url, data }, auth) },
|
|
71
|
-
patch (url: string, data?: {}, auth = false) { return this.request({ method: 'PATCH', url, data }, auth) },
|
|
72
|
-
delete (url: string, params?: {}, auth = false) { return this.request({ method: 'DELETE', url, params }, auth) },
|
|
73
|
-
post (url: string, data?: {}, auth = false) { return this.request({ method: 'POST', url, data }, auth) },
|
|
74
|
-
blob (url: string, params?: {}, auth = false) { return this.request({ method: 'GET', url, params, responseType: 'blob' }, auth) },
|
|
75
|
-
|
|
76
|
-
request(para: any, auth: boolean = false) {
|
|
77
|
-
const headers = para.headers ?? this.headers
|
|
78
|
-
if (auth) headers.Authorization = 'Bearer ' + this.getToken()
|
|
79
|
-
if (para.params) para.params = $params(para.params)
|
|
80
|
-
return (this.instance as any)({ ...para, headers })
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
async download(url: string, params?: {}, filename?: string, auth = false) {
|
|
84
|
-
const ret = await this.blob(url, params, auth)
|
|
85
|
-
if (Platform.isFlutter) return ret
|
|
86
|
-
const getResponseFileName = () => {
|
|
87
|
-
const disposition = ret.headers['content-disposition']
|
|
88
|
-
const parts = disposition.split("filename*=")
|
|
89
|
-
const val = parts[1].split(";")[0].trim()
|
|
90
|
-
return decodeURIComponent(val.replace(/^UTF-8''/i, ''))
|
|
91
|
-
}
|
|
92
|
-
let link = document.createElement('a')
|
|
93
|
-
link.href = window.URL.createObjectURL(ret.data)
|
|
94
|
-
link.download = filename ?? getResponseFileName()
|
|
95
|
-
link.click()
|
|
96
|
-
return ret
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
async upload(url: string, data = {}) {
|
|
100
|
-
const headers = { ...this.headers, 'Content-Type': 'multipart/form-data' }
|
|
101
|
-
return this.instance!.post(url, data, { headers })
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
sse (url: string, para?: {[key: string]: string | number | undefined | null | void} | null) {
|
|
105
|
-
const params = para ? Object.keys(para).map(key => key +'='+ para[key]).join('&') : ''
|
|
106
|
-
return new EventSource(this.baseURL + '/' + url + '?' + params)
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
setHeader(key: string, value: string) {
|
|
110
|
-
this.headers[key] = value
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
delHeader(key: string) {
|
|
114
|
-
delete this.headers[key]
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export class resource {
|
|
119
|
-
|
|
120
|
-
url: string
|
|
121
|
-
auth: boolean
|
|
122
|
-
|
|
123
|
-
constructor(url: string, auth = false) {
|
|
124
|
-
this.url = url
|
|
125
|
-
this.auth = auth
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
select = (para?: {}) => request.get(this.url, para, this.auth)
|
|
129
|
-
|
|
130
|
-
create = (para?: {}) => request.post(this.url, para, this.auth)
|
|
131
|
-
|
|
132
|
-
find = (id: string, para?: {}) => request.get(this.url + '/' + id, para, this.auth)
|
|
133
|
-
|
|
134
|
-
update = (id: string, para?: {}) => request.patch(this.url + '/' + id, para, this.auth)
|
|
135
|
-
|
|
136
|
-
delete = (id: string, para?: {}) => request.delete(this.url + '/' + id, para, this.auth)
|
|
137
|
-
|
|
138
|
-
async get(para: any) {
|
|
139
|
-
para.size = 1
|
|
140
|
-
const ret = await this.select(para)
|
|
141
|
-
ret.data = ret.data[0] || {}
|
|
142
|
-
return ret
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export { $params }
|