init
commit
458639ab75
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Eslint config file
|
||||||
|
* Documentation: https://eslint.org/docs/user-guide/configuring/
|
||||||
|
* Install the Eslint extension before using this feature.
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
es6: true,
|
||||||
|
browser: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
ecmaFeatures: {
|
||||||
|
modules: true,
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2018,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
wx: true,
|
||||||
|
App: true,
|
||||||
|
Page: true,
|
||||||
|
getCurrentPages: true,
|
||||||
|
getApp: true,
|
||||||
|
Component: true,
|
||||||
|
requirePlugin: true,
|
||||||
|
requireMiniProgram: true,
|
||||||
|
},
|
||||||
|
// extends: 'eslint:recommended',
|
||||||
|
rules: {},
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
const net = require("./request")
|
||||||
|
const request={
|
||||||
|
getWineList:function(data:any) {
|
||||||
|
return net.request({
|
||||||
|
api:'/api/v1/wine',
|
||||||
|
method:"GET",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
module.exports = request
|
@ -0,0 +1,59 @@
|
|||||||
|
// var baseUrl = "https://dfhd.guwengkj.com";
|
||||||
|
var baseUrl = "http://192.168.1.40:8083";
|
||||||
|
// const APPID = "wx3d38ce1103a82225";
|
||||||
|
// const SECRET = '3c41ca428b4d0f43cfaef6f567a1cc06';
|
||||||
|
const service = {
|
||||||
|
request:(options:any) => {
|
||||||
|
let {api,data={},method="POST",header='',callback} = options
|
||||||
|
var url=baseUrl+api
|
||||||
|
if(api.includes("http")){// 特殊接口
|
||||||
|
url=api
|
||||||
|
}
|
||||||
|
//获取token 缓存
|
||||||
|
var token= wx.getStorageSync('token')
|
||||||
|
if(token)token="Bearer "+token
|
||||||
|
if(!header){
|
||||||
|
header={
|
||||||
|
// 'content-type': 'application/x-www-form-urlencoded'
|
||||||
|
'content-type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
header["Authorization"]=token || 'Basic ZGV2OmRldjEyMw== '
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
wx.request({
|
||||||
|
url: url,
|
||||||
|
data,
|
||||||
|
method,
|
||||||
|
header,
|
||||||
|
success (res:any) {
|
||||||
|
// console.log(res.data)
|
||||||
|
resolve(res.data)
|
||||||
|
},
|
||||||
|
fail(error:any){
|
||||||
|
wx.showToast({
|
||||||
|
title: error.errMsg,
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(error)
|
||||||
|
},
|
||||||
|
complete(res:any){
|
||||||
|
// console.log(res);
|
||||||
|
if(res.data.code == 401) { // token过期
|
||||||
|
wx.showToast({
|
||||||
|
title: res.data.message,
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
wx.setStorageSync('token', '');//清空token
|
||||||
|
// wx.navigateTo({ // 跳转登录页
|
||||||
|
// url: '/pages/login/login',
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// export default service;
|
||||||
|
module.exports = service
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"pages": [
|
||||||
|
"pages/home/home",
|
||||||
|
"pages/index/index",
|
||||||
|
"pages/logs/logs",
|
||||||
|
"pages/star/star",
|
||||||
|
"pages/search/search",
|
||||||
|
"pages/detail/detail"
|
||||||
|
],
|
||||||
|
"window": {
|
||||||
|
"backgroundTextStyle": "light",
|
||||||
|
"navigationBarBackgroundColor": "#fff",
|
||||||
|
"navigationBarTitleText": "Weixin",
|
||||||
|
"navigationBarTextStyle": "black"
|
||||||
|
},
|
||||||
|
"style": "v2",
|
||||||
|
"sitemapLocation": "sitemap.json"
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/**app.wxss**/
|
||||||
|
@font-face {
|
||||||
|
font-family: "iconfont"; /* Project id 4030386 */
|
||||||
|
src: url('https://gwjxb.oss-cn-chengdu.aliyuncs.com/TangoBT.ttf') format('truetype');
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
// padding: 200rpx 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
.c-part{
|
||||||
|
margin-bottom: 20px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.gray-samll-text{
|
||||||
|
color: gray;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
.small-text{
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
.std-small-text{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.std-text{
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.picker{
|
||||||
|
display: flex;
|
||||||
|
// align-items: center;
|
||||||
|
.picker-icon>image{
|
||||||
|
width: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-ellipsis-1{ /*超出部分省略号 单行*/
|
||||||
|
overflow:hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
-webkit-line-clamp: 1;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
/* min-height: 38rpx; */
|
||||||
|
}
|
||||||
|
.part-title{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
.pt-text{
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.pt-line{
|
||||||
|
width: 100%;
|
||||||
|
border-top: 1px solid black;
|
||||||
|
height: 1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
// app.ts
|
||||||
|
App<IAppOption>({
|
||||||
|
globalData: {},
|
||||||
|
onLaunch() {
|
||||||
|
// 展示本地存储能力
|
||||||
|
const logs = wx.getStorageSync('logs') || []
|
||||||
|
logs.unshift(Date.now())
|
||||||
|
wx.setStorageSync('logs', logs)
|
||||||
|
|
||||||
|
// 登录
|
||||||
|
wx.login({
|
||||||
|
success: res => {
|
||||||
|
console.log(res.code)
|
||||||
|
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
||||||
|
},
|
||||||
|
})
|
||||||
|
wx.loadFontFace({
|
||||||
|
family: 'iconfont',
|
||||||
|
source: 'url("https://gwjxb.oss-cn-chengdu.aliyuncs.com/TangoBT.ttf")',
|
||||||
|
success: (res) => {
|
||||||
|
console.log(res);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {},
|
||||||
|
"navigationBarTitleText": "我喜欢的鸡尾酒"
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
/* pages/detail/detail.wxss */
|
||||||
|
.container{
|
||||||
|
.c-part{
|
||||||
|
padding:0 10px;
|
||||||
|
}
|
||||||
|
.detail-name{
|
||||||
|
font-family: 'iconfont';
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-size: 35px;
|
||||||
|
}
|
||||||
|
.material-part{
|
||||||
|
.mp-list{
|
||||||
|
margin-top: 10px;
|
||||||
|
.mpl-card{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 15px 0;
|
||||||
|
border-bottom: 1px solid rgb(231, 231, 231);
|
||||||
|
.m-name{
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:last-child{
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.step-part{
|
||||||
|
.step-box{
|
||||||
|
.step-card{
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
padding: 10px 20px;
|
||||||
|
.step-index{
|
||||||
|
font-size: 25px;
|
||||||
|
font-weight: 900;
|
||||||
|
margin-right: 20px;
|
||||||
|
font-family: "iconfont";
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
.step-desc{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.deep-part{
|
||||||
|
.deep-box{
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.fixed-part{
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
.fixed-part-wrap{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
.fp-item{
|
||||||
|
image{
|
||||||
|
width: 23px;
|
||||||
|
padding: 10px;
|
||||||
|
// background: red;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.measure-part{
|
||||||
|
.mp-box{
|
||||||
|
.mpb-item{
|
||||||
|
display: flex;
|
||||||
|
justify-content:space-between;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
align-items: center;
|
||||||
|
.mpb-left{
|
||||||
|
|
||||||
|
}
|
||||||
|
.mpb-right{
|
||||||
|
.mpb-operation-box{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 10px;
|
||||||
|
.subtraction{
|
||||||
|
}
|
||||||
|
.add{
|
||||||
|
}
|
||||||
|
.disabled-add{
|
||||||
|
color: #e4e4e4;
|
||||||
|
}
|
||||||
|
.ob-btn{
|
||||||
|
font-size: 25px;
|
||||||
|
font-weight: 900;
|
||||||
|
line-height: 10px;
|
||||||
|
padding:10px;
|
||||||
|
}
|
||||||
|
.person-numer{
|
||||||
|
input{
|
||||||
|
width: 20px;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.close-btn{
|
||||||
|
position: fixed;
|
||||||
|
bottom: 50px;
|
||||||
|
right: 20px;
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
<view class="container" id="detail-container" style="padding: 10px;">
|
||||||
|
<view class="detail-name c-part" style="text-align: center;">
|
||||||
|
{{title}}
|
||||||
|
</view>
|
||||||
|
<view class="material-part c-part">
|
||||||
|
<view class="part-title">
|
||||||
|
<view class="pt-text std-small-text" style="font-weight: 900;margin-right: 10px;">材料</view>
|
||||||
|
<view class="pt-line"></view>
|
||||||
|
</view>
|
||||||
|
<view class="mp-list">
|
||||||
|
<view class="mpl-card" wx:for="{{material_data}}" wx:key="name" wx:for-item="item">
|
||||||
|
<view class="m-name std-text">
|
||||||
|
{{item.name}}
|
||||||
|
</view>
|
||||||
|
<view class="m-unit small-text">
|
||||||
|
{{item.unit}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="step-part c-part">
|
||||||
|
<view class="part-title">
|
||||||
|
<view class="pt-text std-small-text" style="font-weight: 900;margin-right: 10px;">步骤</view>
|
||||||
|
<view class="pt-line"></view>
|
||||||
|
</view>
|
||||||
|
<view class="step-box">
|
||||||
|
<view class="step-detail step-card" wx:for="{{steps}}" wx:for-item="item" wx:key="desc" wx:for-index="index">
|
||||||
|
<view class="step-index">
|
||||||
|
{{index+1}}
|
||||||
|
</view>
|
||||||
|
<view class="step-desc std-small-text">
|
||||||
|
{{item.desc}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view hidden="{{measure_flag}}" class="deep-part c-part" style="margin-bottom: 80px;">
|
||||||
|
<view class="part-title">
|
||||||
|
<view class="pt-text std-small-text" style="font-weight: 900;margin-right: 10px;">深入</view>
|
||||||
|
<view class="pt-line"></view>
|
||||||
|
</view>
|
||||||
|
<view class="deep-box std-small-text">
|
||||||
|
<rich-text nodes="{{deep_info}}"></rich-text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view hidden="{{measure_flag}}" class="fixed-part c-part">
|
||||||
|
<view class="fixed-part-wrap">
|
||||||
|
<view class="fp-left fp-item">
|
||||||
|
<image bindtap="openMeasureFunc" style="background: rgb(253, 253, 31);" src="../../assets/ruler.png" mode="widthFix" />
|
||||||
|
</view>
|
||||||
|
<view class="fp-right fp-item">
|
||||||
|
<image style="background: rgb(84, 84, 201);margin-right: 10px;" src="../../assets/share.png" mode="widthFix" />
|
||||||
|
<image style="background: rgb(219, 78, 78);" src="../../assets/star.png" mode="widthFix" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view hidden="{{!measure_flag}}" class="close-btn" bindtap="closeFunc">
|
||||||
|
<icon color="black" class="icon-box-img" type="cancel" size="30"></icon>
|
||||||
|
</view>
|
||||||
|
<view hidden="{{!measure_flag}}" class="measure-part c-part">
|
||||||
|
<view class="part-title">
|
||||||
|
<view class="pt-text std-small-text" style="font-weight: 900;margin-right: 10px;">度量实用工具</view>
|
||||||
|
<view class="pt-line"></view>
|
||||||
|
</view>
|
||||||
|
<view class="mp-box">
|
||||||
|
<view class="mpb-item" style="padding-top: 20px;">
|
||||||
|
<view class="mpb-left std-small-text">
|
||||||
|
表示方式
|
||||||
|
</view>
|
||||||
|
<view class="mpb-right std-small-text">
|
||||||
|
<picker bindchange="measureShowTypesChange" range-key="name" value="{{measure_show_types_index}}" range="{{measure_show_types}}">
|
||||||
|
<view class="picker">
|
||||||
|
{{measure_show_types[measure_show_types_index].name}}
|
||||||
|
<view class="picker-icon">
|
||||||
|
<image src="../../assets/more.png" mode="widthFix"/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="mpb-item">
|
||||||
|
<view class="mpb-left std-small-text">
|
||||||
|
测量单位
|
||||||
|
</view>
|
||||||
|
<view class="mpb-right std-small-text">
|
||||||
|
<picker bindchange="measureUnitsChange" range-key="name" value="{{measure_units_index}}" range="{{measure_units}}">
|
||||||
|
<view class="picker">
|
||||||
|
{{measure_units[measure_units_index].name}}
|
||||||
|
<view class="picker-icon">
|
||||||
|
<image src="../../assets/more.png" mode="widthFix"/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="mpb-item">
|
||||||
|
<view class="mpb-left std-small-text">
|
||||||
|
份数
|
||||||
|
</view>
|
||||||
|
<view class="mpb-right std-small-text">
|
||||||
|
<view class="mpb-operation-box">
|
||||||
|
<view wx-if="{{person_number>1}}" bindtap="personNumberFunc" data-type='1' class="subtraction ob-btn">-</view>
|
||||||
|
<view wx-if="{{person_number == 1}}" class="subtraction ob-btn disabled-add">-</view>
|
||||||
|
<view class="person-numer">
|
||||||
|
<input value="{{person_number}}" type="numer"/>
|
||||||
|
</view>
|
||||||
|
<view class="add ob-btn" bindtap="personNumberFunc" data-type='2'>+</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {},
|
||||||
|
"navigationBarTitleText": "我喜欢的鸡尾酒"
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
/* pages/home/home.wxss */
|
||||||
|
.operation-part{
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
.btn{
|
||||||
|
border: 1px solid red;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin: 0 5px;
|
||||||
|
color: red;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.star-btn{
|
||||||
|
border: 1px solid rgb(192, 21, 21);
|
||||||
|
color: rgb(192, 21, 21);
|
||||||
|
}
|
||||||
|
.question-btn{
|
||||||
|
padding:0 10px;
|
||||||
|
display:flex;
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid rgb(21, 144, 192);
|
||||||
|
color: rgb(21, 144, 192);
|
||||||
|
image{
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.introduce-part {
|
||||||
|
text-align: center;
|
||||||
|
.title{
|
||||||
|
font-family: 'iconfont';
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-size: 35px;
|
||||||
|
}
|
||||||
|
.desc{
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.list-part{
|
||||||
|
.lp-card{
|
||||||
|
display: flex;
|
||||||
|
padding: 10px;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
.lpc-name-box{
|
||||||
|
width:70%;
|
||||||
|
.lpc-name{
|
||||||
|
width: 100%;
|
||||||
|
font-family: 'iconfont';
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.lpc-tag{
|
||||||
|
white-space: nowrap;
|
||||||
|
width:30%;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.desc-part{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.search-part{
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 20px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
.search-btn{
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
background-color: rgb(243, 243, 243);
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: 1px 1px #a9a9a9;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,119 @@
|
|||||||
|
// pages/home/home.ts
|
||||||
|
const api = require("../../api/index")
|
||||||
|
Page({
|
||||||
|
/**
|
||||||
|
* 页面的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
introduce:`在家制作鸡尾酒是一种生活方式`,
|
||||||
|
list:[
|
||||||
|
{
|
||||||
|
name:'the last word',
|
||||||
|
desc:'橙汁',
|
||||||
|
tag:'遗言',
|
||||||
|
id:1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:'june bug',
|
||||||
|
tag:'六月虫',
|
||||||
|
desc:'青柠汁',
|
||||||
|
id:2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面加载
|
||||||
|
*/
|
||||||
|
onLoad() {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
|
*/
|
||||||
|
onReady() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
|
onHide() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
|
onUnload() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh() {
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom() {
|
||||||
|
console.log(1111);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击右上角分享
|
||||||
|
*/
|
||||||
|
onShareAppMessage() {
|
||||||
|
|
||||||
|
},
|
||||||
|
// 我喜欢的鸡尾酒
|
||||||
|
toStarFunc() {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '../star/star',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 搜索配方
|
||||||
|
toSearchFunc() {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '../search/search',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toDetailFunc(data:any) {
|
||||||
|
console.log(data);
|
||||||
|
const item = data.currentTarget.dataset.item
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '../detail/detail?name='+item.name+'&tag='+item.tag,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async getList() {//获取列表
|
||||||
|
const res = await api.getWineList({
|
||||||
|
current:1,
|
||||||
|
size:10
|
||||||
|
})
|
||||||
|
console.log(res);
|
||||||
|
if(res.code === 200) {
|
||||||
|
// if(res.data.materials.length>0) {
|
||||||
|
for(let item1 of res.data) {
|
||||||
|
item1.materials_str = ''
|
||||||
|
if(item1.materials.length>0) {
|
||||||
|
item1.materials.forEach((item:any,i:number) => {
|
||||||
|
item1.materials_str += item.name+','
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.log(item1.materials_str)
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
@ -0,0 +1,28 @@
|
|||||||
|
<view class="container" style="padding: 10px;">
|
||||||
|
<view class="introduce-part c-part">
|
||||||
|
<view class="title">Make My Drink</view>
|
||||||
|
<view class="desc">
|
||||||
|
{{introduce}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="operation-part c-part">
|
||||||
|
<view class="star-btn btn" bindtap="toStarFunc" style="width: 50%;"> 我喜欢的鸡尾酒</view>
|
||||||
|
<view class="question-btn btn">
|
||||||
|
<image src="../../assets/question.png" mode="widthFix"/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="list-part c-part">
|
||||||
|
<view class="lp-card" wx:for="{{list}}" bindtap="toDetailFunc" data-item="{{item}}" wx:for-item="item" wx:key="id">
|
||||||
|
<view class="lpc-name-box">
|
||||||
|
<view class="lpc-name text-ellipsis-1" style="margin-bottom: 5px;"> {{item.name}}</view>
|
||||||
|
<view class="small-text text-ellipsis-1"> {{item.desc}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="lpc-tag std-small-text text-ellipsis-1">
|
||||||
|
{{item.tag}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="search-part">
|
||||||
|
<image bindtap="toSearchFunc" class="search-btn" src="../../assets/search.png" mode="widthFix"/>
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
/**index.wxss**/
|
||||||
|
.userinfo {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.userinfo-avatar {
|
||||||
|
overflow: hidden;
|
||||||
|
width: 128rpx;
|
||||||
|
height: 128rpx;
|
||||||
|
margin: 20rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.usermotto {
|
||||||
|
margin-top: 200px;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
<!--index.wxml-->
|
||||||
|
<view class="container">
|
||||||
|
<view class="userinfo">
|
||||||
|
<block wx:if="{{canIUseOpenData}}">
|
||||||
|
<view class="userinfo-avatar" bindtap="bindViewTap">
|
||||||
|
<open-data type="userAvatarUrl"></open-data>
|
||||||
|
</view>
|
||||||
|
<open-data type="userNickName"></open-data>
|
||||||
|
</block>
|
||||||
|
<block wx:elif="{{!hasUserInfo}}">
|
||||||
|
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
|
||||||
|
<button wx:elif="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
|
||||||
|
<view wx:else> 请使用1.4.4及以上版本基础库 </view>
|
||||||
|
</block>
|
||||||
|
<block wx:else>
|
||||||
|
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
|
||||||
|
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<view class="usermotto">
|
||||||
|
<text class="user-motto">{{motto}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"navigationBarTitleText": "查看启动日志",
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
// logs.ts
|
||||||
|
// const util = require('../../utils/util.js')
|
||||||
|
import { formatTime } from '../../utils/util'
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
logs: [],
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
this.setData({
|
||||||
|
logs: (wx.getStorageSync('logs') || []).map((log: string) => {
|
||||||
|
return {
|
||||||
|
date: formatTime(new Date(log)),
|
||||||
|
timeStamp: log
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
@ -0,0 +1,6 @@
|
|||||||
|
<!--logs.wxml-->
|
||||||
|
<view class="container log-list">
|
||||||
|
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
|
||||||
|
<text class="log-item">{{index + 1}}. {{log.date}}</text>
|
||||||
|
</block>
|
||||||
|
</view>
|
@ -0,0 +1,8 @@
|
|||||||
|
.log-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 40rpx;
|
||||||
|
}
|
||||||
|
.log-item {
|
||||||
|
margin: 10rpx;
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {},
|
||||||
|
"navigationBarTitleText": "搜索配方"
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
.operation-part{
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
.btn{
|
||||||
|
border: 1px solid red;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin: 0 5px;
|
||||||
|
color: red;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.star-btn{
|
||||||
|
border: 1px solid rgb(192, 21, 21);
|
||||||
|
color: rgb(192, 21, 21);
|
||||||
|
}
|
||||||
|
.question-btn{
|
||||||
|
padding:0 10px;
|
||||||
|
display:flex;
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid rgb(21, 144, 192);
|
||||||
|
color: rgb(21, 144, 192);
|
||||||
|
image{
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.introduce-part {
|
||||||
|
text-align: center;
|
||||||
|
.title{
|
||||||
|
font-family: 'iconfont';
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-size: 35px;
|
||||||
|
}
|
||||||
|
.desc{
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.list-part{
|
||||||
|
width: 95% !important;
|
||||||
|
margin-top: 50px;
|
||||||
|
.lp-card{
|
||||||
|
display: flex;
|
||||||
|
padding: 10px;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
.lpc-name-box{
|
||||||
|
width:70%;
|
||||||
|
.lpc-name{
|
||||||
|
width: 100%;
|
||||||
|
font-family: 'iconfont';
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.lpc-tag{
|
||||||
|
white-space: nowrap;
|
||||||
|
width:30%;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.desc-part{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.search-part{
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
top: 10px;
|
||||||
|
text-align: right;
|
||||||
|
box-sizing: border-box;
|
||||||
|
left: 0;
|
||||||
|
.search-box{
|
||||||
|
background-color: rgb(243, 243, 243);
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
.search-icon{
|
||||||
|
width: 15px;
|
||||||
|
}
|
||||||
|
.search-input{
|
||||||
|
font-size: 12px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
// pages/search/search.ts
|
||||||
|
Page({
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
list:[
|
||||||
|
{
|
||||||
|
name:'the last word',
|
||||||
|
desc:'橙汁',
|
||||||
|
tag:'遗言',
|
||||||
|
id:1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:'june bug',
|
||||||
|
tag:'六月虫',
|
||||||
|
desc:'青柠汁',
|
||||||
|
id:2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面加载
|
||||||
|
*/
|
||||||
|
onLoad() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
|
*/
|
||||||
|
onReady() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
|
onHide() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
|
onUnload() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击右上角分享
|
||||||
|
*/
|
||||||
|
onShareAppMessage() {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,22 @@
|
|||||||
|
<view class="container" style="padding: 10px;">
|
||||||
|
<view class="search-part c-part">
|
||||||
|
<view class="search-box">
|
||||||
|
<image class="search-icon" src="../../assets/search.png" mode="widthFix"/>
|
||||||
|
<input class="search-input" type="text" placeholder="搜索鸡尾酒" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="list-part c-part" wx:if="{{list.length>0}}">
|
||||||
|
<view class="lp-card" wx:for="{{list}}" wx:for-item="item" wx:key="id">
|
||||||
|
<view class="lpc-name-box">
|
||||||
|
<view class="lpc-name text-ellipsis-1" style="margin-bottom: 5px;"> {{item.name}}</view>
|
||||||
|
<view class="small-text text-ellipsis-1"> {{item.desc}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="lpc-tag std-small-text text-ellipsis-1">
|
||||||
|
{{item.tag}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view wx:else="{{list.length<1}}">
|
||||||
|
暂无数据
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {},
|
||||||
|
"navigationBarTitleText": "我的收藏"
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
/* pages/home/home.wxss */
|
||||||
|
.operation-part{
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
.btn{
|
||||||
|
border: 1px solid red;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin: 0 5px;
|
||||||
|
color: red;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.star-btn{
|
||||||
|
border: 1px solid rgb(192, 21, 21);
|
||||||
|
color: rgb(192, 21, 21);
|
||||||
|
}
|
||||||
|
.question-btn{
|
||||||
|
padding:0 10px;
|
||||||
|
display:flex;
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid rgb(21, 144, 192);
|
||||||
|
color: rgb(21, 144, 192);
|
||||||
|
image{
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.introduce-part {
|
||||||
|
text-align: center;
|
||||||
|
.title{
|
||||||
|
font-family: 'iconfont';
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-size: 35px;
|
||||||
|
}
|
||||||
|
.desc{
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.list-part{
|
||||||
|
.lp-card{
|
||||||
|
display: flex;
|
||||||
|
padding: 10px;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
.lpc-name-box{
|
||||||
|
width:70%;
|
||||||
|
.lpc-name{
|
||||||
|
width: 100%;
|
||||||
|
font-family: 'iconfont';
|
||||||
|
text-transform: capitalize;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.lpc-tag{
|
||||||
|
white-space: nowrap;
|
||||||
|
width:30%;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.desc-part{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.search-part{
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 20px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
.search-btn{
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
background-color: rgb(243, 243, 243);
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: 1px 1px #a9a9a9;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
// pages/star/star.ts
|
||||||
|
Page({
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
list:[
|
||||||
|
{
|
||||||
|
name:'the last word',
|
||||||
|
desc:'橙汁',
|
||||||
|
tag:'遗言',
|
||||||
|
id:1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:'june bug',
|
||||||
|
tag:'六月虫',
|
||||||
|
desc:'青柠汁',
|
||||||
|
id:2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面加载
|
||||||
|
*/
|
||||||
|
onLoad() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
|
*/
|
||||||
|
onReady() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
|
onHide() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
|
onUnload() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击右上角分享
|
||||||
|
*/
|
||||||
|
onShareAppMessage() {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,13 @@
|
|||||||
|
<view class="container" style="padding: 10px;">
|
||||||
|
<view class="list-part c-part">
|
||||||
|
<view class="lp-card" wx:for="{{list}}" wx:for-item="item" wx:key="id">
|
||||||
|
<view class="lpc-name-box">
|
||||||
|
<view class="lpc-name text-ellipsis-1" style="margin-bottom: 5px;"> {{item.name}}</view>
|
||||||
|
<view class="small-text text-ellipsis-1"> {{item.desc}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="lpc-tag std-small-text text-ellipsis-1">
|
||||||
|
{{item.tag}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||||
|
"rules": [{
|
||||||
|
"action": "allow",
|
||||||
|
"page": "*"
|
||||||
|
}]
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
export const formatTime = (date: Date) => {
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = date.getMonth() + 1
|
||||||
|
const day = date.getDate()
|
||||||
|
const hour = date.getHours()
|
||||||
|
const minute = date.getMinutes()
|
||||||
|
const second = date.getSeconds()
|
||||||
|
|
||||||
|
return (
|
||||||
|
[year, month, day].map(formatNumber).join('/') +
|
||||||
|
' ' +
|
||||||
|
[hour, minute, second].map(formatNumber).join(':')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatNumber = (n: number) => {
|
||||||
|
const s = n.toString()
|
||||||
|
return s[1] ? s : '0' + s
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "miniprogram-ts-less-quickstart",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"scripts": {
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "",
|
||||||
|
"dependencies": {
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"miniprogram-api-typings": "^2.8.3-1"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"description": "项目配置文件",
|
||||||
|
"packOptions": {
|
||||||
|
"ignore": [],
|
||||||
|
"include": []
|
||||||
|
},
|
||||||
|
"miniprogramRoot": "miniprogram/",
|
||||||
|
"compileType": "miniprogram",
|
||||||
|
"projectname": "ts-sass-demo",
|
||||||
|
"setting": {
|
||||||
|
"useCompilerPlugins": [
|
||||||
|
"typescript",
|
||||||
|
"sass"
|
||||||
|
],
|
||||||
|
"babelSetting": {
|
||||||
|
"ignore": [],
|
||||||
|
"disablePlugins": [],
|
||||||
|
"outputPath": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"simulatorType": "wechat",
|
||||||
|
"simulatorPluginLibVersion": {},
|
||||||
|
"condition": {},
|
||||||
|
"srcMiniprogramRoot": "miniprogram/",
|
||||||
|
"appid": "wx3d38ce1103a82225",
|
||||||
|
"libVersion": "2.31.0",
|
||||||
|
"editorSetting": {
|
||||||
|
"tabIndent": "insertSpaces",
|
||||||
|
"tabSize": 2
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"module": "CommonJS",
|
||||||
|
"target": "ES2020",
|
||||||
|
"allowJs": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"alwaysStrict": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"strict": true,
|
||||||
|
"strictPropertyInitialization": true,
|
||||||
|
"lib": ["ES2020"],
|
||||||
|
"typeRoots": [
|
||||||
|
"./typings"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
/// <reference path="./types/index.d.ts" />
|
||||||
|
|
||||||
|
interface IAppOption {
|
||||||
|
globalData: {
|
||||||
|
userInfo?: WechatMiniprogram.UserInfo,
|
||||||
|
}
|
||||||
|
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/// <reference path="./wx/index.d.ts" />
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,68 @@
|
|||||||
|
/*! *****************************************************************************
|
||||||
|
Copyright (c) 2023 Tencent, Inc. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
***************************************************************************** */
|
||||||
|
|
||||||
|
declare namespace WechatMiniprogram.Behavior {
|
||||||
|
type BehaviorIdentifier = string
|
||||||
|
type Instance<
|
||||||
|
TData extends DataOption,
|
||||||
|
TProperty extends PropertyOption,
|
||||||
|
TMethod extends MethodOption,
|
||||||
|
TCustomInstanceProperty extends IAnyObject = Record<string, never>
|
||||||
|
> = Component.Instance<TData, TProperty, TMethod, TCustomInstanceProperty>
|
||||||
|
type TrivialInstance = Instance<IAnyObject, IAnyObject, IAnyObject>
|
||||||
|
type TrivialOption = Options<IAnyObject, IAnyObject, IAnyObject>
|
||||||
|
type Options<
|
||||||
|
TData extends DataOption,
|
||||||
|
TProperty extends PropertyOption,
|
||||||
|
TMethod extends MethodOption,
|
||||||
|
TCustomInstanceProperty extends IAnyObject = Record<string, never>
|
||||||
|
> = Partial<Data<TData>> &
|
||||||
|
Partial<Property<TProperty>> &
|
||||||
|
Partial<Method<TMethod>> &
|
||||||
|
Partial<OtherOption> &
|
||||||
|
Partial<Lifetimes> &
|
||||||
|
ThisType<Instance<TData, TProperty, TMethod, TCustomInstanceProperty>>
|
||||||
|
interface Constructor {
|
||||||
|
<
|
||||||
|
TData extends DataOption,
|
||||||
|
TProperty extends PropertyOption,
|
||||||
|
TMethod extends MethodOption,
|
||||||
|
TCustomInstanceProperty extends IAnyObject = Record<string, never>
|
||||||
|
>(
|
||||||
|
options: Options<TData, TProperty, TMethod, TCustomInstanceProperty>
|
||||||
|
): BehaviorIdentifier
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataOption = Component.DataOption
|
||||||
|
type PropertyOption = Component.PropertyOption
|
||||||
|
type MethodOption = Component.MethodOption
|
||||||
|
type Data<D extends DataOption> = Component.Data<D>
|
||||||
|
type Property<P extends PropertyOption> = Component.Property<P>
|
||||||
|
type Method<M extends MethodOption> = Component.Method<M>
|
||||||
|
|
||||||
|
type DefinitionFilter = Component.DefinitionFilter
|
||||||
|
type Lifetimes = Component.Lifetimes
|
||||||
|
|
||||||
|
type OtherOption = Omit<Component.OtherOption, 'options'>
|
||||||
|
}
|
||||||
|
/** 注册一个 `behavior`,接受一个 `Object` 类型的参数。*/
|
||||||
|
declare let Behavior: WechatMiniprogram.Behavior.Constructor
|
@ -0,0 +1,979 @@
|
|||||||
|
/*! *****************************************************************************
|
||||||
|
Copyright (c) 2023 Tencent, Inc. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
***************************************************************************** */
|
||||||
|
|
||||||
|
interface IAPIError {
|
||||||
|
errMsg: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IAPIParam<T = any> {
|
||||||
|
config?: ICloudConfig
|
||||||
|
success?: (res: T) => void
|
||||||
|
fail?: (err: IAPIError) => void
|
||||||
|
complete?: (val: T | IAPIError) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IAPISuccessParam {
|
||||||
|
errMsg: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type IAPICompleteParam = IAPISuccessParam | IAPIError
|
||||||
|
|
||||||
|
type IAPIFunction<T, P extends IAPIParam<T>> = (param?: P) => Promise<T>
|
||||||
|
|
||||||
|
interface IInitCloudConfig {
|
||||||
|
env?:
|
||||||
|
| string
|
||||||
|
| {
|
||||||
|
database?: string
|
||||||
|
functions?: string
|
||||||
|
storage?: string
|
||||||
|
}
|
||||||
|
traceUser?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICloudConfig {
|
||||||
|
env?: string
|
||||||
|
traceUser?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IICloudAPI {
|
||||||
|
init: (config?: IInitCloudConfig) => void
|
||||||
|
[api: string]: AnyFunction | IAPIFunction<any, any>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICloudService {
|
||||||
|
name: string
|
||||||
|
|
||||||
|
getAPIs: () => { [name: string]: IAPIFunction<any, any> }
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICloudServices {
|
||||||
|
[serviceName: string]: ICloudService
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICloudMetaData {
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class InternalSymbol {}
|
||||||
|
|
||||||
|
interface AnyObject {
|
||||||
|
[x: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
type AnyArray = any[]
|
||||||
|
|
||||||
|
type AnyFunction = (...args: any[]) => any
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extend wx with cloud
|
||||||
|
*/
|
||||||
|
interface WxCloud {
|
||||||
|
init: (config?: ICloudConfig) => void
|
||||||
|
|
||||||
|
callFunction(param: OQ<ICloud.CallFunctionParam>): void
|
||||||
|
callFunction(
|
||||||
|
param: RQ<ICloud.CallFunctionParam>
|
||||||
|
): Promise<ICloud.CallFunctionResult>
|
||||||
|
|
||||||
|
uploadFile(param: OQ<ICloud.UploadFileParam>): WechatMiniprogram.UploadTask
|
||||||
|
uploadFile(
|
||||||
|
param: RQ<ICloud.UploadFileParam>
|
||||||
|
): Promise<ICloud.UploadFileResult>
|
||||||
|
|
||||||
|
downloadFile(
|
||||||
|
param: OQ<ICloud.DownloadFileParam>
|
||||||
|
): WechatMiniprogram.DownloadTask
|
||||||
|
downloadFile(
|
||||||
|
param: RQ<ICloud.DownloadFileParam>
|
||||||
|
): Promise<ICloud.DownloadFileResult>
|
||||||
|
|
||||||
|
getTempFileURL(param: OQ<ICloud.GetTempFileURLParam>): void
|
||||||
|
getTempFileURL(
|
||||||
|
param: RQ<ICloud.GetTempFileURLParam>
|
||||||
|
): Promise<ICloud.GetTempFileURLResult>
|
||||||
|
|
||||||
|
deleteFile(param: OQ<ICloud.DeleteFileParam>): void
|
||||||
|
deleteFile(
|
||||||
|
param: RQ<ICloud.DeleteFileParam>
|
||||||
|
): Promise<ICloud.DeleteFileResult>
|
||||||
|
|
||||||
|
database: (config?: ICloudConfig) => DB.Database
|
||||||
|
|
||||||
|
CloudID: ICloud.ICloudIDConstructor
|
||||||
|
CDN: ICloud.ICDNConstructor
|
||||||
|
|
||||||
|
callContainer(param: OQ<ICloud.CallContainerParam>): void
|
||||||
|
callContainer(
|
||||||
|
param: RQ<ICloud.CallContainerParam>
|
||||||
|
): Promise<ICloud.CallContainerResult>
|
||||||
|
|
||||||
|
connectContainer(param: OQ<ICloud.ConnectContainerParam>): void
|
||||||
|
connectContainer(
|
||||||
|
param: RQ<ICloud.ConnectContainerParam>
|
||||||
|
): Promise<ICloud.ConnectContainerResult>
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace ICloud {
|
||||||
|
interface ICloudAPIParam<T = any> extends IAPIParam<T> {
|
||||||
|
config?: ICloudConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
// === API: callFunction ===
|
||||||
|
type CallFunctionData = AnyObject
|
||||||
|
|
||||||
|
interface CallFunctionResult extends IAPISuccessParam {
|
||||||
|
result: AnyObject | string | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CallFunctionParam extends ICloudAPIParam<CallFunctionResult> {
|
||||||
|
name: string
|
||||||
|
data?: CallFunctionData
|
||||||
|
slow?: boolean
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
|
||||||
|
// === API: container ===
|
||||||
|
type CallContainerData = AnyObject
|
||||||
|
|
||||||
|
interface CallContainerResult extends IAPISuccessParam {
|
||||||
|
data: any
|
||||||
|
statusCode: number
|
||||||
|
header: Record<string, any>
|
||||||
|
callID: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CallContainerParam extends ICloudAPIParam<CallContainerResult> {
|
||||||
|
path: string
|
||||||
|
service?: string
|
||||||
|
method?: string
|
||||||
|
header?: Record<string, any>
|
||||||
|
data?: any // string, object, ArrayBuffer
|
||||||
|
dataType?: string
|
||||||
|
responseType?: string
|
||||||
|
timeout?: number
|
||||||
|
verbose?: boolean
|
||||||
|
followRedirect?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConnectContainerResult extends IAPISuccessParam {
|
||||||
|
socketTask: WechatMiniprogram.SocketTask
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConnectSocketOptions extends IAPIParam<void> {
|
||||||
|
header?: Record<string, string>
|
||||||
|
protocols?: string[]
|
||||||
|
tcpNoDelay?: boolean
|
||||||
|
perMessageDeflate?: boolean
|
||||||
|
timeout?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConnectContainerParam = Omit<
|
||||||
|
ConnectSocketOptions,
|
||||||
|
'success' | 'fail' | 'complete'
|
||||||
|
> &
|
||||||
|
ICloudAPIParam<ConnectContainerResult> & {
|
||||||
|
service: string
|
||||||
|
path?: string
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
|
||||||
|
// === API: uploadFile ===
|
||||||
|
interface UploadFileResult extends IAPISuccessParam {
|
||||||
|
fileID: string
|
||||||
|
statusCode: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UploadFileParam extends ICloudAPIParam<UploadFileResult> {
|
||||||
|
cloudPath: string
|
||||||
|
filePath: string
|
||||||
|
header?: AnyObject
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
|
||||||
|
// === API: downloadFile ===
|
||||||
|
interface DownloadFileResult extends IAPISuccessParam {
|
||||||
|
tempFilePath: string
|
||||||
|
statusCode: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DownloadFileParam extends ICloudAPIParam<DownloadFileResult> {
|
||||||
|
fileID: string
|
||||||
|
cloudPath?: string
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
|
||||||
|
// === API: getTempFileURL ===
|
||||||
|
interface GetTempFileURLResult extends IAPISuccessParam {
|
||||||
|
fileList: GetTempFileURLResultItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GetTempFileURLResultItem {
|
||||||
|
fileID: string
|
||||||
|
tempFileURL: string
|
||||||
|
maxAge: number
|
||||||
|
status: number
|
||||||
|
errMsg: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GetTempFileURLParam extends ICloudAPIParam<GetTempFileURLResult> {
|
||||||
|
fileList: string[]
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
|
||||||
|
// === API: deleteFile ===
|
||||||
|
interface DeleteFileResult extends IAPISuccessParam {
|
||||||
|
fileList: DeleteFileResultItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DeleteFileResultItem {
|
||||||
|
fileID: string
|
||||||
|
status: number
|
||||||
|
errMsg: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DeleteFileParam extends ICloudAPIParam<DeleteFileResult> {
|
||||||
|
fileList: string[]
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
|
||||||
|
// === API: CloudID ===
|
||||||
|
abstract class CloudID {
|
||||||
|
constructor(cloudID: string)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICloudIDConstructor {
|
||||||
|
new (cloudId: string): CloudID
|
||||||
|
(cloudId: string): CloudID
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
|
||||||
|
// === API: CDN ===
|
||||||
|
abstract class CDN {
|
||||||
|
target: string | ArrayBuffer | ICDNFilePathSpec
|
||||||
|
constructor(target: string | ArrayBuffer | ICDNFilePathSpec)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICDNFilePathSpec {
|
||||||
|
type: 'filePath'
|
||||||
|
filePath: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICDNConstructor {
|
||||||
|
new (options: string | ArrayBuffer | ICDNFilePathSpec): CDN
|
||||||
|
(options: string | ArrayBuffer | ICDNFilePathSpec): CDN
|
||||||
|
}
|
||||||
|
// === end ===
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Database ===
|
||||||
|
declare namespace DB {
|
||||||
|
/**
|
||||||
|
* The class of all exposed cloud database instances
|
||||||
|
*/
|
||||||
|
class Database {
|
||||||
|
readonly config: ICloudConfig
|
||||||
|
readonly command: DatabaseCommand
|
||||||
|
readonly Geo: IGeo
|
||||||
|
readonly serverDate: () => ServerDate
|
||||||
|
readonly RegExp: IRegExpConstructor
|
||||||
|
|
||||||
|
private constructor()
|
||||||
|
|
||||||
|
collection(collectionName: string): CollectionReference
|
||||||
|
}
|
||||||
|
|
||||||
|
class CollectionReference extends Query {
|
||||||
|
readonly collectionName: string
|
||||||
|
|
||||||
|
private constructor(name: string, database: Database)
|
||||||
|
|
||||||
|
doc(docId: string | number): DocumentReference
|
||||||
|
|
||||||
|
add(options: OQ<IAddDocumentOptions>): void
|
||||||
|
add(options: RQ<IAddDocumentOptions>): Promise<IAddResult>
|
||||||
|
}
|
||||||
|
|
||||||
|
class DocumentReference {
|
||||||
|
private constructor(docId: string | number, database: Database)
|
||||||
|
|
||||||
|
field(object: Record<string, any>): this
|
||||||
|
|
||||||
|
get(options: OQ<IGetDocumentOptions>): void
|
||||||
|
get(options?: RQ<IGetDocumentOptions>): Promise<IQuerySingleResult>
|
||||||
|
|
||||||
|
set(options: OQ<ISetSingleDocumentOptions>): void
|
||||||
|
set(options?: RQ<ISetSingleDocumentOptions>): Promise<ISetResult>
|
||||||
|
|
||||||
|
update(options: OQ<IUpdateSingleDocumentOptions>): void
|
||||||
|
update(
|
||||||
|
options?: RQ<IUpdateSingleDocumentOptions>
|
||||||
|
): Promise<IUpdateResult>
|
||||||
|
|
||||||
|
remove(options: OQ<IRemoveSingleDocumentOptions>): void
|
||||||
|
remove(
|
||||||
|
options?: RQ<IRemoveSingleDocumentOptions>
|
||||||
|
): Promise<IRemoveResult>
|
||||||
|
|
||||||
|
watch(options: IWatchOptions): RealtimeListener
|
||||||
|
}
|
||||||
|
|
||||||
|
class RealtimeListener {
|
||||||
|
// "And Now His Watch Is Ended"
|
||||||
|
close: () => Promise<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
class Query {
|
||||||
|
where(condition: IQueryCondition): Query
|
||||||
|
|
||||||
|
orderBy(fieldPath: string, order: string): Query
|
||||||
|
|
||||||
|
limit(max: number): Query
|
||||||
|
|
||||||
|
skip(offset: number): Query
|
||||||
|
|
||||||
|
field(object: Record<string, any>): Query
|
||||||
|
|
||||||
|
get(options: OQ<IGetDocumentOptions>): void
|
||||||
|
get(options?: RQ<IGetDocumentOptions>): Promise<IQueryResult>
|
||||||
|
|
||||||
|
count(options: OQ<ICountDocumentOptions>): void
|
||||||
|
count(options?: RQ<ICountDocumentOptions>): Promise<ICountResult>
|
||||||
|
|
||||||
|
watch(options: IWatchOptions): RealtimeListener
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DatabaseCommand {
|
||||||
|
eq(val: any): DatabaseQueryCommand
|
||||||
|
neq(val: any): DatabaseQueryCommand
|
||||||
|
gt(val: any): DatabaseQueryCommand
|
||||||
|
gte(val: any): DatabaseQueryCommand
|
||||||
|
lt(val: any): DatabaseQueryCommand
|
||||||
|
lte(val: any): DatabaseQueryCommand
|
||||||
|
in(val: any[]): DatabaseQueryCommand
|
||||||
|
nin(val: any[]): DatabaseQueryCommand
|
||||||
|
|
||||||
|
geoNear(options: IGeoNearCommandOptions): DatabaseQueryCommand
|
||||||
|
geoWithin(options: IGeoWithinCommandOptions): DatabaseQueryCommand
|
||||||
|
geoIntersects(
|
||||||
|
options: IGeoIntersectsCommandOptions
|
||||||
|
): DatabaseQueryCommand
|
||||||
|
|
||||||
|
and(
|
||||||
|
...expressions: Array<DatabaseLogicCommand | IQueryCondition>
|
||||||
|
): DatabaseLogicCommand
|
||||||
|
or(
|
||||||
|
...expressions: Array<DatabaseLogicCommand | IQueryCondition>
|
||||||
|
): DatabaseLogicCommand
|
||||||
|
nor(
|
||||||
|
...expressions: Array<DatabaseLogicCommand | IQueryCondition>
|
||||||
|
): DatabaseLogicCommand
|
||||||
|
not(expression: DatabaseLogicCommand): DatabaseLogicCommand
|
||||||
|
|
||||||
|
exists(val: boolean): DatabaseQueryCommand
|
||||||
|
|
||||||
|
mod(divisor: number, remainder: number): DatabaseQueryCommand
|
||||||
|
|
||||||
|
all(val: any[]): DatabaseQueryCommand
|
||||||
|
elemMatch(val: any): DatabaseQueryCommand
|
||||||
|
size(val: number): DatabaseQueryCommand
|
||||||
|
|
||||||
|
set(val: any): DatabaseUpdateCommand
|
||||||
|
remove(): DatabaseUpdateCommand
|
||||||
|
inc(val: number): DatabaseUpdateCommand
|
||||||
|
mul(val: number): DatabaseUpdateCommand
|
||||||
|
min(val: number): DatabaseUpdateCommand
|
||||||
|
max(val: number): DatabaseUpdateCommand
|
||||||
|
rename(val: string): DatabaseUpdateCommand
|
||||||
|
bit(val: number): DatabaseUpdateCommand
|
||||||
|
|
||||||
|
push(...values: any[]): DatabaseUpdateCommand
|
||||||
|
pop(): DatabaseUpdateCommand
|
||||||
|
shift(): DatabaseUpdateCommand
|
||||||
|
unshift(...values: any[]): DatabaseUpdateCommand
|
||||||
|
addToSet(val: any): DatabaseUpdateCommand
|
||||||
|
pull(val: any): DatabaseUpdateCommand
|
||||||
|
pullAll(val: any): DatabaseUpdateCommand
|
||||||
|
|
||||||
|
project: {
|
||||||
|
slice(val: number | [number, number]): DatabaseProjectionCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
aggregate: {
|
||||||
|
__safe_props__?: Set<string>
|
||||||
|
|
||||||
|
abs(val: any): DatabaseAggregateCommand
|
||||||
|
add(val: any): DatabaseAggregateCommand
|
||||||
|
addToSet(val: any): DatabaseAggregateCommand
|
||||||
|
allElementsTrue(val: any): DatabaseAggregateCommand
|
||||||
|
and(val: any): DatabaseAggregateCommand
|
||||||
|
anyElementTrue(val: any): DatabaseAggregateCommand
|
||||||
|
arrayElemAt(val: any): DatabaseAggregateCommand
|
||||||
|
arrayToObject(val: any): DatabaseAggregateCommand
|
||||||
|
avg(val: any): DatabaseAggregateCommand
|
||||||
|
ceil(val: any): DatabaseAggregateCommand
|
||||||
|
cmp(val: any): DatabaseAggregateCommand
|
||||||
|
concat(val: any): DatabaseAggregateCommand
|
||||||
|
concatArrays(val: any): DatabaseAggregateCommand
|
||||||
|
cond(val: any): DatabaseAggregateCommand
|
||||||
|
convert(val: any): DatabaseAggregateCommand
|
||||||
|
dateFromParts(val: any): DatabaseAggregateCommand
|
||||||
|
dateToParts(val: any): DatabaseAggregateCommand
|
||||||
|
dateFromString(val: any): DatabaseAggregateCommand
|
||||||
|
dateToString(val: any): DatabaseAggregateCommand
|
||||||
|
dayOfMonth(val: any): DatabaseAggregateCommand
|
||||||
|
dayOfWeek(val: any): DatabaseAggregateCommand
|
||||||
|
dayOfYear(val: any): DatabaseAggregateCommand
|
||||||
|
divide(val: any): DatabaseAggregateCommand
|
||||||
|
eq(val: any): DatabaseAggregateCommand
|
||||||
|
exp(val: any): DatabaseAggregateCommand
|
||||||
|
filter(val: any): DatabaseAggregateCommand
|
||||||
|
first(val: any): DatabaseAggregateCommand
|
||||||
|
floor(val: any): DatabaseAggregateCommand
|
||||||
|
gt(val: any): DatabaseAggregateCommand
|
||||||
|
gte(val: any): DatabaseAggregateCommand
|
||||||
|
hour(val: any): DatabaseAggregateCommand
|
||||||
|
ifNull(val: any): DatabaseAggregateCommand
|
||||||
|
in(val: any): DatabaseAggregateCommand
|
||||||
|
indexOfArray(val: any): DatabaseAggregateCommand
|
||||||
|
indexOfBytes(val: any): DatabaseAggregateCommand
|
||||||
|
indexOfCP(val: any): DatabaseAggregateCommand
|
||||||
|
isArray(val: any): DatabaseAggregateCommand
|
||||||
|
isoDayOfWeek(val: any): DatabaseAggregateCommand
|
||||||
|
isoWeek(val: any): DatabaseAggregateCommand
|
||||||
|
isoWeekYear(val: any): DatabaseAggregateCommand
|
||||||
|
last(val: any): DatabaseAggregateCommand
|
||||||
|
let(val: any): DatabaseAggregateCommand
|
||||||
|
literal(val: any): DatabaseAggregateCommand
|
||||||
|
ln(val: any): DatabaseAggregateCommand
|
||||||
|
log(val: any): DatabaseAggregateCommand
|
||||||
|
log10(val: any): DatabaseAggregateCommand
|
||||||
|
lt(val: any): DatabaseAggregateCommand
|
||||||
|
lte(val: any): DatabaseAggregateCommand
|
||||||
|
ltrim(val: any): DatabaseAggregateCommand
|
||||||
|
map(val: any): DatabaseAggregateCommand
|
||||||
|
max(val: any): DatabaseAggregateCommand
|
||||||
|
mergeObjects(val: any): DatabaseAggregateCommand
|
||||||
|
meta(val: any): DatabaseAggregateCommand
|
||||||
|
min(val: any): DatabaseAggregateCommand
|
||||||
|
millisecond(val: any): DatabaseAggregateCommand
|
||||||
|
minute(val: any): DatabaseAggregateCommand
|
||||||
|
mod(val: any): DatabaseAggregateCommand
|
||||||
|
month(val: any): DatabaseAggregateCommand
|
||||||
|
multiply(val: any): DatabaseAggregateCommand
|
||||||
|
neq(val: any): DatabaseAggregateCommand
|
||||||
|
not(val: any): DatabaseAggregateCommand
|
||||||
|
objectToArray(val: any): DatabaseAggregateCommand
|
||||||
|
or(val: any): DatabaseAggregateCommand
|
||||||
|
pow(val: any): DatabaseAggregateCommand
|
||||||
|
push(val: any): DatabaseAggregateCommand
|
||||||
|
range(val: any): DatabaseAggregateCommand
|
||||||
|
reduce(val: any): DatabaseAggregateCommand
|
||||||
|
reverseArray(val: any): DatabaseAggregateCommand
|
||||||
|
rtrim(val: any): DatabaseAggregateCommand
|
||||||
|
second(val: any): DatabaseAggregateCommand
|
||||||
|
setDifference(val: any): DatabaseAggregateCommand
|
||||||
|
setEquals(val: any): DatabaseAggregateCommand
|
||||||
|
setIntersection(val: any): DatabaseAggregateCommand
|
||||||
|
setIsSubset(val: any): DatabaseAggregateCommand
|
||||||
|
setUnion(val: any): DatabaseAggregateCommand
|
||||||
|
size(val: any): DatabaseAggregateCommand
|
||||||
|
slice(val: any): DatabaseAggregateCommand
|
||||||
|
split(val: any): DatabaseAggregateCommand
|
||||||
|
sqrt(val: any): DatabaseAggregateCommand
|
||||||
|
stdDevPop(val: any): DatabaseAggregateCommand
|
||||||
|
stdDevSamp(val: any): DatabaseAggregateCommand
|
||||||
|
strcasecmp(val: any): DatabaseAggregateCommand
|
||||||
|
strLenBytes(val: any): DatabaseAggregateCommand
|
||||||
|
strLenCP(val: any): DatabaseAggregateCommand
|
||||||
|
substr(val: any): DatabaseAggregateCommand
|
||||||
|
substrBytes(val: any): DatabaseAggregateCommand
|
||||||
|
substrCP(val: any): DatabaseAggregateCommand
|
||||||
|
subtract(val: any): DatabaseAggregateCommand
|
||||||
|
sum(val: any): DatabaseAggregateCommand
|
||||||
|
switch(val: any): DatabaseAggregateCommand
|
||||||
|
toBool(val: any): DatabaseAggregateCommand
|
||||||
|
toDate(val: any): DatabaseAggregateCommand
|
||||||
|
toDecimal(val: any): DatabaseAggregateCommand
|
||||||
|
toDouble(val: any): DatabaseAggregateCommand
|
||||||
|
toInt(val: any): DatabaseAggregateCommand
|
||||||
|
toLong(val: any): DatabaseAggregateCommand
|
||||||
|
toObjectId(val: any): DatabaseAggregateCommand
|
||||||
|
toString(val: any): DatabaseAggregateCommand
|
||||||
|
toLower(val: any): DatabaseAggregateCommand
|
||||||
|
toUpper(val: any): DatabaseAggregateCommand
|
||||||
|
trim(val: any): DatabaseAggregateCommand
|
||||||
|
trunc(val: any): DatabaseAggregateCommand
|
||||||
|
type(val: any): DatabaseAggregateCommand
|
||||||
|
week(val: any): DatabaseAggregateCommand
|
||||||
|
year(val: any): DatabaseAggregateCommand
|
||||||
|
zip(val: any): DatabaseAggregateCommand
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DatabaseAggregateCommand {}
|
||||||
|
|
||||||
|
enum LOGIC_COMMANDS_LITERAL {
|
||||||
|
AND = 'and',
|
||||||
|
OR = 'or',
|
||||||
|
NOT = 'not',
|
||||||
|
NOR = 'nor'
|
||||||
|
}
|
||||||
|
|
||||||
|
class DatabaseLogicCommand {
|
||||||
|
and(...expressions: DatabaseLogicCommand[]): DatabaseLogicCommand
|
||||||
|
or(...expressions: DatabaseLogicCommand[]): DatabaseLogicCommand
|
||||||
|
nor(...expressions: DatabaseLogicCommand[]): DatabaseLogicCommand
|
||||||
|
not(expression: DatabaseLogicCommand): DatabaseLogicCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
enum QUERY_COMMANDS_LITERAL {
|
||||||
|
// comparison
|
||||||
|
EQ = 'eq',
|
||||||
|
NEQ = 'neq',
|
||||||
|
GT = 'gt',
|
||||||
|
GTE = 'gte',
|
||||||
|
LT = 'lt',
|
||||||
|
LTE = 'lte',
|
||||||
|
IN = 'in',
|
||||||
|
NIN = 'nin',
|
||||||
|
// geo
|
||||||
|
GEO_NEAR = 'geoNear',
|
||||||
|
GEO_WITHIN = 'geoWithin',
|
||||||
|
GEO_INTERSECTS = 'geoIntersects',
|
||||||
|
// element
|
||||||
|
EXISTS = 'exists',
|
||||||
|
// evaluation
|
||||||
|
MOD = 'mod',
|
||||||
|
// array
|
||||||
|
ALL = 'all',
|
||||||
|
ELEM_MATCH = 'elemMatch',
|
||||||
|
SIZE = 'size'
|
||||||
|
}
|
||||||
|
|
||||||
|
class DatabaseQueryCommand extends DatabaseLogicCommand {
|
||||||
|
eq(val: any): DatabaseLogicCommand
|
||||||
|
neq(val: any): DatabaseLogicCommand
|
||||||
|
gt(val: any): DatabaseLogicCommand
|
||||||
|
gte(val: any): DatabaseLogicCommand
|
||||||
|
lt(val: any): DatabaseLogicCommand
|
||||||
|
lte(val: any): DatabaseLogicCommand
|
||||||
|
in(val: any[]): DatabaseLogicCommand
|
||||||
|
nin(val: any[]): DatabaseLogicCommand
|
||||||
|
|
||||||
|
exists(val: boolean): DatabaseLogicCommand
|
||||||
|
|
||||||
|
mod(divisor: number, remainder: number): DatabaseLogicCommand
|
||||||
|
|
||||||
|
all(val: any[]): DatabaseLogicCommand
|
||||||
|
elemMatch(val: any): DatabaseLogicCommand
|
||||||
|
size(val: number): DatabaseLogicCommand
|
||||||
|
|
||||||
|
geoNear(options: IGeoNearCommandOptions): DatabaseLogicCommand
|
||||||
|
geoWithin(options: IGeoWithinCommandOptions): DatabaseLogicCommand
|
||||||
|
geoIntersects(
|
||||||
|
options: IGeoIntersectsCommandOptions
|
||||||
|
): DatabaseLogicCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PROJECTION_COMMANDS_LITERAL {
|
||||||
|
SLICE = 'slice'
|
||||||
|
}
|
||||||
|
|
||||||
|
class DatabaseProjectionCommand {}
|
||||||
|
|
||||||
|
enum UPDATE_COMMANDS_LITERAL {
|
||||||
|
// field
|
||||||
|
SET = 'set',
|
||||||
|
REMOVE = 'remove',
|
||||||
|
INC = 'inc',
|
||||||
|
MUL = 'mul',
|
||||||
|
MIN = 'min',
|
||||||
|
MAX = 'max',
|
||||||
|
RENAME = 'rename',
|
||||||
|
// bitwise
|
||||||
|
BIT = 'bit',
|
||||||
|
// array
|
||||||
|
PUSH = 'push',
|
||||||
|
POP = 'pop',
|
||||||
|
SHIFT = 'shift',
|
||||||
|
UNSHIFT = 'unshift',
|
||||||
|
ADD_TO_SET = 'addToSet',
|
||||||
|
PULL = 'pull',
|
||||||
|
PULL_ALL = 'pullAll'
|
||||||
|
}
|
||||||
|
|
||||||
|
class DatabaseUpdateCommand {}
|
||||||
|
|
||||||
|
class Batch {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A contract that all API provider must adhere to
|
||||||
|
*/
|
||||||
|
class APIBaseContract<
|
||||||
|
PromiseReturn,
|
||||||
|
CallbackReturn,
|
||||||
|
Param extends IAPIParam,
|
||||||
|
Context = any
|
||||||
|
> {
|
||||||
|
getContext(param: Param): Context
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In case of callback-style invocation, this function will be called
|
||||||
|
*/
|
||||||
|
getCallbackReturn(param: Param, context: Context): CallbackReturn
|
||||||
|
|
||||||
|
getFinalParam<T extends Param>(param: Param, context: Context): T
|
||||||
|
|
||||||
|
run<T extends Param>(param: T): Promise<PromiseReturn>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoPointConstructor {
|
||||||
|
new (longitude: number, latitide: number): GeoPoint
|
||||||
|
new (geojson: IGeoJSONPoint): GeoPoint
|
||||||
|
(longitude: number, latitide: number): GeoPoint
|
||||||
|
(geojson: IGeoJSONPoint): GeoPoint
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoMultiPointConstructor {
|
||||||
|
new (points: GeoPoint[] | IGeoJSONMultiPoint): GeoMultiPoint
|
||||||
|
(points: GeoPoint[] | IGeoJSONMultiPoint): GeoMultiPoint
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoLineStringConstructor {
|
||||||
|
new (points: GeoPoint[] | IGeoJSONLineString): GeoLineString
|
||||||
|
(points: GeoPoint[] | IGeoJSONLineString): GeoLineString
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoMultiLineStringConstructor {
|
||||||
|
new (
|
||||||
|
lineStrings: GeoLineString[] | IGeoJSONMultiLineString
|
||||||
|
): GeoMultiLineString
|
||||||
|
(
|
||||||
|
lineStrings: GeoLineString[] | IGeoJSONMultiLineString
|
||||||
|
): GeoMultiLineString
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoPolygonConstructor {
|
||||||
|
new (lineStrings: GeoLineString[] | IGeoJSONPolygon): GeoPolygon
|
||||||
|
(lineStrings: GeoLineString[] | IGeoJSONPolygon): GeoPolygon
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoMultiPolygonConstructor {
|
||||||
|
new (polygons: GeoPolygon[] | IGeoJSONMultiPolygon): GeoMultiPolygon
|
||||||
|
(polygons: GeoPolygon[] | IGeoJSONMultiPolygon): GeoMultiPolygon
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeo {
|
||||||
|
Point: IGeoPointConstructor
|
||||||
|
MultiPoint: IGeoMultiPointConstructor
|
||||||
|
LineString: IGeoLineStringConstructor
|
||||||
|
MultiLineString: IGeoMultiLineStringConstructor
|
||||||
|
Polygon: IGeoPolygonConstructor
|
||||||
|
MultiPolygon: IGeoMultiPolygonConstructor
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoJSONPoint {
|
||||||
|
type: 'Point'
|
||||||
|
coordinates: [number, number]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoJSONMultiPoint {
|
||||||
|
type: 'MultiPoint'
|
||||||
|
coordinates: Array<[number, number]>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoJSONLineString {
|
||||||
|
type: 'LineString'
|
||||||
|
coordinates: Array<[number, number]>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoJSONMultiLineString {
|
||||||
|
type: 'MultiLineString'
|
||||||
|
coordinates: Array<Array<[number, number]>>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoJSONPolygon {
|
||||||
|
type: 'Polygon'
|
||||||
|
coordinates: Array<Array<[number, number]>>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoJSONMultiPolygon {
|
||||||
|
type: 'MultiPolygon'
|
||||||
|
coordinates: Array<Array<Array<[number, number]>>>
|
||||||
|
}
|
||||||
|
|
||||||
|
type IGeoJSONObject =
|
||||||
|
| IGeoJSONPoint
|
||||||
|
| IGeoJSONMultiPoint
|
||||||
|
| IGeoJSONLineString
|
||||||
|
| IGeoJSONMultiLineString
|
||||||
|
| IGeoJSONPolygon
|
||||||
|
| IGeoJSONMultiPolygon
|
||||||
|
|
||||||
|
abstract class GeoPoint {
|
||||||
|
longitude: number
|
||||||
|
latitude: number
|
||||||
|
|
||||||
|
constructor(longitude: number, latitude: number)
|
||||||
|
|
||||||
|
toJSON(): Record<string, any>
|
||||||
|
toString(): string
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class GeoMultiPoint {
|
||||||
|
points: GeoPoint[]
|
||||||
|
|
||||||
|
constructor(points: GeoPoint[])
|
||||||
|
|
||||||
|
toJSON(): IGeoJSONMultiPoint
|
||||||
|
toString(): string
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class GeoLineString {
|
||||||
|
points: GeoPoint[]
|
||||||
|
|
||||||
|
constructor(points: GeoPoint[])
|
||||||
|
|
||||||
|
toJSON(): IGeoJSONLineString
|
||||||
|
toString(): string
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class GeoMultiLineString {
|
||||||
|
lines: GeoLineString[]
|
||||||
|
|
||||||
|
constructor(lines: GeoLineString[])
|
||||||
|
|
||||||
|
toJSON(): IGeoJSONMultiLineString
|
||||||
|
toString(): string
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class GeoPolygon {
|
||||||
|
lines: GeoLineString[]
|
||||||
|
|
||||||
|
constructor(lines: GeoLineString[])
|
||||||
|
|
||||||
|
toJSON(): IGeoJSONPolygon
|
||||||
|
toString(): string
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class GeoMultiPolygon {
|
||||||
|
polygons: GeoPolygon[]
|
||||||
|
|
||||||
|
constructor(polygons: GeoPolygon[])
|
||||||
|
|
||||||
|
toJSON(): IGeoJSONMultiPolygon
|
||||||
|
toString(): string
|
||||||
|
}
|
||||||
|
|
||||||
|
type GeoInstance =
|
||||||
|
| GeoPoint
|
||||||
|
| GeoMultiPoint
|
||||||
|
| GeoLineString
|
||||||
|
| GeoMultiLineString
|
||||||
|
| GeoPolygon
|
||||||
|
| GeoMultiPolygon
|
||||||
|
|
||||||
|
interface IGeoNearCommandOptions {
|
||||||
|
geometry: GeoPoint
|
||||||
|
maxDistance?: number
|
||||||
|
minDistance?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoWithinCommandOptions {
|
||||||
|
geometry: GeoPolygon | GeoMultiPolygon
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGeoIntersectsCommandOptions {
|
||||||
|
geometry:
|
||||||
|
| GeoPoint
|
||||||
|
| GeoMultiPoint
|
||||||
|
| GeoLineString
|
||||||
|
| GeoMultiLineString
|
||||||
|
| GeoPolygon
|
||||||
|
| GeoMultiPolygon
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IServerDateOptions {
|
||||||
|
offset: number
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ServerDate {
|
||||||
|
readonly options: IServerDateOptions
|
||||||
|
constructor(options?: IServerDateOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IRegExpOptions {
|
||||||
|
regexp: string
|
||||||
|
options?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IRegExpConstructor {
|
||||||
|
new (options: IRegExpOptions): RegExp
|
||||||
|
(options: IRegExpOptions): RegExp
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class RegExp {
|
||||||
|
readonly regexp: string
|
||||||
|
readonly options: string
|
||||||
|
constructor(options: IRegExpOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DocumentId = string | number
|
||||||
|
|
||||||
|
interface IDocumentData {
|
||||||
|
_id?: DocumentId
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
type IDBAPIParam = IAPIParam
|
||||||
|
|
||||||
|
interface IAddDocumentOptions extends IDBAPIParam {
|
||||||
|
data: IDocumentData
|
||||||
|
}
|
||||||
|
|
||||||
|
type IGetDocumentOptions = IDBAPIParam
|
||||||
|
|
||||||
|
type ICountDocumentOptions = IDBAPIParam
|
||||||
|
|
||||||
|
interface IUpdateDocumentOptions extends IDBAPIParam {
|
||||||
|
data: IUpdateCondition
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IUpdateSingleDocumentOptions extends IDBAPIParam {
|
||||||
|
data: IUpdateCondition
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ISetDocumentOptions extends IDBAPIParam {
|
||||||
|
data: IUpdateCondition
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ISetSingleDocumentOptions extends IDBAPIParam {
|
||||||
|
data: IUpdateCondition
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IRemoveDocumentOptions extends IDBAPIParam {
|
||||||
|
query: IQueryCondition
|
||||||
|
}
|
||||||
|
|
||||||
|
type IRemoveSingleDocumentOptions = IDBAPIParam
|
||||||
|
|
||||||
|
interface IWatchOptions {
|
||||||
|
// server realtime data init & change event
|
||||||
|
onChange: (snapshot: ISnapshot) => void
|
||||||
|
// error while connecting / listening
|
||||||
|
onError: (error: any) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ISnapshot {
|
||||||
|
id: number
|
||||||
|
docChanges: ISingleDBEvent[]
|
||||||
|
docs: Record<string, any>
|
||||||
|
type?: SnapshotType
|
||||||
|
}
|
||||||
|
|
||||||
|
type SnapshotType = 'init'
|
||||||
|
|
||||||
|
interface ISingleDBEvent {
|
||||||
|
id: number
|
||||||
|
dataType: DataType
|
||||||
|
queueType: QueueType
|
||||||
|
docId: string
|
||||||
|
doc: Record<string, any>
|
||||||
|
updatedFields?: Record<string, any>
|
||||||
|
removedFields?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataType = 'init' | 'update' | 'replace' | 'add' | 'remove' | 'limit'
|
||||||
|
|
||||||
|
type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update'
|
||||||
|
|
||||||
|
interface IQueryCondition {
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
type IStringQueryCondition = string
|
||||||
|
|
||||||
|
interface IQueryResult extends IAPISuccessParam {
|
||||||
|
data: IDocumentData[]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IQuerySingleResult extends IAPISuccessParam {
|
||||||
|
data: IDocumentData
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IUpdateCondition {
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
type IStringUpdateCondition = string
|
||||||
|
|
||||||
|
interface IAddResult extends IAPISuccessParam {
|
||||||
|
_id: DocumentId
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IUpdateResult extends IAPISuccessParam {
|
||||||
|
stats: {
|
||||||
|
updated: number
|
||||||
|
// created: number,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ISetResult extends IAPISuccessParam {
|
||||||
|
_id: DocumentId
|
||||||
|
stats: {
|
||||||
|
updated: number
|
||||||
|
created: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IRemoveResult extends IAPISuccessParam {
|
||||||
|
stats: {
|
||||||
|
removed: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICountResult extends IAPISuccessParam {
|
||||||
|
total: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Optional<T> = { [K in keyof T]+?: T[K] }
|
||||||
|
|
||||||
|
type OQ<
|
||||||
|
T extends Optional<
|
||||||
|
Record<'complete' | 'success' | 'fail', (...args: any[]) => any>
|
||||||
|
>
|
||||||
|
> =
|
||||||
|
| (RQ<T> & Required<Pick<T, 'success'>>)
|
||||||
|
| (RQ<T> & Required<Pick<T, 'fail'>>)
|
||||||
|
| (RQ<T> & Required<Pick<T, 'complete'>>)
|
||||||
|
| (RQ<T> & Required<Pick<T, 'success' | 'fail'>>)
|
||||||
|
| (RQ<T> & Required<Pick<T, 'success' | 'complete'>>)
|
||||||
|
| (RQ<T> & Required<Pick<T, 'fail' | 'complete'>>)
|
||||||
|
| (RQ<T> & Required<Pick<T, 'fail' | 'complete' | 'success'>>)
|
||||||
|
|
||||||
|
type RQ<
|
||||||
|
T extends Optional<
|
||||||
|
Record<'complete' | 'success' | 'fail', (...args: any[]) => any>
|
||||||
|
>
|
||||||
|
> = Pick<T, Exclude<keyof T, 'complete' | 'success' | 'fail'>>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue