Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
支持shift显示详情,enter复制单条记录
Browse files Browse the repository at this point in the history
  • Loading branch information
roylez committed Aug 24, 2017
1 parent 25b1afa commit fd21a08
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ alfred_kuaidi

在Alfred中查询快递,使用kd关键字,可以记录已经查过的快递和查询新快递,不需要输入快递公司名称。

[直接下载Alfred2 workflow文件](https://github.com/roylez/alfred_kuaidi/releases)
[直接下载workflow文件](https://github.com/roylez/alfred_kuaidi/releases)

![查询界面](https://github.com/roylez/alfred_kuaidi/blob/master/screenshot.png)

11 changes: 8 additions & 3 deletions alfred.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ def initialize; super('item'); end
def title text
self << elem_with_text(:title, text)
end
def subtitle text
self << elem_with_text(:subtitle, text)
def subtitle( text, mod = nil )
unless mod
self << elem_with_text(:subtitle, text)
else
self << elem_with_text(:subtitle, text, "mod" => mod)
end
end
def icon text
self << elem_with_text(:icon, text)
Expand All @@ -63,9 +67,10 @@ def attribute(att, value)
end

private
def elem_with_text(label, text)
def elem_with_text(label, text, attrs = {})
el = Element.new(label.to_s)
el.text = text
el.add_attributes(attrs)
el
end
end
84 changes: 62 additions & 22 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
Expand All @@ -23,6 +25,8 @@
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>4B7DB9D4-3060-44CE-B15F-D37AD4D1B7F0</key>
Expand All @@ -34,6 +38,8 @@
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>5704D04E-1A19-4674-B4A6-D3EB030B94AF</key>
Expand All @@ -45,6 +51,8 @@
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>B97F5196-169F-473B-9751-F3DA9291CA68</key>
Expand All @@ -56,6 +64,8 @@
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
Expand All @@ -76,12 +86,8 @@
<false/>
<key>onlyshowifquerypopulated</key>
<false/>
<key>output</key>
<integer>1</integer>
<key>removeextension</key>
<false/>
<key>sticky</key>
<false/>
<key>text</key>
<string>快递的状态已经复制到剪切板</string>
<key>title</key>
Expand All @@ -92,15 +98,21 @@
<key>uid</key>
<string>A70A4E1E-712E-4575-967A-0AA64960904D</string>
<key>version</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>127</integer>
<key>script</key>
<string>echo {query}|tr ";" "\n"</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
Expand All @@ -109,11 +121,15 @@
<key>uid</key>
<string>22B8ECA9-C3D1-4670-ACEE-79335B9AAEEA</string>
<key>version</key>
<integer>0</integer>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>1</integer>
<key>escaping</key>
Expand All @@ -136,6 +152,10 @@
else
/usr/bin/ruby ./list_query.rb
fi</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>请输入快递单号,不用输入快递公司</string>
<key>title</key>
Expand All @@ -150,7 +170,7 @@ fi</string>
<key>uid</key>
<string>4B7DB9D4-3060-44CE-B15F-D37AD4D1B7F0</string>
<key>version</key>
<integer>0</integer>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
Expand All @@ -159,13 +179,15 @@ fi</string>
<false/>
<key>clipboardtext</key>
<string></string>
<key>transient</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.output.clipboard</string>
<key>uid</key>
<string>1D9D3C1D-2D95-4BCC-B606-154D8CE31E7B</string>
<key>version</key>
<integer>0</integer>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
Expand All @@ -174,12 +196,8 @@ fi</string>
<false/>
<key>onlyshowifquerypopulated</key>
<false/>
<key>output</key>
<integer>0</integer>
<key>removeextension</key>
<false/>
<key>sticky</key>
<false/>
<key>text</key>
<string>快递查询记录已经全部清除!</string>
<key>title</key>
Expand All @@ -190,7 +208,7 @@ fi</string>
<key>uid</key>
<string>56F533F1-9451-41DF-9F00-F7340B43F3EB</string>
<key>version</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
Expand All @@ -199,6 +217,8 @@ fi</string>
<integer>2</integer>
<key>keyword</key>
<string>kdc</string>
<key>subtext</key>
<string></string>
<key>text</key>
<string>kdc 删除所有查询记录</string>
<key>withspace</key>
Expand All @@ -209,15 +229,21 @@ fi</string>
<key>uid</key>
<string>5704D04E-1A19-4674-B4A6-D3EB030B94AF</string>
<key>version</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>127</integer>
<key>script</key>
<string>rm -f query.json</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
Expand All @@ -226,7 +252,7 @@ fi</string>
<key>uid</key>
<string>B97F5196-169F-473B-9751-F3DA9291CA68</string>
<key>version</key>
<integer>0</integer>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
Expand All @@ -235,38 +261,52 @@ fi</string>
<dict>
<key>1D9D3C1D-2D95-4BCC-B606-154D8CE31E7B</key>
<dict>
<key>xpos</key>
<integer>530</integer>
<key>ypos</key>
<real>160</real>
<integer>200</integer>
</dict>
<key>22B8ECA9-C3D1-4670-ACEE-79335B9AAEEA</key>
<dict>
<key>xpos</key>
<integer>330</integer>
<key>ypos</key>
<real>80</real>
<integer>120</integer>
</dict>
<key>4B7DB9D4-3060-44CE-B15F-D37AD4D1B7F0</key>
<dict>
<key>xpos</key>
<integer>130</integer>
<key>ypos</key>
<real>80</real>
<integer>120</integer>
</dict>
<key>56F533F1-9451-41DF-9F00-F7340B43F3EB</key>
<dict>
<key>xpos</key>
<integer>530</integer>
<key>ypos</key>
<real>300</real>
<integer>340</integer>
</dict>
<key>5704D04E-1A19-4674-B4A6-D3EB030B94AF</key>
<dict>
<key>xpos</key>
<integer>130</integer>
<key>ypos</key>
<real>300</real>
<integer>340</integer>
</dict>
<key>A70A4E1E-712E-4575-967A-0AA64960904D</key>
<dict>
<key>xpos</key>
<integer>530</integer>
<key>ypos</key>
<real>10</real>
<integer>50</integer>
</dict>
<key>B97F5196-169F-473B-9751-F3DA9291CA68</key>
<dict>
<key>xpos</key>
<integer>330</integer>
<key>ypos</key>
<real>300</real>
<integer>340</integer>
</dict>
</dict>
<key>webaddress</key>
Expand Down
8 changes: 5 additions & 3 deletions kuaidi_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ def format_alfred_detail(detail)
attribute :arg, detail[:data].collect{|r| format_status_record(r,nil)}.join(";")
title decode_company( detail[:com]) + ' ' + detail[:nu]
icon 'icon.png'
subtitle 'Enter 将快递状态复制到剪切板'
subtitle 'Shift 显示详情 | Enter 复制到剪切板'
end

total = detail[:data].size
detail[:data].each.with_index do |record, ind|
context = record[:context].gsub(/\s+/, ' ')
al.add_item do
title ("[%02d]" % (total - ind) + ' ' + record[:context].gsub(/\s+/, ' '))
title ("[%02d]" % (total - ind) + ' ' + context)
subtitle record[:time]
subtitle context, "shift"
icon record[:context] =~ /签收/ ? 'success.png' : ( ind.zero? ? 'truck.png' : 'up.png' )
attribute :valid, 'no'
attribute :arg, context
end
end

Expand Down

0 comments on commit fd21a08

Please sign in to comment.