refactor: processor.lua 支持 iOS (#1003)

优化候选词写入记录文件, 支持 iOS
This commit is contained in:
Shingo 2024-08-29 10:12:11 +08:00 committed by GitHub
parent 0407f13bfd
commit 4fbd67f1dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,19 +3,18 @@ require("cold_word_drop.metatable")
local processor = {} local processor = {}
local function get_record_filername(record_type) 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() local user_distribute_name = rime_api:get_distribution_code_name()
if user_distribute_name:lower():match("weasel") then if user_distribute_name:lower():match("weasel") then path_sep = "\\" end
return string.format("%s\\lua\\cold_word_drop\\%s_words.lua", rime_api:get_user_data_dir(), record_type) if user_distribute_name:lower():match("ibus") then
elseif user_distribute_name:lower():match("squirrel") then return string.format("%s/rime/lua/cold_word_records/%s_words.lua",
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",
os.getenv("HOME") .. "/.config/ibus", os.getenv("HOME") .. "/.config/ibus",
record_type 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
end end