mirror of
https://gitee.com/WuKongDev/WuKongIM.git
synced 2025-12-06 06:49:06 +08:00
update demo
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
demo/chatdemo/dist/assets/Login-36899bc1.js
vendored
1
demo/chatdemo/dist/assets/Login-36899bc1.js
vendored
@@ -1 +0,0 @@
|
||||
import{d as g,q as m,r as d,b as f,c as b,j as e,t as x,u as I,W as k,w as u,x as _,A as p,H as w,I as y,_ as S}from"./index-5271d4ae.js";const U="/chatdemo/logo.png",c=a=>(w("data-v-6e16c5bf"),a=a(),y(),a),V={class:"hello"},A=c(()=>e("div",null,[e("a",{href:"https://githubim.com",target:"_blank"},[e("img",{src:U,class:"logo",alt:"Vite logo"})])],-1)),P={class:"form"},D={class:"item"},L=c(()=>e("div",{class:"label"},[e("label",null,"API基地址")],-1)),B={class:"field"},C={class:"item"},K=c(()=>e("div",{class:"label"},[e("label",null,"登录账号")],-1)),R={class:"field"},W={class:"item"},q=c(()=>e("div",{class:"label"},[e("label",null,"登录密码")],-1)),E={class:"field"},M=g({__name:"Login",setup(a){const v=m();var s=(o=>{var t=new RegExp("(^|&)"+o+"=([^&]*)(&|$)"),l=window.location.search.substr(1).match(t);return l!=null?unescape(l[2]):null})("apiurl");!s||(s==null?void 0:s.trim())==""?s="http://127.0.0.1:5001":s&&s.endsWith("/")&&(s=s.substring(0,s.length-1)),console.log("apiurl--->",s),d(0);const r=d(s||""),n=d(""),i=d(""),h=()=>{p.shared.config.apiURL=r.value,p.shared.post("/user/token",{uid:n.value,token:i.value||"default111111",device_flag:1,device_level:0}).then(o=>{console.log(o),v.push({path:"/chat",query:{uid:n.value,token:i.value}})}).catch(o=>{alert(o.msg)})};return(o,t)=>(f(),b("div",V,[A,e("p",null," 悟空IM演示程序,当前SDK版本:[v"+x(I(k).shared().config.sdkVersion)+"] ",1),e("div",P,[e("div",D,[L,e("div",B,[u(e("input",{type:"text",placeholder:"请输入API基地址","onUpdate:modelValue":t[0]||(t[0]=l=>r.value=l)},null,512),[[_,r.value]])])]),e("div",C,[K,e("div",R,[u(e("input",{type:"text",placeholder:"演示下,随便输,唯一即可","onUpdate:modelValue":t[1]||(t[1]=l=>n.value=l)},null,512),[[_,n.value]])])]),e("div",W,[q,e("div",E,[u(e("input",{type:"text",placeholder:"演示下,随便输","onUpdate:modelValue":t[2]||(t[2]=l=>i.value=l)},null,512),[[_,i.value]])])]),e("button",{class:"submit",onClick:h},"登录")])]))}});const H=S(M,[["__scopeId","data-v-6e16c5bf"]]);export{H as default};
|
||||
1
demo/chatdemo/dist/assets/Login-3d3b0c6d.js
vendored
Normal file
1
demo/chatdemo/dist/assets/Login-3d3b0c6d.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{d as _,r as i,b as g,c as m,j as e,t as f,u as h,W as b,w as r,v as u,z as x,A as c,_ as k}from"./index-fc7f73a5.js";const y="/chatdemo/logo.png",w={class:"hello"},U={class:"form"},V={class:"item"},A={class:"field"},I={class:"item"},P={class:"field"},D={class:"item"},L={class:"field"},B=_({__name:"Login",setup(C){const p=x();var s=(o=>{var l=new RegExp("(^|&)"+o+"=([^&]*)(&|$)"),t=window.location.search.substr(1).match(l);return t!=null?unescape(t[2]):null})("apiurl");!s||(s==null?void 0:s.trim())==""?s="http://127.0.0.1:5001":s&&s.endsWith("/")&&(s=s.substring(0,s.length-1)),console.log("apiurl--->",s),i(0);const d=i(s||""),a=i(""),n=i(""),v=()=>{c.shared.config.apiURL=d.value,c.shared.post("/user/token",{uid:a.value,token:n.value||"default111111",device_flag:1,device_level:0}).then(o=>{console.log(o),p.push({path:"/chat",query:{uid:a.value,token:n.value}})}).catch(o=>{alert(o.msg)})};return(o,l)=>(g(),m("div",w,[l[6]||(l[6]=e("div",null,[e("a",{href:"https://githubim.com",target:"_blank"},[e("img",{src:y,class:"logo",alt:"Vite logo"})])],-1)),e("p",null," 悟空IM演示程序,当前SDK版本:[v"+f(h(b).shared().config.sdkVersion)+"] ",1),e("div",U,[e("div",V,[l[3]||(l[3]=e("div",{class:"label"},[e("label",null,"API基地址")],-1)),e("div",A,[r(e("input",{type:"text",placeholder:"请输入API基地址","onUpdate:modelValue":l[0]||(l[0]=t=>d.value=t)},null,512),[[u,d.value]])])]),e("div",I,[l[4]||(l[4]=e("div",{class:"label"},[e("label",null,"登录账号")],-1)),e("div",P,[r(e("input",{type:"text",placeholder:"演示下,随便输,唯一即可","onUpdate:modelValue":l[1]||(l[1]=t=>a.value=t)},null,512),[[u,a.value]])])]),e("div",D,[l[5]||(l[5]=e("div",{class:"label"},[e("label",null,"登录密码")],-1)),e("div",L,[r(e("input",{type:"text",placeholder:"演示下,随便输","onUpdate:modelValue":l[2]||(l[2]=t=>n.value=t)},null,512),[[u,n.value]])])]),e("button",{class:"submit",onClick:v},"登录")])]))}});const S=k(B,[["__scopeId","data-v-6e16c5bf"]]);export{S as default};
|
||||
31
demo/chatdemo/dist/assets/index-5271d4ae.js
vendored
31
demo/chatdemo/dist/assets/index-5271d4ae.js
vendored
File diff suppressed because one or more lines are too long
45
demo/chatdemo/dist/assets/index-fc7f73a5.js
vendored
Normal file
45
demo/chatdemo/dist/assets/index-fc7f73a5.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
demo/chatdemo/dist/index.html
vendored
2
demo/chatdemo/dist/index.html
vendored
@@ -7,7 +7,7 @@
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover,shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
|
||||
<title>悟空IM演示程序</title>
|
||||
<script type="module" crossorigin src="/chatdemo/assets/index-5271d4ae.js"></script>
|
||||
<script type="module" crossorigin src="/chatdemo/assets/index-fc7f73a5.js"></script>
|
||||
<link rel="stylesheet" href="/chatdemo/assets/index-4eaedd69.css">
|
||||
</head>
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
"axios": "^1.4.0",
|
||||
"buffer": "^6.0.3",
|
||||
"highlight.js": "^11.11.1",
|
||||
"marked": "^15.0.7",
|
||||
"marked-highlight": "^2.2.1",
|
||||
"marked": "^16.3.0",
|
||||
"marked-highlight": "^2.2.2",
|
||||
"process": "^0.11.10",
|
||||
"vue": "^3.2.45",
|
||||
"vue-router": "^4.0.13",
|
||||
"wukongimjssdk": "^1.3.2"
|
||||
"wukongimjssdk": "^1.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.0.0",
|
||||
|
||||
@@ -11,8 +11,7 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const contentType = props.message.content.contentType
|
||||
const streamOn = props.message.streamOn
|
||||
|
||||
const streamOn = props.message.setting.streamOn
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -115,7 +115,6 @@ const connectIM = (addr: string) => {
|
||||
|
||||
// 监听消息
|
||||
messageListener = (msg) => {
|
||||
console.log("messageListener-->", msg)
|
||||
if (!to.value.isEqual(msg.channel)) {
|
||||
return
|
||||
}
|
||||
@@ -126,19 +125,23 @@ const connectIM = (addr: string) => {
|
||||
WKSDK.shared().chatManager.addMessageListener(messageListener)
|
||||
|
||||
// 流监听
|
||||
eventListener = (event: WKEvent) => {
|
||||
eventListener = async (event: WKEvent) => {
|
||||
for (const message of messages.value) {
|
||||
console.log("eventListener--->", event.id, event.type,event.dataText)
|
||||
if (message.clientMsgNo === event.id) {
|
||||
if (message.contentType === MessageContentType.text) {
|
||||
message.streamText = (message.streamText || "") + (event.dataText||"")
|
||||
const textContent = new MessageText(message.streamText || "")
|
||||
message.streamText = (message.streamText || "") + (event.dataText || "")
|
||||
const htmlText = await marked.parse(message.streamText)
|
||||
const textContent = new MessageText(htmlText || "")
|
||||
message.content = textContent
|
||||
}
|
||||
// 刷新ui
|
||||
messages.value = [...messages.value]
|
||||
nextTick(() => {
|
||||
scrollBottom()
|
||||
})
|
||||
break
|
||||
}
|
||||
// 刷新ui
|
||||
messages.value = [...messages.value]
|
||||
scrollBottom()
|
||||
}
|
||||
}
|
||||
WKSDK.shared().eventManager.addEventListener(eventListener)
|
||||
@@ -203,7 +206,8 @@ const pullLast = async () => {
|
||||
for (const m of msgs) {
|
||||
if (m.setting.streamOn) {
|
||||
if (m.streamText && m.streamText.length > 0) {
|
||||
m.content = new MessageText(m.streamText)
|
||||
const htmlText = await marked.parse(m.streamText)
|
||||
m.content = new MessageText(htmlText)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,7 +240,8 @@ const pullDown = async () => {
|
||||
for (const m of msgs) {
|
||||
if (m.setting.streamOn) {
|
||||
if (m.streamText && m.streamText.length > 0) {
|
||||
m.content = new MessageText(m.streamText)
|
||||
const htmlText = await marked.parse(m.streamText)
|
||||
m.content = new MessageText(htmlText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ demo:
|
||||
conversation:
|
||||
on: true
|
||||
webhook: # webhook配置 用于接收消息通知事件,详情请查看文档
|
||||
httpAddr: "http://127.0.0.1:8080/webhooks/wukongim"
|
||||
httpAddr: "http://127.0.0.1:8000/v1/integrations/wukongim/webhook"
|
||||
cluster:
|
||||
nodeId: 1 # 节点ID
|
||||
addr: "tcp://127.0.0.1:10001"
|
||||
|
||||
@@ -35,7 +35,7 @@ func newStream(s *Server) *stream {
|
||||
|
||||
// Route route
|
||||
func (s *stream) route(r *wkhttp.WKHttp) {
|
||||
// 此文件里的接口后续将移除 新的查看 streamv2.go里的接口
|
||||
// 此文件里的接口后续将移除 新的查看 event.go里的接口
|
||||
r.POST("/stream/open", s.open) // 流消息开始
|
||||
r.POST("/stream/close", s.close) // 流消息结束
|
||||
}
|
||||
|
||||
@@ -213,6 +213,9 @@ func (c *ConversationManager) storeConversations() {
|
||||
conversationType = wkdb.ConversationTypeCMD
|
||||
}
|
||||
for _, uid := range update.Uids {
|
||||
if uid == "" || update.ChannelId == "" {
|
||||
continue
|
||||
}
|
||||
createdAt := time.Now()
|
||||
updatedAt := time.Now()
|
||||
conversations = append(conversations, wkdb.Conversation{
|
||||
|
||||
@@ -27,4 +27,6 @@ const (
|
||||
EventMsgNotify = "msg.notify"
|
||||
// EventOnlineStatus 用户在线状态
|
||||
EventOnlineStatus = "user.onlinestatus"
|
||||
// EventMsgStream 流消息
|
||||
EventMsgStream = "msg.stream"
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/WuKongIM/WuKongIM/internal/common"
|
||||
"github.com/WuKongIM/WuKongIM/internal/eventbus"
|
||||
"github.com/WuKongIM/WuKongIM/internal/options"
|
||||
"github.com/WuKongIM/WuKongIM/internal/service"
|
||||
"github.com/WuKongIM/WuKongIM/pkg/wklog"
|
||||
"github.com/WuKongIM/WuKongIM/pkg/wknet"
|
||||
wkproto "github.com/WuKongIM/WuKongIMGoProto"
|
||||
@@ -124,6 +125,10 @@ func (e *EventPool) AllConnCount() int {
|
||||
|
||||
func (e *EventPool) RemoveConn(conn *eventbus.Conn) {
|
||||
e.pollerByUid(conn.Uid).removeConn(conn)
|
||||
realConn := service.ConnManager.GetConn(conn.ConnId)
|
||||
if realConn != nil {
|
||||
service.ConnManager.RemoveConn(realConn)
|
||||
}
|
||||
}
|
||||
|
||||
func (e *EventPool) WriteLocalData(conn *eventbus.Conn, data []byte) error {
|
||||
|
||||
@@ -163,12 +163,12 @@ func (h *Handler) handleConnect(event *eventbus.Event) (wkproto.ReasonCode, *wkp
|
||||
for _, oldConn := range oldConns {
|
||||
if oldConn.ConnId != conn.ConnId && oldConn.DeviceId == connectPacket.DeviceID {
|
||||
service.CommonService.AfterFunc(time.Second*2, func(od *eventbus.Conn) func() {
|
||||
h.Info("auth: close old conn for slave", zap.Any("oldConn", oldConn), zap.Int64("oldConnId", oldConn.ConnId), zap.Int64("newConnId", conn.ConnId))
|
||||
return func() {
|
||||
eventbus.User.CloseConn(od)
|
||||
}
|
||||
}(oldConn))
|
||||
|
||||
h.Info("auth: close old conn for slave", zap.Any("oldConn", oldConn), zap.Int64("oldConnId", oldConn.ConnId), zap.Int64("newConnId", conn.ConnId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ const (
|
||||
DefaultMaxChunksPerStream = 1000
|
||||
// DefaultStreamTimeout is the default timeout for inactive streams (30 minutes)
|
||||
DefaultStreamTimeout = 30 * time.Minute
|
||||
// DefaultChunkInactivityTimeout is the default timeout for auto-completing inactive streams (30 seconds)
|
||||
DefaultChunkInactivityTimeout = 30 * time.Second
|
||||
// DefaultChunkInactivityTimeout is the default timeout for auto-completing inactive streams
|
||||
DefaultChunkInactivityTimeout = 10 * time.Minute
|
||||
// CleanupInterval is the interval for cleanup operations
|
||||
CleanupInterval = 5 * time.Minute
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user