Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yu
uniapp-dpp-demo
提交
ee2ed195
U
uniapp-dpp-demo
项目概览
yu
/
uniapp-dpp-demo
通知
21
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uniapp-dpp-demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ee2ed195
编写于
5月 26, 2022
作者:
yu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync with uni market
上级
9dfdd183
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
387 addition
and
317 deletion
+387
-317
.gitignore
.gitignore
+3
-0
App.vue
App.vue
+110
-101
meteor/server/main.ts
meteor/server/main.ts
+71
-71
modules/chatroom/service/index.js
modules/chatroom/service/index.js
+35
-24
modules/core/ddp.js
modules/core/ddp.js
+31
-7
modules/user/service/index.js
modules/user/service/index.js
+24
-16
modules/user/signin/signin.vue
modules/user/signin/signin.vue
+15
-10
modules/user/signup/signup.vue
modules/user/signup/signup.vue
+71
-75
pages.json
pages.json
+8
-7
uni_modules/hj-ddp/changelog.md
uni_modules/hj-ddp/changelog.md
+2
-0
uni_modules/hj-ddp/js_sdk/hj-ddp.es.js
uni_modules/hj-ddp/js_sdk/hj-ddp.es.js
+16
-5
uni_modules/hj-ddp/package.json
uni_modules/hj-ddp/package.json
+1
-1
未找到文件。
.gitignore
浏览文件 @
ee2ed195
uni_modules
hbuilderx
node_modules
\ No newline at end of file
App.vue
浏览文件 @
ee2ed195
<
script
>
import
{
ddp
}
from
"
./modules/core/ddp
"
;
console
.
log
(
ddp
)
ddp
.
subscribe
(
"
rooms.all
"
)
ddp
.
subscribe
(
"
rooms.mine
"
)
export
default
{
onLaunch
:
function
()
{
console
.
log
(
"
App Launch
"
);
},
onShow
:
function
()
{
console
.
log
(
"
App Show
"
);
},
onHide
:
function
()
{
console
.
log
(
"
App Hide
"
);
},
};
import
{
ddp
}
from
"
./modules/core/ddp
"
;
export
default
{
onLaunch
:
function
()
{
console
.
log
(
"
App Launch
"
);
// #ifdef H5
uni
.
reLaunch
({
url
:
"
/modules/user/signin/signin
"
})
// #endif
},
onShow
:
function
()
{
console
.
log
(
"
App Show
"
);
},
onHide
:
function
()
{
console
.
log
(
"
App Hide
"
);
},
};
</
script
>
<
style
>
/*每个页面公共css */
page
{
display
:
flex
;
flex-direction
:
column
;
/*
/*每个页面公共css */
page
{
display
:
flex
;
flex-direction
:
column
;
/*
min-height: 100%; */
background-color
:
#eeeeff
;
min-height
:
100%
;
}
page-body
{
background-color
:
red
;
}
view
{
box-sizing
:
border-box
;
}
.frow
,
.fcol
{
display
:
flex
;
}
.frow
{
flex-direction
:
row
;
}
.fcol
{
flex-direction
:
column
;
}
.fcnt
,
.cntx
{
justify-content
:
center
;
}
.fcnt
,
.cnty
{
align-items
:
center
;
}
.fbtw
{
justify-content
:
space-between
;
}
.fsc
{
align-self
:
center
;
}
.fse
{
align-self
:
flex-end
;
}
.fss
{
align-self
:
flex-start
;
}
.pd
{
padding
:
0.5rem
;
}
.pdh
{
padding
:
0.5rem
0
;
}
.f1
{
flex
:
1
;
}
.pdv
{
padding
:
0
0.5rem
;
}
.mg
{
margin
:
0.5rem
;
}
.mgh
{
margin
:
0
0.5rem
;
}
.mgv
{
margin
:
0.5rem
0
;
}
.mgt
{
margin-top
:
0.5rem
;
}
.mgb
{
margin-bottom
:
0.5rem
;
}
background-color
:
#eeeeff
;
min-height
:
100%
;
}
page-body
{
background-color
:
red
;
}
view
{
box-sizing
:
border-box
;
}
.frow
,
.fcol
{
display
:
flex
;
}
.frow
{
flex-direction
:
row
;
}
.fcol
{
flex-direction
:
column
;
}
.fcnt
,
.cntx
{
justify-content
:
center
;
}
.fcnt
,
.cnty
{
align-items
:
center
;
}
.fbtw
{
justify-content
:
space-between
;
}
.fsc
{
align-self
:
center
;
}
.fse
{
align-self
:
flex-end
;
}
.fss
{
align-self
:
flex-start
;
}
.pd
{
padding
:
0.5rem
;
}
.pdh
{
padding
:
0.5rem
0
;
}
.f1
{
flex
:
1
;
}
.pdv
{
padding
:
0
0.5rem
;
}
.mg
{
margin
:
0.5rem
;
}
.mgh
{
margin
:
0
0.5rem
;
}
.mgv
{
margin
:
0.5rem
0
;
}
.mgt
{
margin-top
:
0.5rem
;
}
.mgb
{
margin-bottom
:
0.5rem
;
}
</
style
>
meteor/server/main.ts
浏览文件 @
ee2ed195
...
...
@@ -4,87 +4,87 @@ import { publishComposite } from "meteor/reywood:publish-composite";
Meteor
.
startup
(()
=>
{
console
.
log
(
`Hi boot! -- ddp demo -- oh yeah -`
);
console
.
log
(
`Hi boot! -- ddp demo -- oh yeah -`
);
});
const
Users
=
Meteor
.
users
;
const
Rooms
=
new
Mongo
.
Collection
<
any
>
(
"
rooms
"
);
const
Messages
=
new
Mongo
.
Collection
<
any
>
(
"
messages
"
);
Messages
.
allow
({
insert
(
user
,
doc
)
{
if
(
!
user
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
if
(
!
doc
.
roomId
)
throw
new
Meteor
.
Error
(
"
需要提供roomId
"
);
doc
.
createdBy
=
user
;
doc
.
createdAt
=
Date
.
now
()
}
})
Meteor
.
methods
({
"
message.add
"
:
function
(
data
:
any
)
{
if
(
!
this
.
userId
||
!
data
.
roomId
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
return
Messages
.
insert
({
...
data
,
user
:
this
.
userId
,
});
},
"
room.create
"
:
function
(
name
:
string
)
{
if
(
!
this
.
userId
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
return
Rooms
.
insert
({
name
,
createdBy
:
this
.
userId
,
createdAt
:
Date
.
now
(),
members
:
[
this
.
userId
],
});
},
"
room.join
"
:
function
(
id
:
string
)
{
if
(
!
this
.
userId
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
const
room
=
Rooms
.
findOne
(
id
);
if
(
!
room
)
throw
new
Meteor
.
Error
(
"
没房间不能那啥
"
);
return
Rooms
.
update
(
id
,
{
$addToSet
:
{
members
:
this
.
userId
,
},
});
},
"
room.left
"
:
function
(
id
:
string
)
{
if
(
!
this
.
userId
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
const
room
=
Rooms
.
findOne
(
id
);
if
(
!
room
)
throw
new
Meteor
.
Error
(
"
没房间不能那啥
"
);
return
Rooms
.
update
(
id
,
{
$pull
:
{
members
:
this
.
userId
,
},
});
}
"
room.create
"
:
function
(
name
:
string
)
{
if
(
!
this
.
userId
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
return
Rooms
.
insert
({
name
,
createdBy
:
this
.
userId
,
createdAt
:
Date
.
now
(),
members
:
[
this
.
userId
],
});
},
"
room.join
"
:
function
(
id
:
string
)
{
if
(
!
this
.
userId
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
const
room
=
Rooms
.
findOne
(
id
);
if
(
!
room
)
throw
new
Meteor
.
Error
(
"
没房间不能那啥
"
);
return
Rooms
.
update
(
id
,
{
$addToSet
:
{
members
:
this
.
userId
,
},
});
},
"
room.left
"
:
function
(
id
:
string
)
{
if
(
!
this
.
userId
)
throw
new
Meteor
.
Error
(
"
仅有登录用户能那啥
"
);
const
room
=
Rooms
.
findOne
(
id
);
if
(
!
room
)
throw
new
Meteor
.
Error
(
"
没房间不能那啥
"
);
return
Rooms
.
update
(
id
,
{
$pull
:
{
members
:
this
.
userId
,
},
});
}
});
Meteor
.
publish
(
"
rooms.all
"
,
function
()
{
return
Rooms
.
find
({},
{
fields
:
{
name
:
1
,
_id
:
1
}
});
Meteor
.
publish
(
"
rooms.all
"
,
function
()
{
return
Rooms
.
find
({},
{
fields
:
{
name
:
1
,
_id
:
1
}
});
});
publishComposite
(
"
rooms.mine
"
,
function
()
{
const
userId
=
this
.
userId
;
return
{
find
()
{
return
Rooms
.
find
(
{
members
:
userId
},
{
fields
:
{
name
:
1
,
members
:
1
}
}
);
},
collectionName
:
`rooms-mine`
,
children
:
[
{
find
(
room
)
{
return
Users
.
find
(
{
id
:
{
$in
:
room
.
membsers
}
},
{
fields
:
{
profile
:
1
}
}
);
},
},
{
find
(
room
)
{
return
Messages
.
find
({
roomId
:
room
.
_id
});
},
},
],
};
publishComposite
(
"
rooms.mine
"
,
function
()
{
const
userId
=
this
.
userId
;
console
.
log
(
userId
+
"
mine
"
)
return
{
find
()
{
return
Rooms
.
find
(
{
members
:
userId
},
{
fields
:
{
name
:
1
,
members
:
1
,
createdBy
:
1
}
}
);
}
,
children
:
[
{
find
(
room
)
{
return
Users
.
find
(
{
id
:
{
$in
:
room
.
membsers
}
},
{
fields
:
{
profile
:
1
}
}
);
},
},
{
find
(
room
)
{
return
Messages
.
find
({
roomId
:
room
.
_id
});
},
},
],
};
});
Meteor
.
onConnection
((
con
)
=>
{
console
.
log
(
`
${
con
.
id
}
connected`
);
con
.
onClose
(()
=>
{
console
.
log
(
`
${
con
.
id
}
closed`
);
});
console
.
log
(
`
${
con
.
id
}
connected`
);
con
.
onClose
(()
=>
{
console
.
log
(
`
${
con
.
id
}
closed`
);
});
});
modules/chatroom/service/index.js
浏览文件 @
ee2ed195
import
{
useMongo
,
ddp
}
from
"
../../core/ddp.js
"
import
{
mineInfo
}
from
"
../../user/service/index.js
"
import
{
reactive
,
computed
computed
,
watchEffect
}
from
"
vue
"
export
const
myRooms
=
reactive
([])
const
allRooms
=
reactive
([])
console
.
log
(
ddp
)
const
MyRooms
=
ddp
.
db
.
collection
(
'
rooms-mine
'
)
const
AllRooms
=
ddp
.
db
.
collection
(
'
rooms
'
)
const
Messages
=
ddp
.
db
.
collection
(
'
messages
'
)
ddp
.
subscribe
(
"
rooms.all
"
)
ddp
.
subscribe
(
"
rooms.mine
"
)
const
db
=
useMongo
(
mineInfo
.
_id
,
ddp
)
const
AllRooms
=
db
.
collection
(
'
rooms
'
)
const
Messages
=
db
.
collection
(
'
messages
'
)
let
currentRoom
=
null
;
ddp
.
map
(
MyRooms
,
myRooms
)
ddp
.
map
(
AllRooms
,
allRooms
)
console
.
log
(
mineInfo
.
_id
)
export
const
myRooms
=
AllRooms
.
liveQuery
({
createdBy
:
mineInfo
.
_id
})
export
const
roomMessages
=
reactive
([])
export
const
otherRooms
=
computed
(()
=>
allRooms
.
filter
(
v
=>
!
myRooms
.
some
(
e
=>
e
.
_id
===
v
.
_id
)))
export
const
sendMessage
=
txt
=>
new
Promise
(
resolve
=>
{
if
(
!
currentRoom
||
!
txt
)
return
resolve
(
false
)
export
const
otherRooms
=
AllRooms
.
liveQuery
({
createdBy
:
{
$ne
:
mineInfo
.
_id
}
})
watchEffect
(()
=>
{
console
.
log
(
myRooms
)
console
.
log
(
otherRooms
)
})
export
const
sendMessage
=
async
txt
=>
{
if
(
!
currentRoom
||
!
txt
)
return
const
data
=
{
roomId
:
currentRoom
,
txt
,
_id
:
Date
.
now
()
_id
:
mineInfo
.
_id
+
"
-
"
+
Date
.
now
()
}
ddp
.
call
(
'
message.add
'
,
{
...
data
,
_id
:
undefined
},
(
err
,
res
)
=>
{
resolve
(
!
err
)
const
res
=
await
Messages
.
insert
({
...
data
},
{
remote
:
1
})
})
console
.
log
(
res
)
}
export
const
createRoom
=
name
=>
new
Promise
(
resolve
=>
{
{
ddp
.
call
(
'
room.create
'
,
name
,
(
err
,
res
)
=>
{
...
...
@@ -69,11 +82,9 @@ Messages.observe({
index
>
-
1
&&
roomMessages
.
splice
(
i
,
1
,
nv
)
}
});
import
{
user
}
from
"
../../user/service
"
export
const
joinRoom
=
id
=>
new
Promise
(
resolve
=>
{
if
(
!
user
.
_id
)
return
uni
.
navigateTo
({
if
(
!
mineInfo
.
_id
)
return
uni
.
navigateTo
({
url
:
'
/modules/user/signin/signin
'
})
ddp
.
call
(
'
room.join
'
,
id
,
(
err
,
res
)
=>
{
...
...
modules/core/ddp.js
浏览文件 @
ee2ed195
import
{
init
}
from
"
../../uni_modules/hj-ddp/js_sdk
"
;
import
{
hjMeteorAccount
}
from
"
../../uni_modules/hj-meteor-account/js_sdk
"
;
import
{
watchEffect
}
from
"
vue
"
;
import
{
connect
}
from
"
../../uni_modules/hj-ddp/js_sdk
"
;
import
{
useMeteorAccount
}
from
"
../../uni_modules/hj-meteor-account/js_sdk
"
;
import
{
useLocalMongo
}
from
"
../../uni_modules/hj-mongo-vue3/js_sdk
"
;
export
{
useLocalMongo
as
useMongo
}
from
"
../../uni_modules/hj-mongo-vue3/js_sdk
"
;
// #ifdef H5
export
const
ddp
=
ini
t
(
'
ws://localhost:3002
'
)
export
const
ddp
=
connec
t
(
'
ws://localhost:3002
'
)
// #endif
// #ifndef H5
export
const
ddp
=
ini
t
(
'
ws://10.0.2.2:3002
'
)
export
const
ddp
=
connec
t
(
'
ws://10.0.2.2:3002
'
)
// #endif
export
const
account
=
useMeteorAccount
(
ddp
)
export
const
db
=
useLocalMongo
(
"
shared
"
,
ddp
)
ddp
.
use
(
hjMeteorAccount
)
\ No newline at end of file
watchEffect
(()
=>
account
.
data
.
state
,
(
nv
,
ov
)
=>
{
if
(
nv
===
2
)
{
uni
.
showLoading
({
title
:
"
登陆中
"
})
}
else
if
(
ov
!==
2
)
{
uni
.
hideLoading
()
}
})
modules/user/service/index.js
浏览文件 @
ee2ed195
import
{
computed
,
reactive
}
from
"
vue
"
;
export
{
account
}
from
"
../../core/ddp
"
;
import
{
ddp
ddp
,
useMongo
,
db
,
account
}
from
"
../../core/ddp
"
;
export
const
user
=
reactive
({})
export
const
mineInfo
=
reactive
({})
export
const
Users
=
ddp
.
db
.
collection
(
'
users
'
)
ddp
.
user
.
onChange
((
info
)
=>
{
if
(
info
)
{
for
(
const
key
in
info
)
{
user
[
key
]
=
info
[
key
]
}
}
else
{
for
(
const
key
in
user
)
{
delete
user
[
key
]
export
const
Users
=
db
.
collection
(
'
users
'
)
export
const
ready
=
computed
(()
=>
account
.
state
===
1
)
account
.
onChange
(
nv
=>
{
const
removes
=
new
Set
(
Object
.
keys
(
mineInfo
))
if
(
nv
)
{
for
(
const
key
in
nv
)
{
mineInfo
[
key
]
=
nv
[
key
]
removes
.
delete
(
key
)
}
}
removes
.
forEach
(
key
=>
delete
mineInfo
[
key
])
})
export
const
signin
=
async
(
data
)
=>
{
if
(
!
data
.
username
||
!
data
.
password
)
return
ddp
.
loginWithPassword
(
data
.
username
,
data
.
password
).
catch
(
err
=>
{
account
.
loginWithPassword
(
data
.
username
,
data
.
password
).
catch
(
err
=>
{
uni
.
showToast
({
title
:
'
密码或者用户名错误
'
})
...
...
@@ -33,9 +40,10 @@ export const signin = async (data) => {
export
const
signup
=
async
(
data
)
=>
{
if
(
!
data
.
username
||
!
data
.
password
||
data
.
password
!==
data
.
password1
)
return
ddp
.
createAccount
(
data
.
username
,
data
.
password
).
catch
(
err
=>
{
account
.
createAccount
(
data
.
username
,
data
.
password
).
catch
(
err
=>
{
console
.
log
(
err
)
uni
.
showToast
({
title
:
'
注册失败
'
title
:
'
注册失败
'
+
err
?.
reason
})
});
};
\ No newline at end of file
};
modules/user/signin/signin.vue
浏览文件 @
ee2ed195
...
...
@@ -11,9 +11,11 @@
<view
class=
"dlbutton fsc"
hover-class=
"dlbutton-hover"
@
tap=
"signin(data)"
>
<text>
登录
</text>
</view>
<navigator
url=
"../signup/signup"
class=
"btn fsc mgv"
>
<button
type=
"default"
>
注册
</button>
</navigator>
<view
class=
" fsc"
>
<navigator
url=
"../signup/signup"
class=
"btn mgv"
>
<button
type=
"default"
>
注册
</button>
</navigator>
</view>
</view>
</
template
>
...
...
@@ -24,17 +26,18 @@
}
from
"
vue
"
import
{
signin
,
user
mineInfo
,
ready
,
account
}
from
"
../service
"
;
const
data
=
reactive
({
username
:
""
,
password
:
""
})
watch
(
user
,
(
ov
,
nv
)
=>
{
console
.
log
({
ov
,
nv
})
if
(
nv
?.
_id
)
{
watch
(()
=>
account
.
data
.
state
,
(
nv
,
ov
)
=>
{
if
(
nv
===
1
)
{
uni
.
reLaunch
({
url
:
'
/pages/index/index
'
url
:
'
/pages/index/index
'
});
}
},
{
...
...
@@ -67,13 +70,16 @@
width
:
100%
;
}
}
.btn
,
.dlbutton
{
.btn
,
.dlbutton
{
font-size
:
34upx
;
width
:
470upx
;
height
:
100upx
;
border-radius
:
50upx
;
line-height
:
100upx
;
}
.dlbutton
{
color
:
#ffffff
;
background
:
linear-gradient
(
-90deg
,
...
...
@@ -89,5 +95,4 @@
rgba
(
63
,
205
,
235
,
0
.9
)
,
rgba
(
188
,
226
,
158
,
0
.9
));
}
</
style
>
modules/user/signup/signup.vue
浏览文件 @
ee2ed195
...
...
@@ -18,88 +18,84 @@
</
template
>
<
script
setup
>
import
{
reactive
,
watch
}
from
"
vue
"
import
{
signup
,
user
}
from
"
../service
"
;
const
data
=
reactive
({
username
:
""
,
password
:
""
,
password1
:
''
})
watch
(
user
,
(
ov
,
nv
)
=>
{
console
.
log
({
ov
,
nv
})
if
(
nv
?.
_id
)
{
uni
.
reLaunch
({
url
:
'
/pages/index/index
'
});
}
},
{
imediate
:
true
})
import
{
reactive
,
watch
}
from
"
vue
"
import
{
signup
,
user
,
account
}
from
"
../service
"
;
const
data
=
reactive
({
username
:
""
,
password
:
""
,
password1
:
''
})
watch
(()
=>
account
.
data
.
state
,
(
nv
,
ov
)
=>
{
if
(
nv
===
1
)
{
uni
.
reLaunch
({
url
:
'
/pages/index/index
'
});
}
},
{
imediate
:
true
})
</
script
>
<
style
scoped=
""
lang=
"scss"
>
.input-list
{
padding
:
50upx
70upx
;
}
.input-list
{
padding
:
50upx
70upx
;
}
.list-call
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
space-between
;
align-items
:
center
;
height
:
100upx
;
color
:
#333333
;
border-bottom
:
1upx
solid
rgba
(
230
,
230
,
230
,
1
);
.list-call
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
space-between
;
align-items
:
center
;
height
:
100upx
;
color
:
#333333
;
border-bottom
:
1upx
solid
rgba
(
230
,
230
,
230
,
1
);
input
{
width
:
100%
;
input
{
width
:
100%
;
}
}
}
.dlbutton
{
color
:
#ffffff
;
font-size
:
34upx
;
width
:
470upx
;
height
:
100upx
;
background
:
linear-gradient
(
-90deg
,
rgba
(
63
,
205
,
235
,
1
)
,
rgba
(
188
,
226
,
158
,
1
)
);
box-shadow
:
0upx
0upx
13upx
0upx
rgba
(
164
,
217
,
228
,
0
.2
);
border-radius
:
50upx
;
line-height
:
100upx
;
text-align
:
center
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-top
:
100upx
;
}
.dlbutton
{
color
:
#ffffff
;
font-size
:
34upx
;
width
:
470upx
;
height
:
100upx
;
background
:
linear-gradient
(
-90deg
,
rgba
(
63
,
205
,
235
,
1
)
,
rgba
(
188
,
226
,
158
,
1
));
box-shadow
:
0upx
0upx
13upx
0upx
rgba
(
164
,
217
,
228
,
0
.2
);
border-radius
:
50upx
;
line-height
:
100upx
;
text-align
:
center
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-top
:
100upx
;
}
.dlbutton-hover
{
background
:
linear-gradient
(
-90deg
,
rgba
(
63
,
205
,
235
,
0
.9
)
,
rgba
(
188
,
226
,
158
,
0
.9
)
);
}
.dlbutton-hover
{
background
:
linear-gradient
(
-90deg
,
rgba
(
63
,
205
,
235
,
0
.9
)
,
rgba
(
188
,
226
,
158
,
0
.9
));
}
.addition
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
center
;
align-items
:
center
;
font-size
:
30upx
;
margin-top
:
80upx
;
color
:
#ffa800
;
text-align
:
center
;
height
:
40upx
;
line-height
:
40upx
;
}
.addition
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
center
;
align-items
:
center
;
font-size
:
30upx
;
margin-top
:
80upx
;
color
:
#ffa800
;
text-align
:
center
;
height
:
40upx
;
line-height
:
40upx
;
}
</
style
>
pages.json
浏览文件 @
ee2ed195
{
"pages"
:
[
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path"
:
"pages/index/index"
,
"style"
:
{
"navigationBarTitleText"
:
"DDP Demo"
}
}
,{
"path"
:
"modules/user/signin/signin"
,
"style"
:
{
...
...
@@ -14,7 +8,14 @@
"enablePullDownRefresh"
:
false
}
}
},
{
"path"
:
"pages/index/index"
,
"style"
:
{
"navigationBarTitleText"
:
"DDP Demo"
}
}
,{
"path"
:
"modules/user/signup/signup"
,
"style"
:
...
...
uni_modules/hj-ddp/changelog.md
浏览文件 @
ee2ed195
## 1.2.3(2022-04-16)
提供一个callAsync方法,返回promise简化rpc调用回调模式
## 1.2.2(2022-04-16)
更新readme
## 1.2.1(2022-04-16)
...
...
uni_modules/hj-ddp/js_sdk/hj-ddp.es.js
浏览文件 @
ee2ed195
...
...
@@ -244,7 +244,7 @@ class DDPConnection extends EventEmitter {
});
if
(
oldIndex
>
-
1
)
{
const
oo
=
this
.
messages
.
splice
(
oldIndex
,
1
)[
0
];
this
.
revokeCallBack
(
oo
.
id
,
[
1
,
"
ignored
"
]
);
this
.
revokeCallBack
(
oo
.
id
,
"
忽略了相同参数的相同方法调用
"
);
}
}
this
.
messages
.
push
(
data
);
...
...
@@ -337,7 +337,7 @@ class DDPConnection extends EventEmitter {
}
}
var
IDDPConnectionState
;
(
function
(
IDDPConnectionState2
)
{
(
function
(
IDDPConnectionState2
)
{
IDDPConnectionState2
[
IDDPConnectionState2
[
"
CLOSED
"
]
=
0
]
=
"
CLOSED
"
;
IDDPConnectionState2
[
IDDPConnectionState2
[
"
CONNECTING
"
]
=
1
]
=
"
CONNECTING
"
;
IDDPConnectionState2
[
IDDPConnectionState2
[
"
CONNECTED
"
]
=
2
]
=
"
CONNECTED
"
;
...
...
@@ -362,7 +362,9 @@ class Client {
if
(
this
.
connection
.
state
===
DDPConnectionState
.
CONNECTED
)
{
return
resolve
()
}
const
cb
=
({
state
})
=>
{
const
cb
=
({
state
})
=>
{
if
(
state
===
DDPConnectionState
.
CONNECTED
)
{
this
.
connection
.
off
(
DDPConnectionEvent
.
STATE_CHANGE
,
cb
)
resolve
()
...
...
@@ -374,7 +376,9 @@ class Client {
if
(
this
.
connection
.
state
!==
DDPConnectionState
.
CONNECTED
)
{
return
resolve
()
}
const
cb
=
({
state
})
=>
{
const
cb
=
({
state
})
=>
{
if
(
state
!==
DDPConnectionState
.
CONNECTED
)
{
this
.
connection
.
off
(
DDPConnectionEvent
.
STATE_CHANGE
,
cb
)
resolve
()
...
...
@@ -397,7 +401,9 @@ class Client {
return
()
=>
onCloses
.
delete
(
cb
)
}
let
connected
=
false
;
this
.
connection
.
on
(
DDPConnectionEvent
.
STATE_CHANGE
,
({
state
})
=>
{
this
.
connection
.
on
(
DDPConnectionEvent
.
STATE_CHANGE
,
({
state
})
=>
{
const
newState
=
state
===
DDPConnectionState
.
CONNECTED
;
if
(
newState
===
connected
)
return
;
connected
=
newState
;
...
...
@@ -409,6 +415,11 @@ class Client {
const
callback
=
args
.
filter
((
el
)
=>
typeof
el
===
"
function
"
);
return
this
.
connection
.
call
(
name
,
callArgs
,
callback
[
0
],
callback
[
1
]);
}
callAsync
(
name
,
...
args
)
{
return
new
Promise
((
res
,
rej
)
=>
{
this
.
connection
.
call
(
name
,
callArgs
,
(
err
,
data
)
=>
err
?
rej
(
err
)
:
res
(
data
));
})
}
subscribe
(
name
,
...
args
)
{
const
callArgs
=
args
.
filter
((
el
)
=>
typeof
el
!==
"
function
"
);
const
callback
=
args
.
filter
((
el
)
=>
typeof
el
===
"
function
"
);
...
...
uni_modules/hj-ddp/package.json
浏览文件 @
ee2ed195
{
"id"
:
"hj-ddp"
,
"displayName"
:
"DDP协议的Uniapp插件实现【附带MiniMongo Selector】"
,
"version"
:
"1.2.
2
"
,
"version"
:
"1.2.
3
"
,
"description"
:
"一个uniapp的DDP客户端实现,助你成为全栈工程师,哈哈~"
,
"keywords"
:
[
"hj-ddp"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录