Skip to content

Commit 892ca3e

Browse files
committed
refactor: simplify installer step numbering by removing dynamic calculation and add specific alerts for auto-handled installations.
1 parent 8ca8708 commit 892ca3e

1 file changed

Lines changed: 43 additions & 35 deletions

File tree

src/components/InteractiveInstaller.vue

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,20 @@ const logic = {
131131
}
132132
};
133133
134-
const configStepCode = computed(() => {
134+
const activateServerCode = computed(() => {
135135
if (selectedDistro.value === 'NixOS') return '# Bước này đã được cấu hình trong flake.nix ở trên.';
136-
if (['Debian', 'Ubuntu'].includes(selectedDistro.value) && selectedMethod.value === 'Package Manager') {
137-
return '# Gói .deb sẽ tự động thực hiện bước này qua post-install script.\n# Bạn có thể bỏ qua hoặc chạy lại nếu cần:\n' + serverCmd.value;
136+
if (isAutoHandled.value) {
137+
return '# Gói .deb sẽ tự động thực hiện bước này.\n' + serverCmd.value;
138138
}
139-
140-
return `${serverCmd.value}\n\n# Thiết lập biến môi trường\n${envCmd.value}`;
139+
return serverCmd.value;
140+
});
141+
142+
const shellConfigCode = computed(() => {
143+
if (selectedDistro.value === 'NixOS') return '# Bước này đã được cấu hình trong flake.nix ở trên.';
144+
if (isAutoHandled.value) {
145+
return '# Gói .deb sẽ tự động thiết lập biến môi trường.\n' + envCmd.value;
146+
}
147+
return envCmd.value;
141148
});
142149
143150
const serverCmd = computed(() => {
@@ -202,24 +209,6 @@ const isAutoHandled = computed(() => {
202209
return ['Debian', 'Ubuntu'].includes(selectedDistro.value) && selectedMethod.value === 'Package Manager';
203210
});
204211
205-
const getStepNumber = (stepKey: string) => {
206-
let num = 1; // Step 1 is always visible
207-
if (stepKey === 'install') return 1;
208-
209-
if (!isAutoHandled.value) {
210-
if (stepKey === 'activate') return 2;
211-
if (stepKey === 'ibus') return 3;
212-
num = 3;
213-
} else {
214-
num = 1;
215-
}
216-
217-
if (stepKey === 'autostart') return num + 1;
218-
if (stepKey === 'config') return num + 2;
219-
if (stepKey === 'extras') return num + 3;
220-
return 0;
221-
};
222-
223212
const copyToClipboard = async (text: string) => {
224213
try {
225214
await navigator.clipboard.writeText(text);
@@ -372,26 +361,45 @@ const kanataConfig = {
372361
<pre><code>{{ installStepCode }}</code></pre>
373362
<el-button class="copy-float" circle :icon="DocumentCopy" @click="copyToClipboard(installStepCode)" />
374363
</div>
375-
<el-alert v-if="isAutoHandled" title="Lưu ý: Bạn cần Đăng xuất và Đăng nhập lại sau bước này." type="info" :closable="false" class="mt-4" />
376364
</div>
377365
</div>
378366

379-
<div v-if="!isAutoHandled" class="step-card">
380-
<div class="step-badge">{{ getStepNumber('activate') }}</div>
367+
<div class="step-card">
368+
<div class="step-badge">2</div>
369+
<div class="step-content">
370+
<h4>Kích hoạt Server</h4>
371+
<div v-if="isAutoHandled" class="mb-3">
372+
<el-alert title="Gói .deb sẽ tự động kích hoạt server qua post-install script. Bạn có thể bỏ qua bước này." type="success" :closable="false" />
373+
</div>
374+
<div class="code-container">
375+
<pre><code>{{ activateServerCode }}</code></pre>
376+
<el-button class="copy-float" circle :icon="DocumentCopy" @click="copyToClipboard(activateServerCode)" />
377+
</div>
378+
</div>
379+
</div>
380+
381+
<div class="step-card">
382+
<div class="step-badge">3</div>
381383
<div class="step-content">
382-
<h4>Kích hoạt Server & Cấu hình Shell</h4>
384+
<h4>Thiết lập biến môi trường (Shell)</h4>
385+
<div v-if="isAutoHandled" class="mb-3">
386+
<el-alert title="Gói .deb sẽ tự động thiết lập biến môi trường. Bạn có thể bỏ qua bước này." type="success" :closable="false" />
387+
</div>
383388
<div class="code-container">
384-
<pre><code>{{ configStepCode }}</code></pre>
385-
<el-button class="copy-float" circle :icon="DocumentCopy" @click="copyToClipboard(configStepCode)" />
389+
<pre><code>{{ shellConfigCode }}</code></pre>
390+
<el-button class="copy-float" circle :icon="DocumentCopy" @click="copyToClipboard(shellConfigCode)" />
386391
</div>
387-
<el-alert title="Lưu ý: Bạn cần Đăng xuất và Đăng nhập lại sau bước này." type="info" :closable="false" />
392+
<el-alert title="Lưu ý: Bạn cần Đăng xuất và Đăng nhập lại sau bước này để cấu hình Shell có hiệu lực." type="info" :closable="false" />
388393
</div>
389394
</div>
390395

391-
<div v-if="!isAutoHandled" class="step-card">
392-
<div class="step-badge">{{ getStepNumber('ibus') }}</div>
396+
<div class="step-card">
397+
<div class="step-badge">4</div>
393398
<div class="step-content">
394399
<h4>Tắt bộ gõ cũ (IBus)</h4>
400+
<div v-if="isAutoHandled" class="mb-3">
401+
<el-alert title="Gói .deb sẽ tự động tắt IBus. Bước này chỉ dùng để kiểm tra lại." type="success" :closable="false" />
402+
</div>
395403
<p class="instruction">Nếu máy bạn đang dùng IBus, hãy tắt nó đi trước khi chuyển sang Fcitx5 để tránh xung đột.</p>
396404
<div class="code-container mini">
397405
<pre><code>killall ibus-daemon || ibus exit</code></pre>
@@ -404,7 +412,7 @@ const kanataConfig = {
404412
</div>
405413

406414
<div class="step-card">
407-
<div class="step-badge">{{ getStepNumber('autostart') }}</div>
415+
<div class="step-badge">5</div>
408416
<div class="step-content">
409417
<h4>Tự động khởi chạy (Autostart)</h4>
410418
<div class="ui-nav-container">
@@ -414,7 +422,7 @@ const kanataConfig = {
414422
</div>
415423

416424
<div class="step-card">
417-
<div class="step-badge">{{ getStepNumber('config') }}</div>
425+
<div class="step-badge">6</div>
418426
<div class="step-content">
419427
<h4>Cấu hình bộ gõ Fcitx5</h4>
420428
<p class="instruction">Sau khi đã Log out và Log in lại:</p>
@@ -425,7 +433,7 @@ const kanataConfig = {
425433
</div>
426434

427435
<div class="step-card additional-card">
428-
<div class="step-badge">{{ getStepNumber('extras') }}</div>
436+
<div class="step-badge">7</div>
429437
<div class="step-content">
430438
<h4>Cấu hình bổ sung</h4>
431439

0 commit comments

Comments
 (0)