From 4fbd67f1dcd45717330d1d6fb4d5ac94e1a80b27 Mon Sep 17 00:00:00 2001 From: Shingo Date: Thu, 29 Aug 2024 10:12:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20processor.lua=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20iOS=20(#1003)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化候选词写入记录文件, 支持 iOS --- lua/cold_word_drop/processor.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lua/cold_word_drop/processor.lua b/lua/cold_word_drop/processor.lua index 435513c..3bb304b 100644 --- a/lua/cold_word_drop/processor.lua +++ b/lua/cold_word_drop/processor.lua @@ -3,19 +3,18 @@ require("cold_word_drop.metatable") local processor = {} local function get_record_filername(record_type) + local path_sep = "/" + local user_data_dir = rime_api:get_user_data_dir() local user_distribute_name = rime_api:get_distribution_code_name() - if user_distribute_name:lower():match("weasel") then - return string.format("%s\\lua\\cold_word_drop\\%s_words.lua", rime_api:get_user_data_dir(), record_type) - elseif user_distribute_name:lower():match("squirrel") then - return string.format("%s/lua/cold_word_drop/%s_words.lua", rime_api:get_user_data_dir(), record_type) - elseif user_distribute_name:lower():match("fcitx") then - return string.format("%s/lua/cold_word_drop/%s_words.lua", rime_api:get_user_data_dir(), record_type) - elseif user_distribute_name:lower():match("ibus") then - return string.format( - "%s/rime/lua/cold_word_drop/%s_words.lua", + if user_distribute_name:lower():match("weasel") then path_sep = "\\" end + if user_distribute_name:lower():match("ibus") then + return string.format("%s/rime/lua/cold_word_records/%s_words.lua", os.getenv("HOME") .. "/.config/ibus", record_type ) + else + local file_path = string.format("%s/lua/cold_word_records/%s_words.lua", user_data_dir, record_type) + return file_path:gsub("/", path_sep) end end