Skip to content

Commit a1804a1

Browse files
committed
1. Desktop 安装依赖包时禁用安装按钮;2. 完善 .gitignore;
1 parent 4a19866 commit a1804a1

5 files changed

Lines changed: 146 additions & 20 deletions

File tree

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = false
10+
11+
# Matches multiple files with brace expansion notation
12+
# Set default charset
13+
charset = utf-8
14+
15+
# Tab indentation (no size specified)
16+
indent_style = tab
17+
indent_size = 2
18+
19+
# Others
20+
trim_trailing_whitespace = true

.gitignore

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
*.pid.lock
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# nyc test coverage
19+
.nyc_output
20+
21+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
22+
.grunt
23+
24+
# node-waf configuration
25+
.lock-wscript
26+
27+
# Compiled binary addons (http://nodejs.org/api/addons.html)
28+
build/Release
29+
dist
30+
31+
# Dependency directories
132
node_modules
2-
npm-debug.log
33+
jspm_packages
34+
35+
# Optional npm cache directory
36+
.npm
37+
38+
# Optional eslint cache
39+
.eslintcache
40+
41+
# Optional REPL history
42+
.node_repl_history
43+
44+
# Output of 'npm pack'
45+
*.tgz
46+
47+
#Others
348
.DS_Store
4-
dist

css/main.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,15 @@ html {
330330
background-color: #1CB83A;
331331
border-color: #1CB83A;
332332
}
333+
.frame_toolbar_btn_Disabled {
334+
opacity: .5;
335+
}
336+
.frame_toolbar_btn_Disabled:hover,
337+
.frame_toolbar_btn_Disabled:active {
338+
background-color: transparent;
339+
border: 1px solid #00A3E1;
340+
color: #00A3E1;
341+
}
333342
.frame_toolbar_btn_Install,
334343
.frame_toolbar_btn_Gulp {
335344
margin-right: 0;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qmui_web_desktop",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "基于 QMUI Web 的桌面 App,它可以管理基于 QMUI Web 进行开发的项目,并提供了编译提醒,出错提醒,进程关闭提醒等额外的功能。",
55
"main": "main.js",
66
"scripts": {

src/app.js

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,15 @@ $projectList.on('click', '.js_project_item', function () {
409409

410410
// 根据是否开启了服务设置 Gulp 按钮的状态
411411
if ($this.data('watch')) {
412-
setWatching();
412+
setGulpBtnWatching();
413413
} else {
414-
setNormal();
414+
setGulpBtnNormal();
415+
}
416+
// 根据是否正在安装依赖包设置 Install 按钮的状态
417+
if ($this.data('install')) {
418+
setInstallBtnInstalling();
419+
} else {
420+
setInstallBtnNormal();
415421
}
416422
}
417423

@@ -434,22 +440,34 @@ $projectList.on('click', '.js_openFolder', function () {
434440
}
435441
});
436442

437-
function setNormal() {
443+
function setGulpBtnNormal() {
438444
$gulpButton.removeClass('frame_toolbar_btn_Watching');
439445
$gulpButton.text('开启 Gulp 服务');
440446

441447
$curProject.removeClass('project_stage_item_Watching');
442448
$curProject.data('watch', false);
443449
}
444450

445-
function setWatching() {
451+
function setGulpBtnWatching() {
446452
$gulpButton.addClass('frame_toolbar_btn_Watching');
447453
$gulpButton.text('Gulp 正在服务');
448454

449455
$curProject.addClass('project_stage_item_Watching');
450456
$curProject.data('watch', true);
451457
}
452458

459+
function setInstallBtnNormal() {
460+
$installButton.removeClass('frame_toolbar_btn_Disabled');
461+
462+
$curProject.data('install', false);
463+
}
464+
465+
function setInstallBtnInstalling() {
466+
$installButton.addClass('frame_toolbar_btn_Disabled');
467+
468+
$curProject.data('install', true);
469+
}
470+
453471
// 结束子进程
454472
function killChildProcess(projectDir) {
455473
let storage = Common.getLocalStorage();
@@ -548,6 +566,7 @@ function runDevTask(projectPath, task) {
548566
child = childProcess.spawn('gulp', [task], {env: {'PATH':'/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'}, cwd: qmuiPath, silent: true});
549567
}
550568
}
569+
console.log(child.pid);
551570

552571
child.stdout.setEncoding('utf-8');
553572
child.stdout.on('data', function (data) {
@@ -566,8 +585,9 @@ function runDevTask(projectPath, task) {
566585
logReply(`child process exited with code ${code}`, projectPath);
567586
}
568587

588+
let tipText;
569589
if (task === 'main') {
570-
let tipText;
590+
// Gulp 服务进程结束处理
571591
if (closeGulpManually) {
572592
closeGulpManually = false;
573593
tipText = '已关闭 Gulp 服务';
@@ -596,11 +616,39 @@ function runDevTask(projectPath, task) {
596616
Common.postNotification('Gulp 意外停止工作', '项目 ' + projectName + ' (' + projectDir + ') 的 Gulp 服务停止工作,请重新启动');
597617
}
598618
} else if (task === 'install') {
599-
$gulpButton.removeClass('qw_hide');
600-
$mergeButton.removeClass('qw_hide');
601-
$cleanButton.removeClass('qw_hide');
602-
$installButton.addClass('qw_hide');
603-
logReply(logTextWithDate('依赖包安装完毕,可以开始使用 QMUI Web 的功能'), projectPath);
619+
// 安装依赖包进程结束处理
620+
// 按照进程 pid 确定项目,然后手动更新 storage 和 UI 表现
621+
let $project = $('.js_project_item[data-pid="' + this.pid + '"]');
622+
$project.data('install', false);
623+
624+
let storage = Common.getLocalStorage();
625+
storage['projects'][projectDir]['pid'] = 0;
626+
Common.setLocalStorage(storage);
627+
628+
if (projectDir === $curProject.data('project')) {
629+
$installButton.removeClass('frame_toolbar_btn_Disabled');
630+
}
631+
632+
if (code && code !== 0) {
633+
// 出错处理
634+
tipText = '安装依赖包进程意外停止,请检查 NPM 和 Github 等环境后重新启动';
635+
logReply(logTextWithDate(tipText), projectPath);
636+
// 改变状态栏图标
637+
mainProcess.emit('closeGulp');
638+
// 发出通知
639+
let projectName = $project.data('name');
640+
Common.postNotification('安装依赖包进程意外停止', '项目 ' + projectName + ' (' + projectDir + ') 安装依赖包进程意外停止,请检查 NPM 和 Github 等环境后重新启动');
641+
} else {
642+
// 成功处理
643+
if (projectDir === $curProject.data('project')) {
644+
$gulpButton.removeClass('qw_hide');
645+
$mergeButton.removeClass('qw_hide');
646+
$cleanButton.removeClass('qw_hide');
647+
$installButton.addClass('qw_hide');
648+
}
649+
tipText = '依赖包安装完毕,可以开始使用 QMUI Web 的功能';
650+
logReply(logTextWithDate(tipText), projectPath);
651+
}
604652
}
605653
});
606654

@@ -615,12 +663,15 @@ function runDevTask(projectPath, task) {
615663

616664
$curProject.attr('data-pid', child.pid);
617665

618-
setWatching();
666+
setGulpBtnWatching();
667+
668+
} else if (task === 'install') {
669+
setInstallBtnInstalling();
619670
}
620671
}
621672
}
622673

623-
var runTaskInCurrentTask = function(task) {
674+
var runTaskOnCurrentProject = function(task) {
624675
let projectDir = $curProject.data('project');
625676
let storage = Common.getLocalStorage();
626677
if (storage && storage['projects'] && storage['projects'][projectDir]) {
@@ -629,7 +680,9 @@ var runTaskInCurrentTask = function(task) {
629680
};
630681

631682
$installButton.on('click', function() {
632-
runTaskInCurrentTask('install');
683+
if (!$curProject.data('install')) {
684+
runTaskOnCurrentProject('install');
685+
}
633686
});
634687

635688
$gulpButton.on('click', function() {
@@ -639,20 +692,20 @@ $gulpButton.on('click', function() {
639692
if ($curProject.data('watch')) {
640693
closeGulpManually = true;
641694
killChildProcess(projectDir);
642-
setNormal();
695+
setGulpBtnNormal();
643696
} else {
644-
runTaskInCurrentTask('main');
697+
runTaskOnCurrentProject('main');
645698
}
646699
});
647700

648701
$mergeButton.on('click', function() {
649702

650-
runTaskInCurrentTask('merge');
703+
runTaskOnCurrentProject('merge');
651704
});
652705

653706
$cleanButton.on('click', function() {
654707

655-
runTaskInCurrentTask('clean');
708+
runTaskOnCurrentProject('clean');
656709
});
657710

658711
// 设置界面

0 commit comments

Comments
 (0)