22import { ref , computed } from ' vue' ;
33import { DocumentCopy } from ' @element-plus/icons-vue' ;
44import { ElMessage } from ' element-plus' ;
5-
6- const distros = [
7- { name: " Arch Linux" , icon: " si-archlinux" },
8- { name: " Debian" , icon: " si-debian" },
9- { name: " Ubuntu" , icon: " si-ubuntu" },
10- { name: " Fedora" , icon: " si-fedora" },
11- { name: " openSUSE" , icon: " si-opensuse" },
12- { name: " NixOS" , icon: " si-nixos" }
13- ];
14- const methods = [" Package Manager" , " Binary" , " Source" ];
15- const shells = [" Bash" , " Zsh" , " Fish" ];
16- const deWms = [" GNOME" , " KDE Plasma" , " Xfce" , " Cinnamon" , " MATE" , " Pantheon" , " Budgie" , " LXQt" , " COSMIC" , " i3" , " Sway" , " Hyprland" ];
17- const environments = [" X11" , " Wayland" ];
5+ import {
6+ distros ,
7+ methods ,
8+ shells ,
9+ deWms ,
10+ environments ,
11+ logic ,
12+ fcitx5Config ,
13+ kanataConfig
14+ } from ' @/data/installer' ;
1815
1916const selectedDistro = ref (distros [0 ].name );
2017const selectedMethod = ref (methods [0 ]);
2118const selectedShell = ref (shells [0 ]);
2219const selectedDe = ref (deWms [0 ]);
23- const selectedEnv = ref (environments [0 ]);
24-
25- const logic = {
26- " steps" : {
27- " install" : {
28- " Arch Linux" : {
29- " Package Manager" : " yay -S fcitx5-lotus" ,
30- " Binary" : " sudo pacman -U fcitx5-lotus-*.pkg.tar.zst" ,
31- " Source" : " git clone https://github.com/LotusInputMethod/fcitx5-lotus.git\n cd fcitx5-lotus\n cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib .\n make\n sudo make install"
32- },
33- " Debian" : {
34- " Package Manager" : " CODENAME=$(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2)\n sudo mkdir -p /etc/apt/keyrings\n curl -fsSL https://fcitx5-lotus.pages.dev/pubkey.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/fcitx5-lotus.gpg\n echo \" deb [signed-by=/etc/apt/keyrings/fcitx5-lotus.gpg] https://fcitx5-lotus.pages.dev/apt/$CODENAME $CODENAME main\" | sudo tee /etc/apt/sources.list.d/fcitx5-lotus.list\n sudo apt update && sudo apt install fcitx5-lotus" ,
35- " Binary" : " sudo dpkg -i fcitx5-lotus_*.deb" ,
36- " Source" : " sudo apt-get install cmake extra-cmake-modules libfcitx5core-dev libfcitx5config-dev libfcitx5utils-dev libinput-dev libudev-dev g++ golang hicolor-icon-theme pkg-config libx11-dev libfcitx5-qt6-dev qt6-base-dev fcitx5-modules-dev\n git clone https://github.com/LotusInputMethod/fcitx5-lotus.git\n cd fcitx5-lotus\n cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib .\n make\n sudo make install"
37- },
38- " Ubuntu" : {
39- " Package Manager" : " CODENAME=$(grep '^UBUNTU_CODENAME=' /etc/os-release | cut -d'=' -f2)\n sudo mkdir -p /etc/apt/keyrings\n curl -fsSL https://fcitx5-lotus.pages.dev/pubkey.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/fcitx5-lotus.gpg\n echo \" deb [signed-by=/etc/apt/keyrings/fcitx5-lotus.gpg] https://fcitx5-lotus.pages.dev/apt/$CODENAME $CODENAME main\" | sudo tee /etc/apt/sources.list.d/fcitx5-lotus.list\n sudo apt update && sudo apt install fcitx5-lotus" ,
40- " Binary" : " sudo dpkg -i fcitx5-lotus_*.deb" ,
41- " Source" : " sudo apt-get install cmake extra-cmake-modules libfcitx5core-dev libfcitx5config-dev libfcitx5utils-dev libinput-dev libudev-dev g++ golang hicolor-icon-theme pkg-config libx11-dev libfcitx5-qt6-dev qt6-base-dev fcitx5-modules-dev\n git clone https://github.com/LotusInputMethod/fcitx5-lotus.git\n cd fcitx5-lotus\n cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib .\n make\n sudo make install"
42- },
43- " Fedora" : {
44- " Package Manager" : " RELEASEVER=$(grep '^VERSION_ID=' /etc/os-release | cut -d'=' -f2)\n sudo rpm --import https://fcitx5-lotus.pages.dev/pubkey.gpg\n sudo dnf config-manager addrepo --from-repofile=https://fcitx5-lotus.pages.dev/rpm/fedora/fcitx5-lotus-$RELEASEVER.repo\n sudo dnf install fcitx5-lotus" ,
45- " Binary" : " sudo rpm -i fcitx5-lotus-*.rpm" ,
46- " Source" : " sudo dnf install cmake extra-cmake-modules fcitx5-devel libinput-devel libudev-devel gcc-c++ golang hicolor-icon-theme systemd-devel libX11-devel fcitx5-qt-devel\n git clone https://github.com/LotusInputMethod/fcitx5-lotus.git\n cd fcitx5-lotus\n cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib .\n make\n sudo make install"
47- },
48- " openSUSE" : {
49- " Package Manager" : " sudo rpm --import https://fcitx5-lotus.pages.dev/pubkey.gpg\n sudo zypper addrepo https://fcitx5-lotus.pages.dev/rpm/opensuse/fcitx5-lotus-tumbleweed.repo\n sudo zypper refresh\n sudo zypper install fcitx5-lotus" ,
50- " Binary" : " sudo rpm -i fcitx5-lotus-*.rpm" ,
51- " Source" : " sudo zypper install cmake extra-cmake-modules fcitx5-devel libinput-devel systemd-devel gcc-c++ go hicolor-icon-theme systemd-devel libX11-devel udev fcitx5-qt-devel\n git clone https://github.com/LotusInputMethod/fcitx5-lotus.git\n cd fcitx5-lotus\n cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib .\n make\n sudo make install"
52- },
53- " NixOS" : {
54- " Package Manager" : " inputs.fcitx5-lotus = {\n url = \" github:LotusInputMethod/fcitx5-lotus\" ;\n inputs.nixpkgs.follows = \" nixpkgs\" ;\n };\n\n # In configuration.nix:\n services.fcitx5-lotus = {\n enable = true;\n user = \" your_username\" ;\n };" ,
55- " Binary" : " NixOS prefers flake/module configuration." ,
56- " Source" : " NixOS prefers nix-shell or custom derivations."
57- }
58- },
59- " server" : {
60- " Other" : {
61- " Bash" : " sudo systemctl enable --now fcitx5-lotus-server@$(whoami).service || (sudo systemd-sysusers && sudo systemctl enable --now fcitx5-lotus-server@$(whoami).service)" ,
62- " Zsh" : " sudo systemctl enable --now fcitx5-lotus-server@$(whoami).service || (sudo systemd-sysusers && sudo systemctl enable --now fcitx5-lotus-server@$(whoami).service)" ,
63- " Fish" : " sudo systemctl enable --now fcitx5-lotus-server@(whoami).service; or begin; sudo systemd-sysusers; and sudo systemctl enable --now fcitx5-lotus-server@(whoami).service; end"
64- }
65- },
66- " environment" : {
67- " Bash" : " cat <<EOF >> ~/.bash_profile\n export GTK_IM_MODULE=fcitx\n export QT_IM_MODULE=fcitx\n export XMODIFIERS=@im=fcitx\n export SDL_IM_MODULE=fcitx\n export GLFW_IM_MODULE=ibus\n EOF" ,
68- " Zsh" : " cat <<EOF >> ~/.zprofile\n export GTK_IM_MODULE=fcitx\n export QT_IM_MODULE=fcitx\n export XMODIFIERS=@im=fcitx\n export SDL_IM_MODULE=fcitx\n export GLFW_IM_MODULE=ibus\n EOF" ,
69- " Fish" : " echo 'if status is-login\n set -Ux GTK_IM_MODULE fcitx\n set -Ux QT_IM_MODULE fcitx\n set -Ux XMODIFIERS \" @im=fcitx\"\n set -gx SDL_IM_MODULE fcitx\n set -gx GLFW_IM_MODULE ibus\n end' >> ~/.config/fish/config.fish"
70- },
71- " autostart" : {
72- " GNOME" : " GNOME Tweaks → Startup Applications → Add → Fcitx 5" ,
73- " KDE Plasma" : " System Settings → Autostart → Add... → Add Application... → Fcitx 5" ,
74- " Xfce" : " Settings → Session and Startup → Application Autostart → Add → Fcitx 5" ,
75- " Cinnamon" : " System Settings → Startup Applications → + → Choose application → Fcitx 5" ,
76- " MATE" : " Control Center → Startup Applications → Add (Name: Fcitx 5, Command: fcitx5)" ,
77- " Pantheon" : " System Settings → Applications → Startup → Add Startup App... → Fcitx 5" ,
78- " Budgie" : " Budgie Desktop Settings → Autostart → + → Add application → Fcitx 5" ,
79- " LXQt" : " LXQt Configuration Center → Session Settings → Autostart → LXQt Autostart → Add (Name: Fcitx 5, Command: fcitx5)" ,
80- " COSMIC" : " COSMIC Settings → Applications → Startup Applications → Add app → Fcitx 5" ,
81- " i3" : " Add `exec --no-startup-id fcitx5 -d` to ~/.config/i3/config" ,
82- " Sway" : " Add `exec --no-startup-id fcitx5 -d` to ~/.config/sway/config" ,
83- " Hyprland" : " Add `exec-once = fcitx5 -d` to ~/.config/hypr/hyprland.conf"
84- },
85- " wayland_extras" : {
86- " General" : {
87- " title" : " Khuyến nghị Xwayland" ,
88- " description" : " Ngay cả khi bạn chỉ dùng ứng dụng Wayland native, bật Xwayland vẫn được khuyến nghị. Nếu bảng gõ client-side không hoạt động, Fcitx sẽ chuyển sang cửa sổ X11 để đảm bảo vị trí hiển thị chính xác thay vì một cửa sổ Wayland ngẫu nhiên."
89- },
90- " KDE Plasma" : {
91- " best_setup" : [
92- " Sử dụng KDE Plasma 5.27 trở lên." ,
93- " Biến môi trường: `XMODIFIERS=@im=fcitx` cho ứng dụng XWayland." ,
94- " Vào **System Settings** -> **Virtual Keyboard** -> Chọn **Fcitx 5**." ,
95- " Không đặt `GTK_IM_MODULE` & `QT_IM_MODULE` toàn cục." ,
96- " Tham số trình duyệt: `--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime`"
97- ],
98- " support_info" : " Hỗ trợ text-input-v1/v2/v3 và zwp_input_method_v1." ,
99- " caveats" : " Một số ứng dụng Gtk/Qt cũ chỉ chạy X11 vẫn có thể cần đặt module riêng lẻ. Tránh đặt toàn cục để tránh lỗi nhấp nháy cửa sổ ứng viên."
100- },
101- " GNOME" : {
102- " best_setup" : [
103- " Biến môi trường: `XMODIFIERS=@im=fcitx` cho XWayland." ,
104- " Qt5: `QT_IM_MODULE=fcitx`." ,
105- " Qt >= 6.8.2: `QT_IM_MODULES=\" wayland;fcitx\" `." ,
106- " Chrome: Chạy qua XWayland với `GTK_IM_MODULE=fcitx`."
107- ],
108- " support_info" : " Sử dụng text-input-v3 và giao thức ibus dbus." ,
109- " caveats" : " Gnome-shell UI không hiển thị được popup ứng viên. Giải pháp duy nhất là sử dụng extension Kimpanel."
110- },
111- " Sway" : {
112- " best_setup" : [
113- " Yêu cầu Sway 1.10 trở lên." ,
114- " Biến môi trường: `XMODIFIERS=@im=fcitx` (XWayland)." ,
115- " Qt5: `QT_IM_MODULE=fcitx`." ,
116- " Qt >= 6.8.2: `QT_IM_MODULES=\" wayland;fcitx\" `."
117- ],
118- " support_info" : " Hỗ trợ text-input-v3 và zwp_input_method_v2 (từ bản 1.10+)." ,
119- " caveats" : " Qt < 6.8.2 cần `QT_IM_MODULE=fcitx` do Sway chưa hỗ trợ text-input-v2."
120- },
121- " Weston" : {
122- " best_setup" : [
123- " Đặt `GTK_IM_MODULE=fcitx` và `QT_IM_MODULE=fcitx`." ,
124- " Cấu hình `~/.config/weston.ini`:" ,
125- " [core]\n xwayland=true\n\n [input-method]\n path=/usr/bin/fcitx5"
126- ],
127- " support_info" : " Sử dụng text-input-v1 và zwp_input_method_v1." ,
128- " caveats" : " Do thiếu text-input-v3, IM module là giải pháp duy nhất cho Gtk/Qt."
129- }
130- }
131- }
132- };
20+ const selectedEnv = ref (environments [1 ]);
13321
13422const activateServerCode = computed (() => {
13523 if (selectedDistro .value === ' NixOS' ) return ' # Bước này đã được cấu hình trong flake.nix ở trên.' ;
@@ -153,7 +41,16 @@ const serverCmd = computed(() => {
15341});
15442
15543const envCmd = computed (() => {
156- let vars = [];
44+ // Default for X11 and other Wayland DEs
45+ const defaultVars = [
46+ " export GTK_IM_MODULE=fcitx" ,
47+ " export QT_IM_MODULE=fcitx" ,
48+ " export XMODIFIERS=@im=fcitx" ,
49+ " export SDL_IM_MODULE=fcitx" ,
50+ " export GLFW_IM_MODULE=ibus"
51+ ];
52+
53+ let vars;
15754
15855 if (selectedEnv .value === ' Wayland' ) {
15956 if (selectedDe .value === ' KDE Plasma' ) {
@@ -169,24 +66,10 @@ const envCmd = computed(() => {
16966 " export GLFW_IM_MODULE=ibus"
17067 ];
17168 } else {
172- // Weston & others default
173- vars = [
174- " export GTK_IM_MODULE=fcitx" ,
175- " export QT_IM_MODULE=fcitx" ,
176- " export XMODIFIERS=@im=fcitx" ,
177- " export SDL_IM_MODULE=fcitx" ,
178- " export GLFW_IM_MODULE=ibus"
179- ];
69+ vars = defaultVars ;
18070 }
18171 } else {
182- // X11
183- vars = [
184- " export GTK_IM_MODULE=fcitx" ,
185- " export QT_IM_MODULE=fcitx" ,
186- " export XMODIFIERS=@im=fcitx" ,
187- " export SDL_IM_MODULE=fcitx" ,
188- " export GLFW_IM_MODULE=ibus"
189- ];
72+ vars = defaultVars ;
19073 }
19174
19275 if (selectedShell .value === ' Bash' ) {
@@ -219,54 +102,26 @@ const copyToClipboard = async (text: string) => {
219102};
220103
221104const installStepCode = computed (() => {
222- return logic .steps .install [selectedDistro .value ][selectedMethod .value ];
105+ const distroInfo = logic .steps .install [selectedDistro .value as keyof typeof logic .steps .install ];
106+ if (! distroInfo ) return ' Cấu hình chưa sẵn sàng.' ;
107+ return (distroInfo as any )[selectedMethod .value ] || ' Phương thức chưa sẵn sàng.' ;
223108});
224109
225- const autostartText = computed (() => logic .steps .autostart [selectedDe .value ]);
226-
227- const waylandExtras = computed (() => {
228- if (selectedEnv .value !== ' Wayland' ) return [];
229- const compositor = selectedDe .value ;
230- const extras: any [] = [];
110+ const autostartText = computed (() => logic .steps .autostart [selectedDe .value as keyof typeof logic .steps .autostart ]);
231111
232- if (compositor === ' KDE Plasma' ) {
233- extras .push ({
234- title: " KDE Plasma (Virtual Keyboard)" ,
235- desc: " Kích hoạt giao thức text-input:" ,
236- instruction: " System Settings → Keyboard → Virtual Keyboard → Chọn Fcitx 5"
237- });
238- } else if (compositor === ' Hyprland' ) {
239- extras .push ({
240- title: " Hyprland Support" ,
241- desc: " Thêm quyền hạn cho bộ gõ:" ,
242- code: " permission = fcitx5-lotus-server, keyboard, allow"
243- });
244- }
245-
246- // Common for Chrome/Electron on Wayland
247- extras .push ({
248- title: " Chromium / Electron" ,
249- desc: " Bật hỗ trợ bộ gõ Wayland:" ,
250- code: " --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3"
251- });
112+ // Wayland Logic
113+ const waylandGeneral = computed (() => {
114+ if (selectedEnv .value !== ' Wayland' ) return null ;
115+ return logic .steps .wayland_extras .General ;
116+ });
252117
253- return extras ;
118+ const waylandDeSpecific = computed (() => {
119+ if (selectedEnv .value !== ' Wayland' ) return null ;
120+ return (logic .steps .wayland_extras as any )[selectedDe .value ] || null ;
254121});
255122
256- const fcitx5Config = {
257- steps: [
258- ' Mở <b>Fcitx5 Configuration</b> (tìm trong menu hoặc chạy <code>fcitx5-configtool</code>).' ,
259- ' Tìm <b>Lotus</b> ở cột bên phải.' ,
260- ' Nhấn mũi tên <b><</b> để thêm nó sang cột bên trái.' ,
261- ' Bấm <b>Apply</b> để lưu thay đổi.'
262- ]
263- };
123+ const chromiumWaylandFlags = " --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --wayland-text-input-version=3" ;
264124
265- const kanataConfig = {
266- title: " Cấu hình Kanata" ,
267- desc: " Nếu dùng Kanata, hãy loại bỏ Uinput Server khỏi danh sách quét:" ,
268- code: " (defcfg\n ...\n linux-dev-names-exclude (\" Lotus-Uinput-Server\" )\n ...\n )"
269- };
270125 </script >
271126
272127<template >
@@ -389,7 +244,6 @@ const kanataConfig = {
389244 <pre ><code >{{ shellConfigCode }}</code ></pre >
390245 <el-button class =" copy-float" circle :icon =" DocumentCopy" @click =" copyToClipboard(shellConfigCode)" />
391246 </div >
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" />
393247 </div >
394248 </div >
395249
@@ -408,6 +262,7 @@ const kanataConfig = {
408262 <p class =" instruction mt-2" style =" font-size : 0.85rem " >
409263 * Lưu ý: Hãy tắt autostart của IBus (thường là ibus-daemon hoặc ibus). Tốt nhất là gỡ cài đặt IBus nếu không sử dụng.
410264 </p >
265+ <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" class =" mt-4" />
411266 </div >
412267 </div >
413268
@@ -453,14 +308,50 @@ const kanataConfig = {
453308
454309 <!-- Wayland Extras -->
455310 <div v-if =" selectedEnv === 'Wayland'" >
456- <div v-for =" (item, idx) in waylandExtras" :key =" idx" class =" extra-item mb-4" >
457- <p class =" instruction" ><b >{{ item.title }}:</b > {{ item.desc }}</p >
458- <div v-if =" item.code" class =" code-container mini" >
459- <pre ><code >{{ item.code }}</code ></pre >
460- <el-button class =" copy-float" circle :icon =" DocumentCopy" size =" small" @click =" copyToClipboard(item.code)" />
311+ <!-- General Recommendation -->
312+ <div v-if =" waylandGeneral" class =" extra-item mb-4" >
313+ <el-alert
314+ :title =" waylandGeneral.title"
315+ type =" info"
316+ :closable =" false"
317+ show-icon
318+ >
319+ <p style =" margin : 0 ; line-height : 1.5 ;" >{{ waylandGeneral.description }}</p >
320+ </el-alert >
321+ </div >
322+
323+ <!-- DE Specific Setup -->
324+ <div v-if =" waylandDeSpecific" class =" wayland-setup-section mb-6" >
325+ <h5 class =" mb-2" >{{ selectedDe }} Wayland Configuration</h5 >
326+
327+ <div class =" wayland-details p-4" >
328+ <p class =" instruction mb-2" ><b >Thành phần hỗ trợ:</b > {{ waylandDeSpecific.support_info }}</p >
329+
330+ <div v-if =" waylandDeSpecific.best_setup && waylandDeSpecific.best_setup.length > 0" >
331+ <p class =" instruction" ><b >Hướng dẫn cài đặt tốt nhất:</b ></p >
332+ <ul class =" setup-list-mini" >
333+ <li v-for =" (point, idx) in waylandDeSpecific.best_setup" :key =" idx" >{{ point }}</li >
334+ </ul >
335+ </div >
336+
337+ <el-alert
338+ v-if =" waylandDeSpecific.caveats"
339+ title =" Lưu ý"
340+ type =" warning"
341+ :closable =" false"
342+ class =" mt-2"
343+ >
344+ <p style =" margin : 0 ; line-height : 1.4 ; font-size : 0.85rem ;" >{{ waylandDeSpecific.caveats }}</p >
345+ </el-alert >
461346 </div >
462- <div v-else class =" ui-nav-container" >
463- {{ item.instruction }}
347+ </div >
348+
349+ <!-- Chromium Flags (Common) -->
350+ <div class =" extra-item mb-4" >
351+ <p class =" instruction" ><b >Chromium / Electron:</b > Bật hỗ trợ bộ gõ Wayland:</p >
352+ <div class =" code-container mini" >
353+ <pre ><code >{{ chromiumWaylandFlags }}</code ></pre >
354+ <el-button class =" copy-float" circle :icon =" DocumentCopy" size =" small" @click =" copyToClipboard(chromiumWaylandFlags)" />
464355 </div >
465356 </div >
466357 </div >
@@ -619,7 +510,7 @@ const kanataConfig = {
619510 font-weight : 700 ;
620511}
621512
622- .distro-card v-icon {
513+ .distro-card svg {
623514 flex-shrink : 0 ;
624515}
625516
@@ -771,7 +662,15 @@ code {
771662 font-weight : 600 ;
772663}
773664
774- .mb-4 { margin-bottom : 1.5rem ; }
665+ :deep(.el-alert__description ) {
666+ color : var (--ctp-text ) !important ;
667+ }
668+
669+ /* Utility Classes */
670+ .mb-2 { margin-bottom : 0.5rem ; }
671+ .mb-3 { margin-bottom : 0.75rem ; }
672+ .mb-4 { margin-bottom : 1rem ; }
673+ .mb-6 { margin-bottom : 1.5rem ; }
775674.mt-2 { margin-top : 0.5rem ; }
776675
777676.wayland-setup-section {
@@ -821,7 +720,6 @@ code {
821720.info-item strong {
822721 color : var (--ctp-text );
823722}
824- .mb-4 { margin-bottom : 1rem ; }
825723
826724.ui-nav-container {
827725 background-color : var (--ctp-mantle );
0 commit comments