refactor: begin to try to refactor frontend part

This commit is contained in:
JuanZoran
2023-03-12 22:12:33 +08:00
parent f86ff7b615
commit 3c28af5314
6 changed files with 176 additions and 155 deletions

View File

@@ -56,6 +56,7 @@ return {
'definition',
},
spinner = 'dots', -- see: /lua/Trans/style/spinner
fallback_message = '翻译超时或没有找到相关的翻译' -- TODO :support replace with {{special word}}
},
},
style = {

View File

@@ -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)