Skip to content

Commit

Permalink
Merge pull request #54 from youxiachai/patch-2
Browse files Browse the repository at this point in the history
分享模块更新支持windows
  • Loading branch information
guo-yu committed Jan 22, 2014
2 parents 97be986 + d240f9b commit 8ff77a0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions libs/fm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ var fs = require('fs'),
sys = require('../package'),
sdk = require('./sdk'),
utils = require('./utils'),
errors = require('./errors');
errors = require('./errors'),
openBrowser = process.platform === 'win32' ? 'start' : 'open';

var shorthands = {
'return': 'play',
Expand Down Expand Up @@ -222,7 +223,7 @@ Fm.prototype.go = function(channel, user, link) {
if (!this.player) return false;
if (!this.player.playing) return false;
return exeq([
'open ' + (link ? link : this.album(this.player.playing.album))
openBrowser + ' ' + (link ? link : this.album(this.player.playing.album))
]).run();
}

Expand All @@ -231,8 +232,8 @@ Fm.prototype.share = function(channel, user) {
if (!this.player.playing) return false;
var self = this;
var song = self.player.playing;
return self.go(null, null,
'http://service.weibo.com/share/share.php?' +

var shareText = 'http://service.weibo.com/share/share.php?' +
'&type=button' +
'&style=number' +
'&appkey=5rjNpN' +
Expand All @@ -257,8 +258,14 @@ Fm.prototype.share = function(channel, user) {
song.public_time,
self.album(song.album)
].join(' ')
)
);
);

if(process.platform === 'win32'){
//win 下终端 & 需要转义
shareText = shareText.replace(/&/g, '^&');
}

return self.go(null, null, shareText);
}

Fm.prototype.createMenu = function(callback) {
Expand Down

0 comments on commit 8ff77a0

Please sign in to comment.