Skip to content

Commit

Permalink
增加app page片段,添加readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeng04 committed Aug 29, 2018
1 parent ac3f95f commit d7f2a74
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 27 deletions.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,42 @@ Git clone this repository to Sublime Packages Path.

- Zip

Download zip and unzip to Sublime Packages Path.
Download zip and unzip to Sublime Packages Path.

## Setting

- In order to improve SWAN completion efficiency, Preferences.sublime-settings(User) should be edited and added config below:

"auto_complete_triggers":
[
{
"characters": "abcdefghijklmnopqrstuvwxyz< :.",
"selector": "text.wxml"
}
],


## Feature

- .swan file syntax highlighting

- Baidu smart app components auto-completion

- Baidu smart app apis auto-completion and suggestion

## Usage

- Swan
1. choose `view` ====> `<view></view>`
2. choose `view:id` ===> `<view id=""></view>`
3. `view.demo + tab` ===> `<view class="demo"></view>`
4. `view#demo + tab` ===> `<view id="demo"></view>`

- JavaScript(api and snippet)
1. choose `swan.login api` ===> `swan.login();`
2. choose `swan.login snippet` ===>

swan.login({
success: function (res) {}
});
**Note:** Snippets only include the necesssary keys
2 changes: 1 addition & 1 deletion SWAN_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def get_attribute_completions(self, view, locations, prefix, ch):

# 不同属性值类型,输出不一样的补全方案
if type_value == 'mustache':
comp_value = name + '="{{$1}}"'
comp_value = name + '="$1"'
elif type_value == 'prop':
comp_value = name
elif type_value == 'boolean':
Expand Down
31 changes: 25 additions & 6 deletions SWAN_completions.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
],
[
"view:if\tTag",
"view s-if=\"{{$1}}\">$0</view>"
"view s-if=\"$1\">$0</view>"
],
[
"view:elif\tTag",
"view s-elif=\"{{$1}}\">$0</view>"
"view s-elif=\"$1\">$0</view>"
],
[
"view:else\tTag",
"view s-else>$0</view>"
],
[
"view:for\tTag",
"view s-for=\"{{$1}}\">$0</view>"
"view s-for=\"$1\">$0</view>"
],
[
"view:for:for\tTag",
"view s-for=\"{{$1}}\" s-for-index=\"${2:idx}\" s-for-item=\"${3:item}\">$4</view>"
"view s-for=\"$1\" s-for-index=\"${2:idx}\" s-for-item=\"${3:item}\">$4</view>"
],
[
"view:for:key\tTag",
"view s-for=\"{{$1}}\" s-for-index=\"${2:idx}\" s-for-item=\"${3:item}\" s-key=\"${4:*this}\">$5</view>"
"view s-for=\"$1\" s-for-index=\"${2:idx}\" s-for-item=\"${3:item}\" s-key=\"${4:*this}\">$5</view>"
],
[
"text:class\tTag",
Expand Down Expand Up @@ -1971,6 +1971,25 @@
}
],
"docLink": "https://smartprogram.baidu.com/docs/develop/component/open/#web-view"
}
},
"template": {
"attrs": [{
"name": "name",
"type": "string",
"def": "",
"desc": ""
}, {
"name": "is",
"type": "string",
"def": "",
"desc": ""
}, {
"name": "data",
"type": "any",
"def": "",
"desc": ""
}],
"docLink": "https://smartprogram.baidu.com/docs/develop/framework/view_template/"
},
}
}
19 changes: 0 additions & 19 deletions swan/SWAN.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,6 @@ contexts:
- match: '-->'
scope: punctuation.definition.comment.end.swan
pop: true
# 语法:脚本
- match: (<)((?i:wxs))\b
captures:
1: punctuation.definition.tag.begin.swan
2: entity.name.tag.swan
push:
- meta_scope: meta.tag.swan
- match: '/>'
scope: punctuation.definition.tag.end.swan
pop: true
- match: '>'
push: Packages/JavaScript/JavaScript.sublime-syntax
with_prototype:
- match: (?=</wxs>)
pop: true
- match: (?=</wxs>)
scope: punctuation.definition.tag.end.swan
pop: true
- include: tag-attributes
# 语法:标签
- match: (</?)([A-Za-z0-9:_-]+)
captures:
Expand Down
34 changes: 34 additions & 0 deletions swanSnippet/app.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<snippet>
<content><![CDATA[
App({
/**
* 生命周期函数--监听小程序初始化
*/
globalData: {$1},
/**
* 生命周期函数--监听小程序初始化
* 当小程序初始化完成时,会触发 onLaunch(全局只触发一次)
*/
onLaunch: function (options) {
$2
},
/**
* 生命周期函数--监听小程序显示
* 当小程序启动,或从后台进入前台显示,会触发 onShow
*/
onShow: function (options) {
$3
},
/**
* 生命周期函数--监听小程序隐藏
* 当小程序从前台进入后台,会触发 onHide
*/
onHide: function (options) {
$4
}
});
]]></content>
<tabTrigger>App</tabTrigger>
<description>Baidu smartApp(注册程序)</description>
<scope>source.js</scope>
</snippet>
86 changes: 86 additions & 0 deletions swanSnippet/page.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<snippet>
<content><![CDATA[
Page({
/**
* 页面的初始数据
*/
data: {$1},
/**
* 监听页面加载
*/
onLoad: function (options) {
$2
},
/**
* 监听页面初次渲染完成
*/
onReady: function () {
$3
},
/**
* 监听页面显示
*/
onShow: function () {
$4
},
/**
* 监听页面隐藏
*/
onHide: function () {
$5
},
/**
* 监听页面卸载
*/
onUnload: function () {
$6
},
/**
* 监听用户下拉动作
*/
onPullDownRefresh: function () {
$7
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
$8
},
/**
* 用户点击右上角转发
*/
onShareAppMessage: function () {
$9
},
/**
* 页面滚动触发事件的处理函数
*/
onPageScroll: function () {
$10
},
/**
* 当前是 tab 页时,点击 tab 时触发
*/
onTabItemTap: function(item) {
$11
},
customData: {$12}
});
]]></content>
<tabTrigger>Page</tabTrigger>
<description>Baidu smartApp(注册页面)</description>
<scope>source.js</scope>
</snippet>

0 comments on commit d7f2a74

Please sign in to comment.