@aivin-labs/cli 1.0.37 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,7 +15,7 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
15
15
|
serverVn: 'VN',
|
|
16
16
|
serverLocal: 'Local',
|
|
17
17
|
serverConfirm: 'Đổi máy chủ sang {server}? Việc đang chạy trên máy này sẽ bị dừng.',
|
|
18
|
-
connect: '
|
|
18
|
+
connect: 'Đăng nhập để kết nối…',
|
|
19
19
|
pause: 'Tạm dừng nhận việc',
|
|
20
20
|
resume: 'Tiếp tục nhận việc',
|
|
21
21
|
startup: 'Khởi động cùng Windows',
|
|
@@ -36,11 +36,8 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
36
36
|
pairPrompt: 'Nhập mã kết nối từ Aivin (khung chat → Browser ▾ → Thêm máy tính này):',
|
|
37
37
|
pairOk: 'Kết nối',
|
|
38
38
|
pairCancel: 'Huỷ',
|
|
39
|
-
connectTitle: 'Kết nối máy tính này với Aivin Cloud',
|
|
40
|
-
connectPrompt: 'Đăng nhập tài khoản Aivin để liên kết máy tính này và nhận việc từ Aivin Cloud.',
|
|
41
|
-
connectSignIn: 'Đăng nhập để kết nối',
|
|
42
39
|
connectCode: 'Tôi có mã kết nối',
|
|
43
|
-
|
|
40
|
+
connectBrowserHint: 'Đang mở trang đăng nhập. Sau khi bạn cấp quyền, Aivin sẽ tự kết nối máy tính này.',
|
|
44
41
|
connectPairing: 'Đăng nhập thành công. Đang liên kết máy tính…',
|
|
45
42
|
connectFailed: 'Chưa kết nối được. Hãy thử lại hoặc dùng mã kết nối.',
|
|
46
43
|
connectDone: 'Đã kết nối máy tính này với Aivin Cloud.',
|
|
@@ -67,7 +64,7 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
67
64
|
serverVn: 'VN',
|
|
68
65
|
serverLocal: 'Local',
|
|
69
66
|
serverConfirm: 'Switch to {server}? Current work on this computer will be stopped.',
|
|
70
|
-
connect: '
|
|
67
|
+
connect: 'Sign in to connect…',
|
|
71
68
|
pause: 'Pause work',
|
|
72
69
|
resume: 'Resume work',
|
|
73
70
|
startup: 'Start with Windows',
|
|
@@ -88,11 +85,8 @@ export const TRAY_STRINGS = Object.freeze({
|
|
|
88
85
|
pairPrompt: 'Enter the connect code from Aivin (chat box → Browser ▾ → Add this computer):',
|
|
89
86
|
pairOk: 'Connect',
|
|
90
87
|
pairCancel: 'Cancel',
|
|
91
|
-
connectTitle: 'Connect this computer to Aivin Cloud',
|
|
92
|
-
connectPrompt: 'Sign in to your Aivin account to link this computer and receive work from Aivin Cloud.',
|
|
93
|
-
connectSignIn: 'Sign in to connect',
|
|
94
88
|
connectCode: 'I have a connect code',
|
|
95
|
-
|
|
89
|
+
connectBrowserHint: 'Opening sign-in. Aivin will connect this computer after you grant access.',
|
|
96
90
|
connectPairing: 'Signed in. Linking this computer…',
|
|
97
91
|
connectFailed: 'Could not connect. Try again or use a connect code.',
|
|
98
92
|
connectDone: 'This computer is connected to Aivin Cloud.',
|
|
@@ -373,7 +373,7 @@ namespace AivinDesktop {
|
|
|
373
373
|
Config cfg;
|
|
374
374
|
NotifyIcon tray;
|
|
375
375
|
Icon colorIcon, greyIcon, shownIcon;
|
|
376
|
-
ToolStripMenuItem status, updateItem, open, quickChat, quickVoice, pause, startup, mascot, terminal, quit, serverMenu, serverCloud, serverVn, serverLocal;
|
|
376
|
+
ToolStripMenuItem status, updateItem, open, connectCodeItem, quickChat, quickVoice, pause, startup, mascot, terminal, quit, serverMenu, serverCloud, serverVn, serverLocal;
|
|
377
377
|
ToolStripSeparator quickSeparator;
|
|
378
378
|
System.Windows.Forms.Timer timer;
|
|
379
379
|
Control invoker;
|
|
@@ -389,6 +389,7 @@ namespace AivinDesktop {
|
|
|
389
389
|
int delay = FirstDelay;
|
|
390
390
|
int fast = 0;
|
|
391
391
|
bool pairing = false;
|
|
392
|
+
bool browserConnectInProgress = false;
|
|
392
393
|
bool rePairPromptPending = false;
|
|
393
394
|
bool wasPaired;
|
|
394
395
|
bool quitting = false;
|
|
@@ -411,6 +412,7 @@ namespace AivinDesktop {
|
|
|
411
412
|
open = Item("", delegate { OpenAivin(); });
|
|
412
413
|
open.Font = new Font("Segoe UI", 10.0f, FontStyle.Bold);
|
|
413
414
|
open.Padding = new Padding(16, 7, 24, 7);
|
|
415
|
+
connectCodeItem = Item(cfg.T("connectCode"), delegate { ShowPairWithCode(); });
|
|
414
416
|
|
|
415
417
|
quickChat = Item(cfg.T("quickChat"), delegate { OpenAivin(); });
|
|
416
418
|
quickVoice = Item(cfg.T("quickVoice"), delegate { RequestMascot(VoiceFile); });
|
|
@@ -435,6 +437,7 @@ namespace AivinDesktop {
|
|
|
435
437
|
|
|
436
438
|
menu.Items.AddRange(new ToolStripItem[] {
|
|
437
439
|
open,
|
|
440
|
+
connectCodeItem,
|
|
438
441
|
mascot,
|
|
439
442
|
pause,
|
|
440
443
|
quickSeparator,
|
|
@@ -514,9 +517,9 @@ namespace AivinDesktop {
|
|
|
514
517
|
wasPaired = paired;
|
|
515
518
|
if (child == null && paired && DateTime.Now >= nextStart && LockHolder() == 0) StartChild(null);
|
|
516
519
|
Refresh();
|
|
517
|
-
if (rePairPromptPending && child == null && !pairing && pairForm == null && !tray.ContextMenuStrip.Visible) {
|
|
520
|
+
if (rePairPromptPending && child == null && !pairing && !browserConnectInProgress && pairForm == null && !tray.ContextMenuStrip.Visible) {
|
|
518
521
|
rePairPromptPending = false;
|
|
519
|
-
|
|
522
|
+
StartBrowserConnect();
|
|
520
523
|
}
|
|
521
524
|
}
|
|
522
525
|
|
|
@@ -526,7 +529,7 @@ namespace AivinDesktop {
|
|
|
526
529
|
* để không ngắt việc đang chạy.
|
|
527
530
|
*/
|
|
528
531
|
bool SwapIfExeReplaced() {
|
|
529
|
-
if (child != null || pairing || pairForm != null || isUpdating || tray.ContextMenuStrip.Visible) return false;
|
|
532
|
+
if (child != null || pairing || browserConnectInProgress || pairForm != null || isUpdating || tray.ContextMenuStrip.Visible) return false;
|
|
530
533
|
try {
|
|
531
534
|
string exe = Application.ExecutablePath;
|
|
532
535
|
if (!File.Exists(exe) || File.GetLastWriteTimeUtc(exe) == exeStamp) return false;
|
|
@@ -699,7 +702,7 @@ namespace AivinDesktop {
|
|
|
699
702
|
bool paired = HasPairedServer();
|
|
700
703
|
bool paused = File.Exists(PausedFile);
|
|
701
704
|
bool running = Running();
|
|
702
|
-
string state = !paired ? cfg.T(pairing ? "connecting" : "notPaired")
|
|
705
|
+
string state = !paired ? cfg.T(pairing || browserConnectInProgress ? "connecting" : "notPaired")
|
|
703
706
|
: !running ? cfg.T("stopped") : paused ? cfg.T("paused") : cfg.T("running");
|
|
704
707
|
status.Text = "● " + state;
|
|
705
708
|
string tip = "Aivin - " + state;
|
|
@@ -751,6 +754,8 @@ namespace AivinDesktop {
|
|
|
751
754
|
serverVn.Checked = selectedServer == "https://api.aivin.vn";
|
|
752
755
|
serverLocal.Checked = selectedServer == "http://localhost:3001";
|
|
753
756
|
open.Text = cfg.T(paired ? "open" : "connect");
|
|
757
|
+
connectCodeItem.Visible = !paired;
|
|
758
|
+
connectCodeItem.Enabled = !browserConnectInProgress;
|
|
754
759
|
pause.Text = cfg.T(paused ? "resume" : "pause");
|
|
755
760
|
pause.Visible = paired;
|
|
756
761
|
terminal.Text = cfg.T("terminal");
|
|
@@ -840,6 +845,7 @@ namespace AivinDesktop {
|
|
|
840
845
|
|
|
841
846
|
/** Double-click Aivin.exe: show the mascot and the platform in a browser app window. */
|
|
842
847
|
void OpenPlatform() {
|
|
848
|
+
if (!HasPairedServer()) { StartBrowserConnect(); return; }
|
|
843
849
|
ThreadPool.QueueUserWorkItem(delegate { LaunchPlatformApp(); });
|
|
844
850
|
OpenAivin();
|
|
845
851
|
}
|
|
@@ -938,7 +944,7 @@ namespace AivinDesktop {
|
|
|
938
944
|
/** Gửi yêu cầu cho daemon qua tệp đánh dấu (mascot-show = mở ô hỏi, mascot-voice = nói chuyện); daemon đang dừng thì chạy lại để nó nhận. */
|
|
939
945
|
void RequestMascot(string requestFile) {
|
|
940
946
|
if (quitting) return;
|
|
941
|
-
if (!HasPairedServer()) {
|
|
947
|
+
if (!HasPairedServer()) { StartBrowserConnect(); return; }
|
|
942
948
|
try {
|
|
943
949
|
try { SetMascotEnabled(true); } catch { }
|
|
944
950
|
long ms = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
|
|
@@ -1029,7 +1035,7 @@ namespace AivinDesktop {
|
|
|
1029
1035
|
nextStart = DateTime.MinValue;
|
|
1030
1036
|
delay = FirstDelay;
|
|
1031
1037
|
Refresh();
|
|
1032
|
-
if (!HasPairedServer())
|
|
1038
|
+
if (!HasPairedServer()) StartBrowserConnect();
|
|
1033
1039
|
else Tick();
|
|
1034
1040
|
}
|
|
1035
1041
|
|
|
@@ -1066,74 +1072,38 @@ namespace AivinDesktop {
|
|
|
1066
1072
|
Refresh();
|
|
1067
1073
|
}
|
|
1068
1074
|
|
|
1069
|
-
void
|
|
1070
|
-
if (
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
f.MinimizeBox = false;
|
|
1080
|
-
f.StartPosition = FormStartPosition.CenterScreen;
|
|
1081
|
-
f.TopMost = true;
|
|
1082
|
-
f.ClientSize = new Size(420, 194);
|
|
1083
|
-
bool[] connectCancelled = new bool[] { false };
|
|
1084
|
-
f.FormClosing += delegate { connectCancelled[0] = true; };
|
|
1085
|
-
Label label = new Label();
|
|
1086
|
-
label.Text = cfg.T("connectPrompt");
|
|
1087
|
-
label.SetBounds(16, 16, 388, 52);
|
|
1088
|
-
Label statusLabel = new Label();
|
|
1089
|
-
statusLabel.SetBounds(16, 76, 388, 24);
|
|
1090
|
-
statusLabel.ForeColor = Color.FromArgb(80, 90, 105);
|
|
1091
|
-
Button signIn = new Button();
|
|
1092
|
-
signIn.Text = cfg.T("connectSignIn");
|
|
1093
|
-
signIn.SetBounds(16, 128, 190, 32);
|
|
1094
|
-
signIn.BackColor = Color.FromArgb(33, 98, 230);
|
|
1095
|
-
signIn.ForeColor = Color.White;
|
|
1096
|
-
signIn.FlatStyle = FlatStyle.Flat;
|
|
1097
|
-
Button code = new Button();
|
|
1098
|
-
code.Text = cfg.T("connectCode");
|
|
1099
|
-
code.SetBounds(212, 128, 128, 32);
|
|
1100
|
-
Button cancel = new Button();
|
|
1101
|
-
cancel.Text = cfg.T("pairCancel");
|
|
1102
|
-
cancel.SetBounds(346, 128, 58, 32);
|
|
1103
|
-
cancel.DialogResult = DialogResult.Cancel;
|
|
1104
|
-
f.Controls.AddRange(new Control[] { label, statusLabel, signIn, code, cancel });
|
|
1105
|
-
f.CancelButton = cancel;
|
|
1106
|
-
pairForm = f;
|
|
1107
|
-
signIn.Click += delegate {
|
|
1108
|
-
signIn.Enabled = false;
|
|
1109
|
-
code.Enabled = false;
|
|
1110
|
-
statusLabel.Text = cfg.T("connectWorking");
|
|
1111
|
-
ThreadPool.QueueUserWorkItem(delegate {
|
|
1112
|
-
int loginResult = RunCliAndWait("login");
|
|
1113
|
-
if (loginResult != 0) {
|
|
1114
|
-
UI(delegate { if (!quitting && pairForm == f) { statusLabel.Text = cfg.T("connectFailed"); signIn.Enabled = code.Enabled = true; } });
|
|
1115
|
-
return;
|
|
1116
|
-
}
|
|
1117
|
-
if (connectCancelled[0]) return;
|
|
1118
|
-
UI(delegate { if (!quitting && pairForm == f) statusLabel.Text = cfg.T("connectPairing"); });
|
|
1119
|
-
int pairResult = RunCliAndWait("remote pair");
|
|
1075
|
+
void StartBrowserConnect() {
|
|
1076
|
+
if (browserConnectInProgress) return;
|
|
1077
|
+
browserConnectInProgress = true;
|
|
1078
|
+
rePairPromptPending = false;
|
|
1079
|
+
Refresh();
|
|
1080
|
+
Balloon(cfg.T("connectBrowserHint"), ToolTipIcon.Info);
|
|
1081
|
+
ThreadPool.QueueUserWorkItem(delegate {
|
|
1082
|
+
int loginResult = RunCliAndWait("login");
|
|
1083
|
+
if (quitting) return;
|
|
1084
|
+
if (loginResult != 0) {
|
|
1120
1085
|
UI(delegate {
|
|
1121
|
-
if (quitting
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
} else {
|
|
1126
|
-
statusLabel.Text = cfg.T("connectFailed");
|
|
1127
|
-
signIn.Enabled = code.Enabled = true;
|
|
1128
|
-
}
|
|
1086
|
+
if (quitting) return;
|
|
1087
|
+
browserConnectInProgress = false;
|
|
1088
|
+
Refresh();
|
|
1089
|
+
Balloon(cfg.T("connectFailed"), ToolTipIcon.Warning);
|
|
1129
1090
|
});
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
UI(delegate { if (!quitting) Balloon(cfg.T("connectPairing"), ToolTipIcon.Info); });
|
|
1094
|
+
int pairResult = RunCliAndWait("remote pair");
|
|
1095
|
+
UI(delegate {
|
|
1096
|
+
if (quitting) return;
|
|
1097
|
+
browserConnectInProgress = false;
|
|
1098
|
+
if (pairResult == 0 && HasPairedServer()) {
|
|
1099
|
+
wasPaired = true;
|
|
1100
|
+
Balloon(cfg.T("connectDone"), ToolTipIcon.Info);
|
|
1101
|
+
} else {
|
|
1102
|
+
Balloon(cfg.T("connectFailed"), ToolTipIcon.Warning);
|
|
1103
|
+
}
|
|
1104
|
+
Refresh();
|
|
1130
1105
|
});
|
|
1131
|
-
};
|
|
1132
|
-
code.Click += delegate { f.DialogResult = DialogResult.Retry; f.Close(); };
|
|
1133
|
-
DialogResult r = f.ShowDialog();
|
|
1134
|
-
pairForm = null;
|
|
1135
|
-
f.Dispose();
|
|
1136
|
-
if (r == DialogResult.Retry && !quitting) { ShowPairWithCode(); return; }
|
|
1106
|
+
});
|
|
1137
1107
|
}
|
|
1138
1108
|
|
|
1139
1109
|
int RunCliAndWait(string command) {
|