Skip to content

Commit 2e47f0c

Browse files
authored
Merge pull request #51 from weixin/logo
提交一个WeSketch新形象
2 parents f2abb00 + a4ad4a3 commit 2e47f0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+130
-88
lines changed

.DS_Store

6 KB
Binary file not shown.
Loading
Loading

WeSketch.sketchplugin/Contents/Sketch/checkForUpdate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function checkForUpdate(context, auto) {
1818
if (auto && updateAvailable == false) {
1919
return false;
2020
}
21-
var updateAlert = COSAlertWindow.new();
21+
var updateAlert = dialog(context);
2222

2323
updateAlert.setMessageText(updateAvailable ? i18.m2 : i18.m3);
2424
if (updateAvailable) {

WeSketch.sketchplugin/Contents/Sketch/codeSetting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var codeKey = "com.sketchplugins.wechat.codetype";
55
var onRun = function (context) {
66
var i18 = _(context).codeSetting;
77

8-
var settingsWindow = COSAlertWindow.new();
8+
var settingsWindow = dialog(context);
99
settingsWindow.addButtonWithTitle(i18.m1);
1010
settingsWindow.addButtonWithTitle(i18.m2);
1111
settingsWindow.setMessageText(i18.m3);

WeSketch.sketchplugin/Contents/Sketch/colorReplace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function colorReplace(context) {
170170
}
171171

172172
function createUserInterface(colorToFind) {
173-
userInterface = COSAlertWindow.new(); // 创建弹框
173+
userInterface = dialog(context); // 创建弹框
174174

175175
userInterface.setMessageText(i18.m1);
176176

WeSketch.sketchplugin/Contents/Sketch/common.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ var _ = function (context) {
3737
return i18Content;
3838
};
3939

40+
function dialog(context) {
41+
var iconImage = NSImage.alloc().initByReferencingFile(context.plugin.urlForResourceNamed("icon.png").path());
42+
var alert = COSAlertWindow.new();
43+
if (iconImage) {
44+
alert.setIcon(iconImage);
45+
}
46+
return alert;
47+
}
48+
49+
function errorDialog(context,content) {
50+
var iconImage = NSImage.alloc().initByReferencingFile(context.plugin.urlForResourceNamed("icon.png").path());
51+
var alert = COSAlertWindow.new();
52+
if (iconImage) {
53+
alert.setIcon(iconImage);
54+
}
55+
alert.addButtonWithTitle(_(context).checkForUpdate.m9);
56+
57+
alert.setMessageText(_(context).checkForUpdate.m10);
58+
alert.setInformativeText(content);
59+
return alert.runModal();
60+
}
4061

4162
function initDefaults(pluginDomain, initialValues) {
4263
kPluginDomain = pluginDomain;
@@ -142,7 +163,7 @@ function get(args) {
142163
if (jsonData.status == 200) {
143164
return jsonData;
144165
} else {
145-
NSApp.displayDialog(jsonData.msg);
166+
errorDialog(context,jsonData.msg);
146167
return jsonData;
147168
}
148169
}
@@ -155,7 +176,7 @@ function post(args) {
155176
if (jsonData.status == 200) {
156177
return jsonData;
157178
} else {
158-
NSApp.displayDialog(jsonData.msg);
179+
errorDialog(context,jsonData.msg);
159180
return jsonData;
160181
}
161182
}

WeSketch.sketchplugin/Contents/Sketch/commonPreview.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ var buildPreview = function (context) {
209209
var setIndex = function (context) {
210210
var i18 = _(context).commonPreview;
211211
if (context.selection.length == 0) {
212-
return NSApp.displayDialog(i18.m1);
212+
return errorDialog(context,i18.m1);
213213
} else {
214214
var selection = context.selection[0];
215215
if (selection.className() != 'MSArtboardGroup') {
216-
return NSApp.displayDialog(i18.m1);
216+
return errorDialog(context,i18.m1);
217217
}
218218
var linkLayersPredicate = NSPredicate.predicateWithFormat("userInfo != nil && function(userInfo, 'valueForKeyPath:', %@).indexMain != nil", previewKey);
219219
var indexObject = context.document.currentPage().children().filteredArrayUsingPredicate(linkLayersPredicate);
@@ -230,7 +230,7 @@ var setDialog = function (context) {
230230
var fx = 0;
231231

232232
function chooseDialog() {
233-
var settingsWindow = COSAlertWindow.new();
233+
var settingsWindow = dialog(context);
234234
settingsWindow.addButtonWithTitle(i18.m2);
235235
settingsWindow.addButtonWithTitle(i18.m3);
236236

@@ -243,11 +243,11 @@ var setDialog = function (context) {
243243
return settingsWindow.runModal();
244244
}
245245
if (context.selection.length == 0) {
246-
return NSApp.displayDialog(i18.m1);
246+
return errorDialog(context,i18.m1);
247247
} else {
248248
var selection = context.selection[0];
249249
if (selection.className() != 'MSArtboardGroup') {
250-
return NSApp.displayDialog(i18.m1);
250+
return errorDialog(context,i18.m1);
251251
}
252252
if (chooseDialog() != '1000') {
253253
return;
@@ -277,7 +277,7 @@ var setFixed = function (context) {
277277
var fx = 0;
278278

279279
function chooseDialog2() {
280-
var settingsWindow = COSAlertWindow.new();
280+
var settingsWindow = dialog(context);
281281
settingsWindow.addButtonWithTitle(i18.m2);
282282
settingsWindow.addButtonWithTitle(i18.m3);
283283

@@ -291,7 +291,7 @@ var setFixed = function (context) {
291291
}
292292

293293
function chooseDialog(n) {
294-
var settingsWindow = COSAlertWindow.new();
294+
var settingsWindow = dialog(context);
295295
settingsWindow.addButtonWithTitle(i18.m2);
296296
settingsWindow.addButtonWithTitle(i18.m3);
297297
settingsWindow.setMessageText(i18.m14 + n + i18.m15);
@@ -303,11 +303,11 @@ var setFixed = function (context) {
303303
context.command.setValue_forKey_onLayer_forPluginIdentifier(direction, "direction", selection, previewKey);
304304
}
305305
if (context.selection.length == 0) {
306-
return NSApp.displayDialog(i18.m13);
306+
return errorDialog(context,i18.m13);
307307
} else {
308308
var selection = context.selection[0];
309309
if (selection.className() == 'MSArtboardGroup') {
310-
return NSApp.displayDialog(i18.m13);
310+
return errorDialog(context,i18.m13);
311311
}
312312
if (!chooseDialog2()) {
313313
return;
@@ -351,18 +351,18 @@ var setBacks = function (context) {
351351
var fx = 0;
352352

353353
function chooseDialog(n) {
354-
var settingsWindow = COSAlertWindow.new();
354+
var settingsWindow = dialog(context);
355355
settingsWindow.addButtonWithTitle(i18.m2);
356356
settingsWindow.addButtonWithTitle(i18.m3);
357357
settingsWindow.setMessageText(i18.m14 + n + i18.m15);
358358
return settingsWindow.runModal();
359359
}
360360
if (context.selection.length == 0) {
361-
return NSApp.displayDialog(i18.m10);
361+
return errorDialog(context,i18.m10);
362362
} else {
363363
var selection = context.selection[0];
364364
if (selection.className() == 'MSArtboardGroup') {
365-
return NSApp.displayDialog(i18.m10);
365+
return errorDialog(context,i18.m10);
366366
}
367367
var lengthD = 0;
368368
var saveDom = [];
@@ -391,18 +391,18 @@ var setNoBuild = function (context) {
391391
var fx = 0;
392392

393393
function chooseDialog(n) {
394-
var settingsWindow = COSAlertWindow.new();
394+
var settingsWindow = dialog(context);
395395
settingsWindow.addButtonWithTitle(i18.m2);
396396
settingsWindow.addButtonWithTitle(i18.m3);
397397
settingsWindow.setMessageText(i18.m14 + n + i18.m15);
398398
return settingsWindow.runModal();
399399
}
400400
if (context.selection.length == 0) {
401-
return NSApp.displayDialog(i18.m10);
401+
return errorDialog(context,i18.m10);
402402
} else {
403403
var selection = context.selection[0];
404404
if (selection.className() == 'MSArtboardGroup') {
405-
return NSApp.displayDialog(i18.m10);
405+
return errorDialog(context,i18.m10);
406406
}
407407
var lengthD = 0;
408408
var saveDom = [];
@@ -427,7 +427,7 @@ var clearPreview = function (context) {
427427
var i18 = _(context).commonPreview;
428428
var domKey = ['backMain', 'fixedMain', 'dialogMain', 'indexMain', 'noBuildMain'];
429429
if (context.selection.length == 0) {
430-
return NSApp.displayDialog(i18.m16);
430+
return errorDialog(context,i18.m16);
431431
}
432432
for (var i = 0; i < context.selection.length; i++) {
433433
for (var k = 0; k < domKey.length; k++) {

WeSketch.sketchplugin/Contents/Sketch/commonPreviewJson.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ var commonPreviewJson = function (context, filePath, show) {
189189
var fxlocal = '0';
190190

191191
function chooseDialog() {
192-
var settingsWindow = COSAlertWindow.new();
192+
var settingsWindow = dialog(context);
193193
settingsWindow.addButtonWithTitle(i18.m2);
194194
settingsWindow.addButtonWithTitle(i18.m3);
195195

@@ -406,7 +406,7 @@ var commonPreviewJson = function (context, filePath, show) {
406406
}
407407
}
408408
if (!flag) {
409-
NSApp.displayDialog(i18.m18);
409+
errorDialog(context,i18.m18);
410410
return false;
411411
}
412412

WeSketch.sketchplugin/Contents/Sketch/exportColor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ var onRun = function (context) {
4343
}
4444

4545
} else {
46-
NSApp.displayDialog(i18.m2);
46+
errorDialog(context,i18.m2);
4747
}
4848
}

0 commit comments

Comments
 (0)