├── .gitattributes ├── CHANGELOG.md ├── LICENSE ├── README.md ├── assets └── image │ └── logo.png ├── package.json └── snippets ├── wxjs.json ├── wxjson.json └── wxxml.json /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=javascript 2 | 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 0.4.10 2018.10 2 | * 更新到官方最新API 3 | 4 | ### 0.4.9 2018.09 5 | * 更新到官方最新API 6 | 7 | ### 0.4.8 2018.09 8 | * 更新到官方最新API 9 | 10 | ### 0.4.5 2018.08 11 | * FixBug: App,Page Component对象的生命周期函数不能用ES6写法 12 | 13 | ### 0.4.1 2018.08 14 | * 增加了FileSystemManager API 15 | 16 | ### 0.3.9 2018.08 17 | * 模板格式更好了 18 | * 修复了几个索引的Bug 19 | 20 | 21 | ### 0.3.0 2018.08 22 | * 添加了json文件的模板 23 | 24 | 25 | ### 0.2.0 2018.08 26 | * 添加了主要组件的模板 27 | 28 | 29 | ### 0.1.0 2018.08 30 | * 添加了主要API的代码模板 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 ChandZhang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wechat-snippet-vscode 2 | 3 | A wechat snippet plugin for vscode. 4 | 5 | 由微信官方文档照搬下来的代码片段。 6 | 方便自己使用,同时也给需要者提供帮助。 7 | 8 | 官方文档: https://developers.weixin.qq.com/miniprogram/dev/api/ 9 | 10 | ## 使用方法 11 | * JSON 片段:在{}中输入 page,pages,window,tabbar等属性关键字即可提示代码片段模板。 12 | * JavaScript 片段:输入 wx-page,wx-app,wx-request等wx-开头的关键字即可提示代码片段模板。 13 | * WXML 片段:直接输入组件名称,即可提示代码片段模板。如,输入 view,可自动生成 View 标签及其属性。 14 | 15 | ## 演示动画 16 | 17 | json片段:在{}中输入 page,pages,window,tabbar等属性关键字即可提示代码片段模板. 18 | ![JSON](https://www.iiowl.cn/assets/1.gif) 19 | 20 | js片段:输入 wx-page,wx-app,wx-request等wx-开头的关键字即可提示代码片段模板. 21 | ![JS](https://www.iiowl.cn/assets/2.gif) 22 | 23 | wxml片段:直接输入组件名称,即可提示代码片段模板. 如,输入 view,可自动生成 view标签及其属性 24 | ![WXML](https://www.iiowl.cn/assets/3.gif) 25 | 26 | ## 联系作者 27 | 如果有问题,请联系 zhangcd@iiowl.com 28 | -------------------------------------------------------------------------------- /assets/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChandZhang/wechat-snippet-vscode/48c27eaaec79366c7877f44db55ef8cd511011bb/assets/image/logo.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wechat-snippet", 3 | "description": "微信小程序代码辅助,代码片段自动完成", 4 | "version": "0.4.10", 5 | "publisher": "ChandZhang", 6 | "engines": { 7 | "vscode": "^1.20.0" 8 | }, 9 | "categories": [ 10 | "Snippets" 11 | ], 12 | "keywords": [ 13 | "miniapp", 14 | "小程序", 15 | "wx", 16 | "wechat", 17 | "wxapi" 18 | ], 19 | "contributes": { 20 | "languages": [{ 21 | "id": "wxml", 22 | "extensions": [ 23 | ".wxml" 24 | ] 25 | }, 26 | { 27 | "id": "json", 28 | "extensions": [ 29 | ".json" 30 | ] 31 | }, 32 | { 33 | "id": "wxs", 34 | "extensions": [ 35 | ".wxs" 36 | ] 37 | } 38 | ], 39 | "snippets": [{ 40 | "language": "javascript", 41 | "path": "./snippets/wxjs.json" 42 | }, 43 | { 44 | "language": "typescript", 45 | "path": "./snippets/wxjs.json" 46 | }, 47 | { 48 | "language": "wxs", 49 | "path": "./snippets/wxjs.json" 50 | }, 51 | { 52 | "language": "html", 53 | "path": "./snippets/wxxml.json" 54 | }, 55 | { 56 | "language": "wxml", 57 | "path": "./snippets/wxxml.json" 58 | }, 59 | { 60 | "language": "json", 61 | "path": "./snippets/wxjson.json" 62 | } 63 | ] 64 | }, 65 | "repository": { 66 | "type": "git", 67 | "url": "https://github.com/Chand-zhang/wechat-snippet-vscode" 68 | }, 69 | "bugs": { 70 | "email": "zhangcd@iiwol.com" 71 | }, 72 | "icon": "assets/image/logo.png", 73 | "license": "MIT License" 74 | } -------------------------------------------------------------------------------- /snippets/wxjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "wxapp": { 3 | "prefix": "wx-app", 4 | "body": [ 5 | "//app.js", 6 | "App({", 7 | "\t//onLaunch,onShow: options(path,query,scene,shareTicket,referrerInfo(appId,extraData))", 8 | "\tonLaunch: function(options){", 9 | "\t\t${1}", 10 | "\t},", 11 | "\tonShow: function(options){", 12 | "\r\n\t},", 13 | "\tonHide: function(){", 14 | "\r\n\t},", 15 | "\tonError: function(msg){", 16 | "\r\n\t},", 17 | "\t//options(path,query,isEntryPage)", 18 | "\tonPageNotFound: function(options){", 19 | "\r\n\t},", 20 | "\tglobalData: {", 21 | "\t\t${2}", 22 | "\t}", 23 | "});" 24 | ], 25 | "description": "App对象及其生命周期函数和回调函数" 26 | }, 27 | "wxpage": { 28 | "prefix": "wx-page", 29 | "body": [ 30 | "//Page Object", 31 | "Page({", 32 | "\tdata: {", 33 | "\t\t${1}", 34 | "\t},", 35 | "\t//options(Object)", 36 | "\tonLoad: function(options){", 37 | "\t\t${2}", 38 | "\t},", 39 | "\tonReady: function(){", 40 | "\t\t${3}", 41 | "\t},", 42 | "\tonShow: function(){", 43 | "\t\t${4}", 44 | "\t},", 45 | "\tonHide: function(){", 46 | "\r\n\t},", 47 | "\tonUnload: function(){", 48 | "\r\n\t},", 49 | "\tonPullDownRefresh: function(){", 50 | "\r\n\t},", 51 | "\tonReachBottom: function(){", 52 | "\r\n\t},", 53 | "\tonShareAppMessage: function(){", 54 | "\r\n\t},", 55 | "\tonPageScroll: function(){", 56 | "\r\n\t},", 57 | "\t//item(index,pagePath,text)", 58 | "\tonTabItemTap:function(item){", 59 | "\r\n\t}", 60 | "});" 61 | ], 62 | "description": "Page对象及其生命周期函数和回调函数" 63 | }, 64 | "wxComponent": { 65 | "prefix": "wx-Component", 66 | "body": [ 67 | "//Component Object", 68 | "Component({", 69 | "\tproperties: {", 70 | "\t\t${1:myProperty}:{", 71 | "\t\t\ttype:${2:String},", 72 | "\t\t\tvalue:${3:''},", 73 | "\t\t\tobserver: function(){${4}}", 74 | "\t\t},", 75 | "\r\n\t},", 76 | "\tdata: {", 77 | "\r\n\t},", 78 | "\tmethods: {", 79 | "\t\t${5}", 80 | "\t},", 81 | "\tcreated: function(){", 82 | "\r\n\t},", 83 | "\tattached: function(){", 84 | "\r\n\t},", 85 | "\tready: function(){", 86 | "\r\n\t},", 87 | "\tmoved: function(){", 88 | "\r\n\t},", 89 | "\tdetached: function(){", 90 | "\r\n\t},", 91 | "});" 92 | ], 93 | "description": "Component对象及其生命周期函数和回调函数" 94 | }, 95 | "getCurrentPages": { 96 | "prefix": "getCurrentPages", 97 | "body": [ 98 | "${1:var curPages = } getCurrentPages();", 99 | "${2}" 100 | ], 101 | "description": "获取当前页面栈" 102 | }, 103 | "getApp": { 104 | "prefix": "getApp", 105 | "body": [ 106 | "${1:var appInst = } getApp();", 107 | "${2}" 108 | ], 109 | "description": "获取小程序实例" 110 | }, 111 | "wx.request": { 112 | "prefix": "wx-request", 113 | "body": [ 114 | "${1:var reqTask = }wx.request({", 115 | "\turl: '${2}',", 116 | "\tdata: {${3}},", 117 | "\theader: {${4:'content-type':'application/json'}},", 118 | "\tmethod: '${5:GET}',", 119 | "\tdataType: '${6:json}',", 120 | "\tresponseType: '${7:text}',", 121 | "\tsuccess: (result)=>{", 122 | "\t\t${8}", 123 | "\t},", 124 | "\tfail: ()=>{},", 125 | "\tcomplete: ()=>{}", 126 | "});" 127 | ], 128 | "description": "发起网络请求" 129 | }, 130 | "reqTask.abort": { 131 | "prefix": "reqTask-abort", 132 | "body": [ 133 | "reqTask.abort();" 134 | ], 135 | "description": "中断请求任务。" 136 | }, 137 | 138 | "wx.uploadFile": { 139 | "prefix": "wx-uploadFile", 140 | "body": [ 141 | "${1:var upTask = }wx.uploadFile({", 142 | "\turl: '${2}',", 143 | "\tfilePath: ${3},", 144 | "\tname: ${4},", 145 | "\tformData: {${5}},", 146 | "\tsuccess: (result)=>{", 147 | "\t\t${6}", 148 | "\t},", 149 | "\tfail: ()=>{},", 150 | "\tcomplete: ()=>{}", 151 | "});" 152 | ], 153 | "description": "将本地资源上传到开发者服务器,客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data。" 154 | }, 155 | "upTask.onProgressUpdate": { 156 | "prefix": "upTask-onProgressUpdate", 157 | "body": [ 158 | "upTask.onProgressUpdate((result)=>{", 159 | "\t\t${1}", 160 | "\t});" 161 | ], 162 | "description": "监听上传进度变化事件。" 163 | }, 164 | "upTask.abort": { 165 | "prefix": "upTask-abort", 166 | "body": [ 167 | "upTask.abort();" 168 | ], 169 | "description": "中断上传任务。" 170 | }, 171 | "wx.downloadFile": { 172 | "prefix": "wx-downloadFile", 173 | "body": [ 174 | "${1:var downTask = }wx.downloadFile({", 175 | "\turl: '${2}',", 176 | "\tsuccess: (result)=>{", 177 | "\t\t${3}", 178 | "\t},", 179 | "\tfail: ()=>{},", 180 | "\tcomplete: ()=>{}", 181 | "});" 182 | ], 183 | "description": "下载文件资源到本地,客户端直接发起一个HTTP GET请求,返回文件的本地临时路径。" 184 | }, 185 | "downTask.onProgressUpdate": { 186 | "prefix": "downTask-onProgressUpdate", 187 | "body": [ 188 | "downTask.onProgressUpdate((result)=>{", 189 | "\t\t${1}", 190 | "\t});" 191 | ], 192 | "description": "监听下载进度变化事件。" 193 | }, 194 | "downTask.abort": { 195 | "prefix": "downTask-abort", 196 | "body": [ 197 | "downTask.abort();" 198 | ], 199 | "description": "中断下载任务。" 200 | }, 201 | "wx.connectSocket": { 202 | "prefix": "wx-connectSocket", 203 | "body": [ 204 | "${1:var sockTask = }wx.connectSocket({", 205 | "\turl: '${2}',", 206 | "\theader: {${3:'content-type':'application/json'}},", 207 | "\tmethod: '${4:GET}',", 208 | "\tprotocols: [${5}],", 209 | "\tsuccess: ()=>{", 210 | "\t\t${6}", 211 | "\t},", 212 | "\tfail: ()=>{},", 213 | "\tcomplete: ()=>{}", 214 | "});" 215 | ], 216 | "description": "创建一个WebSocket连接。" 217 | }, 218 | "wx.onSocketOpen": { 219 | "prefix": "wx-onSocketOpen", 220 | "body": ["wx.onSocketOpen(${1:result} => {", 221 | "\t${2}", 222 | "});" 223 | ], 224 | "description": "监听WebSocket连接打开事件。" 225 | }, 226 | "wx.onSocketError": { 227 | "prefix": "wx-onSocketError", 228 | "body": ["wx.onSocketError(${1:result} => {", 229 | "\t${2}", 230 | "});" 231 | ], 232 | "description": "监听WebSocket错误。" 233 | }, 234 | "wx.sendSocketMessage": { 235 | "prefix": "wx-sendSocketMessage", 236 | "body": [ 237 | "wx.sendSocketMessage({", 238 | "\tdata: ${1},", 239 | "\tsuccess: (result)=>{", 240 | "\t\t${2}", 241 | "\t},", 242 | "\tfail: ()=>{},", 243 | "\tcomplete: ()=>{}", 244 | "});" 245 | ], 246 | "description": "通过WebSocket连接发送数据,需要先wx.connectSocket,并在wx.onSocketOpen回调之后才能发送。" 247 | }, 248 | "wx.onSocketMessage": { 249 | "prefix": "wx-onSocketMessage", 250 | "body": ["wx.onSocketMessage((${1:result})=>{${2}});"], 251 | "description": "监听WebSocket接受到服务器的消息事件。" 252 | }, 253 | "wx.closeSocket": { 254 | "prefix": "wx-closeSocket", 255 | "body": [ 256 | "wx.closeSocket({", 257 | "\tcode: ${1:1000},", 258 | "\treason: '${2}',", 259 | "\tsuccess: (result)=>{", 260 | "\t\t${3}", 261 | "\t},", 262 | "\tfail: ()=>{},", 263 | "\tcomplete: ()=>{}", 264 | "});" 265 | ], 266 | "description": "关闭WebSocket连接。" 267 | }, 268 | "wx.onSocketClose": { 269 | "prefix": "wx-onSocketClose", 270 | "body": ["wx.onSocketClose((${1:result})=>{", 271 | "\t${2}", 272 | "});" 273 | ], 274 | "description": "监听WebSocket关闭。" 275 | }, 276 | "sockTask.send": { 277 | "prefix": "sockTask-send", 278 | "body": [ 279 | "sockTask.send({", 280 | "\tdata: ${1},", 281 | "\tsuccess: (result)=>{", 282 | "\t\t${2}", 283 | "\t},", 284 | "\tfail: ()=>{},", 285 | "\tcomplete: ()=>{}", 286 | "});" 287 | ], 288 | "description": "通过WebSocket连接发送数据。" 289 | }, 290 | "sockTask.close": { 291 | "prefix": "sockTask-close", 292 | "body": [ 293 | "sockTask.close({", 294 | "\tcode: ${1},", 295 | "\treason: ${2},", 296 | "\tsuccess: (result)=>{", 297 | "\t\t${3}", 298 | "\t},", 299 | "\tfail: ()=>{},", 300 | "\tcomplete: ()=>{}", 301 | "});" 302 | ], 303 | "description": "关闭WebSocket连接。" 304 | }, 305 | "sockTask.onOpen": { 306 | "prefix": "sockTask-onOpen", 307 | "body": [ 308 | "sockTask.onOpen(${1:result} => {", 309 | "\t${2}", 310 | "});" 311 | ], 312 | "description": "监听WebSocket连接打开事件。" 313 | }, 314 | "sockTask.onClose": { 315 | "prefix": "sockTask-onClose", 316 | "body": [ 317 | "sockTask.onClose(${1:result} => {", 318 | "\t${2}", 319 | "});" 320 | ], 321 | "description": "监听 WebSocket 连接关闭事件。" 322 | }, 323 | "sockTask.onError": { 324 | "prefix": "sockTask-onError", 325 | "body": [ 326 | "sockTask.onError(${1:result} => {", 327 | "\t${2}", 328 | "});" 329 | ], 330 | "description": "监听 WebSocket 错误。" 331 | }, 332 | "sockTask.onMessage": { 333 | "prefix": "sockTask-onMessage", 334 | "body": [ 335 | "sockTask.onMessage(${1:result} => {", 336 | "\t${2}", 337 | "});" 338 | ], 339 | "description": "监听WebSocket接受到服务器的消息事件。" 340 | }, 341 | "wx.chooseImage": { 342 | "prefix": "wx-chooseImage", 343 | "body": [ 344 | "wx.chooseImage({", 345 | "\tcount: ${1:9},", 346 | "\tsizeType: ${2:['original','compressed']},", 347 | "\tsourceType: ${3:['album','camera']},", 348 | "\tsuccess: (result)=>{", 349 | "\t\t${4}", 350 | "\t},", 351 | "\tfail: ()=>{},", 352 | "\tcomplete: ()=>{}", 353 | "});" 354 | ], 355 | "description": "从本地相册选择图片或使用相机拍照。" 356 | }, 357 | "wx.previewImage": { 358 | "prefix": "wx-previewImage", 359 | "body": [ 360 | "wx.previewImage({", 361 | "\tcurrent: '${1}',", 362 | "\turls: [${2}],", 363 | "\tsuccess: (result)=>{", 364 | "\t\t${3}", 365 | "\t},", 366 | "\tfail: ()=>{},", 367 | "\tcomplete: ()=>{}", 368 | "});" 369 | ], 370 | "description": "预览图片。" 371 | }, 372 | "wx.getImageInfo": { 373 | "prefix": "wx-getImageInfo", 374 | "body": [ 375 | "wx.getImageInfo({", 376 | "\tsrc: ${1},", 377 | "\tsuccess: (result)=>{", 378 | "\t\t${2}", 379 | "\t},", 380 | "\tfail: ()=>{},", 381 | "\tcomplete: ()=>{}", 382 | "});" 383 | ], 384 | "description": "获取图片信息,倘若为网络图片,需先配置download域名才能生效。" 385 | }, 386 | "wx.saveImageToPhotosAlbum": { 387 | "prefix": "wx-saveImageToPhotosAlbum", 388 | "body": [ 389 | "wx.saveImageToPhotosAlbum({", 390 | "\tfilePath: ${1},", 391 | "\tsuccess: (result)=>{", 392 | "\t\t${2}", 393 | "\t},", 394 | "\tfail: ()=>{},", 395 | "\tcomplete: ()=>{}", 396 | "});" 397 | ], 398 | "description": "保存图片到系统相册。需要用户授权 scope.writePhotosAlbum" 399 | }, 400 | "wx.startRecord": { 401 | "prefix": "wx-startRecord", 402 | "body": ["wx.startRecord({", 403 | "\tsuccess: (result)=>{", 404 | "\t\t${1}", 405 | "\t},", 406 | "\tfail: ()=>{},", 407 | "\tcomplete: ()=>{}", 408 | "});" 409 | ], 410 | "description": "开始录音。需要用户授权 scope.record。1.6.0 起不再维护" 411 | }, 412 | "wx.stopRecord": { 413 | "prefix": "wx-stopRecord", 414 | "body": ["wx.stopRecord();"], 415 | "description": "停止录音。1.6.0 起不再维护" 416 | }, 417 | "wx.getRecorderManager": { 418 | "prefix": "wx-getRecorderManager", 419 | "body": ["${1:var recordManager = }wx.getRecorderManager();"], 420 | "description": "获取全局唯一的录音管理器recorderManager。" 421 | }, 422 | "recordManager.start": { 423 | "prefix": "recordManager-start", 424 | "body": [ 425 | "recordManager.start({", 426 | "\tduration: ${1},", 427 | "\tsampleRate: ${2:44100},", 428 | "\tnumberOfChannels: ${3:2},", 429 | "\tformat: ${4:'aac'}", 430 | "});" 431 | ], 432 | "description": "开始录音" 433 | }, 434 | "recordManager.pause": { 435 | "prefix": "recordManager-pause", 436 | "body": ["recordManager.pause();"], 437 | "description": "暂停录音" 438 | }, 439 | "recordManager.resume": { 440 | "prefix": "recordManager-resume", 441 | "body": ["recordManager.resume();"], 442 | "description": "恢复录音" 443 | }, 444 | "recordManager.stop": { 445 | "prefix": "recordManager-stop", 446 | "body": ["recordManager.stop();"], 447 | "description": "停止录音" 448 | }, 449 | "recordManager.onStart": { 450 | "prefix": "recordManager-onStart", 451 | "body": ["recordManager.onStart((${1})=>{", 452 | "\t${2}", 453 | "});" 454 | ], 455 | "description": "录音开始事件" 456 | }, 457 | "recordManager.onPause": { 458 | "prefix": "recordManager-onPause", 459 | "body": ["recordManager.onPause((${1})=>{", 460 | "\t${2}", 461 | "});" 462 | ], 463 | "description": "录音暂停事件" 464 | }, 465 | "recordManager.onStop": { 466 | "prefix": "recordManager-onStop", 467 | "body": ["recordManager.onStop((${1:result})=>{", 468 | "\t${2}", 469 | "});" 470 | ], 471 | "description": "录音停止事件,会回调文件地址" 472 | }, 473 | "recordManager.onFrameRecorded": { 474 | "prefix": "recordManager-onFrameRecorded", 475 | "body": ["recordManager.onFrameRecorded((${1:result})=>{", 476 | "\t${2}", 477 | "});" 478 | ], 479 | "description": "已录制完指定帧大小的文件,会回调录音分片结果数据" 480 | }, 481 | "recordManager.onError": { 482 | "prefix": "recordManager-onError", 483 | "body": ["recordManager.onError((${1:errMsg})=>{", 484 | "\t${2}", 485 | "});" 486 | ], 487 | "description": "录音错误事件, 会回调错误信息" 488 | }, 489 | "wx.playVoice": { 490 | "prefix": "wx-playVoice", 491 | "body": ["wx.playVoice({", 492 | "\tfilePath: '${1}',", 493 | "\tduration: ${2:60},", 494 | "\tsuccess: (result)=>{", 495 | "\t\t${3}", 496 | "\t},", 497 | "\tfail: ()=>{},", 498 | "\tcomplete: ()=>{}", 499 | "});" 500 | ], 501 | "description": "开始播放语音,同时只允许一个语音文件正在播放,如果前一个语音文件还没播放完,将中断前一个语音播放。1.6.0 起不再维护" 502 | }, 503 | "wx.pauseVoice": { 504 | "prefix": "wx-pauseVoice", 505 | "body": ["wx.pauseVoice();"], 506 | "description": "暂停正在播放的语音。1.6.0 起不再维护" 507 | }, 508 | "wx.stopVoice": { 509 | "prefix": "wx-stopVoice", 510 | "body": ["wx.stopVoice();"], 511 | "description": "结束播放语音。1.6.0 起不再维护" 512 | }, 513 | "wx.getBackgroundAudioPlayerState": { 514 | "prefix": "wx-getBackgroundAudioPlayerState", 515 | "body": ["wx.getBackgroundAudioPlayerState({", 516 | "\tsuccess: (result)=>{", 517 | "\t\t${1}", 518 | "\t},", 519 | "\tfail: ()=>{},", 520 | "\tcomplete: ()=>{}", 521 | "});" 522 | ], 523 | "description": "获取后台音乐播放状态。1.2.0 起不再维护" 524 | }, 525 | "wx.playBackgroundAudio": { 526 | "prefix": "wx-playBackgroundAudio", 527 | "body": ["wx.playBackgroundAudio({", 528 | "\tdataUrl: '${1}',", 529 | "\ttitle: '${2}',", 530 | "\tcoverImgUrl: '${3}',", 531 | "\tsuccess: (result)=>{", 532 | "\t\t${4}", 533 | "\t},", 534 | "\tfail: ()=>{},", 535 | "\tcomplete: ()=>{}", 536 | "});" 537 | ], 538 | "description": "使用后台播放器播放音乐,对于微信客户端来说,只能同时有一个后台音乐在播放。1.2.0 起不再维护" 539 | }, 540 | "wx.pauseBackgroundAudio": { 541 | "prefix": "wx-pauseBackgroundAudio", 542 | "body": ["wx.playBackgroundAudio();"], 543 | "description": "暂停播放音乐。1.2.0 起不再维护" 544 | }, 545 | "wx.seekBackgroundAudio": { 546 | "prefix": "wx-seekBackgroundAudio", 547 | "body": ["wx.seekBackgroundAudio({", 548 | "\tposition: '${1}',", 549 | "\tsuccess: (result)=>{", 550 | "\t\t${2}", 551 | "\t},", 552 | "\tfail: ()=>{},", 553 | "\tcomplete: ()=>{}", 554 | "});" 555 | ], 556 | "description": "控制音乐播放进度(秒)。1.2.0 起不再维护" 557 | }, 558 | "wx.stopBackgroundAudio": { 559 | "prefix": "wx-stopBackgroundAudio", 560 | "body": ["wx.stopBackgroundAudio();"], 561 | "description": "停止播放音乐。1.2.0 起不再维护" 562 | }, 563 | "wx.onBackgroundAudioPlay": { 564 | "prefix": "wx-onBackgroundAudioPlay", 565 | "body": ["wx.onBackgroundAudioPlay((${1:result})=>{${2}});"], 566 | "description": "监听音乐播放。1.2.0 起不再维护" 567 | }, 568 | "wx.onBackgroundAudioPause": { 569 | "prefix": "wx-onBackgroundAudioPause", 570 | "body": ["wx.onBackgroundAudioPause((${1:result})=>{${2}});"], 571 | "description": "监听音乐暂停。1.2.0 起不再维护" 572 | }, 573 | "wx.onBackgroundAudioStop": { 574 | "prefix": "wx-onBackgroundAudioStop", 575 | "body": ["wx.onBackgroundAudioStop((${1:result})=>{${2}});"], 576 | "description": "监听音乐停止。1.2.0 起不再维护" 577 | }, 578 | "wx.getBackgroundAudioManager": { 579 | "prefix": "wx-getBackgroundAudioManager", 580 | "body": [ 581 | "// properties(Read only)(duration,currentTime,paused,buffered)", 582 | "// properties(src(m4a, aac, mp3, wav),startTime,title,epname,singer,coverImgUrl,webUrl,protocol)", 583 | "${1:var backAudioManager = }wx.getBackgroundAudioManager();" 584 | ], 585 | "description": "获取全局唯一的背景音频管理器 backgroundAudioManager。" 586 | }, 587 | "backAudioManager.src": { 588 | "prefix": "backAudioManager-src", 589 | "body": ["backAudioManager.src = ${1};"], 590 | "description": "音频的数据源,默认为空字符串,当设置了新的 src 时,会自动开始播放 ,目前支持的格式有 m4a, aac, mp3, wav。" 591 | }, 592 | "backAudioManager.play": { 593 | "prefix": "backAudioManager-play", 594 | "body": ["backAudioManager.play();"], 595 | "description": "播放" 596 | }, 597 | "backAudioManager.pause": { 598 | "prefix": "backAudioManager-pause", 599 | "body": ["backAudioManager.pause();"], 600 | "description": "暂停" 601 | }, 602 | "backAudioManager.stop": { 603 | "prefix": "backAudioManager-stop", 604 | "body": ["backAudioManager.stop();"], 605 | "description": "停止" 606 | }, 607 | "backAudioManager.seek": { 608 | "prefix": "backAudioManager-seek", 609 | "body": ["backAudioManager.seek(${1});"], 610 | "description": "跳转到指定位置,单位 s。精确到小数点后 3 位,即支持 ms 级别精确度。" 611 | }, 612 | "backAudioManager.onCanplay": { 613 | "prefix": "backAudioManager-onCanplay", 614 | "body": ["backAudioManager.onCanplay(${1:()=>{", 615 | "\t\t${2}", 616 | "\t}});" 617 | ], 618 | "description": "背景音频进入可以播放状态,但不保证后面可以流畅播放" 619 | }, 620 | "backAudioManager.onPlay": { 621 | "prefix": "backAudioManager-onPlay", 622 | "body": ["backAudioManager.onPlay(()=>{", 623 | "\t${1}", 624 | "});" 625 | ], 626 | "description": "背景音频播放事件" 627 | }, 628 | "backAudioManager.onPause": { 629 | "prefix": "backAudioManager-onPause", 630 | "body": ["backAudioManager.onPause(()=>{", 631 | "\t${1}", 632 | "});" 633 | ], 634 | "description": "背景音频暂停事件" 635 | }, 636 | "backAudioManager.onStop": { 637 | "prefix": "backAudioManager-onStop", 638 | "body": ["backAudioManager.onStop(()=>{", 639 | "\t${1}", 640 | "});" 641 | ], 642 | "description": "背景音频停止事件" 643 | }, 644 | "backAudioManager.onEnded": { 645 | "prefix": "backAudioManager-onEnded", 646 | "body": ["backAudioManager.onEnded(()=>{", 647 | "\t${1}", 648 | "});" 649 | ], 650 | "description": "背景音频自然播放结束事件" 651 | }, 652 | "backAudioManager.onTimeUpdate": { 653 | "prefix": "backAudioManager-onTimeUpdate", 654 | "body": ["backAudioManager.onTimeUpdate((${1})=>{", 655 | "\t${2}", 656 | "});" 657 | ], 658 | "description": "背景音频播放进度更新事件" 659 | }, 660 | "backAudioManager.onPrev": { 661 | "prefix": "backAudioManager-onPrev", 662 | "body": ["backAudioManager.onPrev((${1})=>{", 663 | "\t${2}", 664 | "});" 665 | ], 666 | "description": "用户在系统音乐播放面板点击上一曲事件(iOS only)" 667 | }, 668 | "backAudioManager.onNext": { 669 | "prefix": "backAudioManager-onNext", 670 | "body": ["backAudioManager.onNext((${1})=>{", 671 | "\t${2}", 672 | "});" 673 | ], 674 | "description": "用户在系统音乐播放面板点击下一曲事件(iOS only)" 675 | }, 676 | "backAudioManager.onError": { 677 | "prefix": "backAudioManager-onError", 678 | "body": ["backAudioManager.onError((${1:errMsg})=>{", 679 | "\t${2}", 680 | "});" 681 | ], 682 | "description": "背景音频播放错误事件" 683 | }, 684 | "backAudioManager.onWaiting": { 685 | "prefix": "backAudioManager-onWaiting", 686 | "body": ["backAudioManager.onWaiting((${1})=>{", 687 | "\t${2}", 688 | "});" 689 | ], 690 | "description": "音频加载中事件,当音频因为数据不足,需要停下来加载时会触发" 691 | }, 692 | "wx.createAudioContext": { 693 | "prefix": "wx-createAudioContext", 694 | "body": [ 695 | "${1:var audioContext = }wx.createAudioContext(${2}, this);" 696 | ], 697 | "description": "创建并返回audio上下文audioContext对象。在自定义组件下,第二个参数传入组件实例this,以操作组件内