Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
bugluo committed Jan 26, 2019
1 parent b075bce commit 18c7ab2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
4 changes: 2 additions & 2 deletions WeSketch.sketchplugin/Contents/Sketch/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{"key":"zhCN","name":"简体中文(zhCN)"},
{"key":"zhTW","name":"繁體中文(zhTW)"}
],
"UIKIT": [{"title":"WeChat UI Kit","url":"https://team.weui.io/double/WeChat.sketch"}
"UIKIT": [{"title":"WeChat UI Kit","url":""}
],
"COLOR": [{"title":"WeUI","url":""
"COLOR": [{"title":"","url":""
}]
}
2 changes: 1 addition & 1 deletion WeSketch.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Miaow",
"author": "Tencent WeChat",
"version": "1.4.5",
"version": "1.4.4",
"identifier": "cn.wechat",
"description": "A set of plugins for Sketch include drawing links & marks, UI Kit & Color sync, font & text replacing",
"icon": "minicon.png",
Expand Down
9 changes: 6 additions & 3 deletions WeSketch.sketchplugin/Contents/Sketch/newSyncUikit.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,16 @@ var syncUIKit = function syncUIKit(context, fileType, fileMarkup) {
}

var runExportModal = function runExportModal() {
var syncWeChatKey = 'com.sketchplugins.wechat.syncWeChatKey';

var exportModal = COSAlertWindow["new"]();
var iconImage = NSImage.alloc().initByReferencingFile(context.plugin.urlForResourceNamed("icon.png").path());
if (iconImage) {
exportModal.setIcon(iconImage);
}
exportModal.setMessageText("\u8BF7\u9009\u62E9\u8981\u5BFC\u5165\u7684 Library");
exportModal.setInformativeText('下载可能需要10-15秒下载文件');

exportModal.addButtonWithTitle("确认");
exportModal.addButtonWithTitle("取消");

Expand Down Expand Up @@ -228,14 +232,13 @@ var syncUIKit = function syncUIKit(context, fileType, fileMarkup) {
return;
} else {
var uikit = scaleOptionsMatrix.selectedCell();
context.document.showMessage(uikit);

var index = uikit.tag();
context.document.showMessage(index);
context.document.showMessage('导入中');

var data = networkRequest([uikitList[index].url]);
var save = NSSavePanel.savePanel();
var databasePath = (save.URL().path() + '.sketch').replace('Untitled', 'WeChat');
var databasePath = (save.URL().path() + '.sketch').replace('Untitled', uikitList[index].title);
data = NSData.alloc().initWithData(data);
data.writeToFile_atomically(databasePath, true);

Expand Down
42 changes: 42 additions & 0 deletions WeSketch.sketchplugin/Contents/Sketch/onAction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "toolbar.js";
@import "checkForUpdate.js";
@import "common.js"

var selectionDom = "com.sketchplugins.wechat.selectionDom";
var selectionDom1 = "com.sketchplugins.wechat.selectionDom1";
Expand Down Expand Up @@ -47,4 +48,45 @@ var onOpenDocument = function (context) {
if (toolbarAuto != 'false') {
toolbar(context, true);
}
// var syncWeChatKey = 'com.sketchplugins.wechat.syncWeChatKey';
// var syncWeChatTime = 'com.sketchplugins.wechat.syncWeChatTime';

// var time = NSUserDefaults.standardUserDefaults().objectForKey(syncWeChatTime);

// var myDate = new Date();
// var toDay = myDate.toLocaleDateString();
// if(toDay == time){
// return;
// }else{
// NSUserDefaults.standardUserDefaults().setObject_forKey(toDay, syncWeChatTime);
// }


// var returnData = networkRequest([getConfig('config', context).VERSION])
// var jsonData = [[NSString alloc] initWithData: returnData encoding: NSUTF8StringEncoding];
// jsonData = JSON.parse(jsonData);
// var currentVersion = jsonData.currentVersion;


// var version = NSUserDefaults.standardUserDefaults().objectForKey(syncWeChatKey);
// if(version != currentVersion){
// var i18 = _(context).checkForUpdate;
// var updateAlert = dialog(context);
// updateAlert.setMessageText('检查到有新的 libary ,是否更新?');
// updateAlert.setInformativeText('更新可能需要10-15秒下载文件');
// updateAlert.addButtonWithTitle(i18.m7);
// updateAlert.addButtonWithTitle(i18.m8);
// var response = updateAlert.runModal();
// if (response == "1000") {
// var data = networkRequest(['https://team.weui.io/double/WeChat.sketch']);
// var save = NSSavePanel.savePanel();
// var databasePath = (save.URL().path() + '.sketch').replace('Untitled', 'WeChat');
// data = NSData.alloc().initWithData(data);
// data.writeToFile_atomically(databasePath, true);
// NSUserDefaults.standardUserDefaults().setObject_forKey(currentVersion, syncWeChatKey);
// context.document.showMessage('导入成功,请在 Symbol 中使用您的 Library');

// }
// }

};

0 comments on commit 18c7ab2

Please sign in to comment.