refactor: begin to try to refactor frontend part
This commit is contained in:
@@ -56,6 +56,7 @@ return {
|
||||
'definition',
|
||||
},
|
||||
spinner = 'dots', -- see: /lua/Trans/style/spinner
|
||||
fallback_message = '翻译超时或没有找到相关的翻译' -- TODO :support replace with {{special word}}
|
||||
},
|
||||
},
|
||||
style = {
|
||||
|
@@ -65,14 +65,6 @@ local function set_result(data)
|
||||
end
|
||||
|
||||
|
||||
local function render_window(data)
|
||||
-- TODO :
|
||||
vim.pretty_print(data)
|
||||
print('begin to render window')
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- HACK : Core process logic
|
||||
local function process(opts)
|
||||
Trans.translate = coroutine.wrap(process)
|
||||
@@ -82,8 +74,8 @@ local function process(opts)
|
||||
|
||||
-- Find in cache
|
||||
if Trans.cache[str] then
|
||||
local data = Trans.cache[opts.str]
|
||||
render_window(data)
|
||||
local data = Trans.cache[str]
|
||||
data.frontend:process(data)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -101,7 +93,7 @@ local function process(opts)
|
||||
if success == false then return end
|
||||
|
||||
Trans.cache[data.str] = data
|
||||
render_window(data)
|
||||
data.frontend:process(data)
|
||||
end
|
||||
|
||||
return coroutine.wrap(process)
|
||||
|
Reference in New Issue
Block a user