refactor: add animation utility

This commit is contained in:
JuanZoran
2023-01-31 22:29:40 +08:00
parent 59f29f5a33
commit 50ff4980ef
8 changed files with 208 additions and 170 deletions

View File

@@ -28,10 +28,10 @@ end
--- this is a nice plugin
---返回一个channel
---@param word string
---@return function
---@return table
return function(word)
local query = get_field(word)
local result
local result = {}
post(uri, {
data = query,
@@ -39,26 +39,21 @@ return function(word)
content_type = "application/x-www-form-urlencoded",
},
callback = function(str)
if result then
return
elseif str ~= '' then
local res = vim.fn.json_decode(str)
if res and res.trans_result then
result = {
word = word,
translation = res.trans_result[1].dst,
}
local res = vim.json.decode(str)
if res and res.trans_result then
result.value = {
word = word,
translation = res.trans_result[1].dst,
}
else
result = false
if result.callback then
result.callback(result.value)
end
else
result = false
result.value = false
end
end,
})
return function()
return result
end
return result
end