Skip to content

Commit

Permalink
- 处理多语言
Browse files Browse the repository at this point in the history
  • Loading branch information
slowlyo committed Nov 8, 2023
1 parent da581a3 commit 5c9e7d3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 59 deletions.
10 changes: 8 additions & 2 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
'order_desc' => 'Order Desc',
'order_asc' => 'Order Asc',
'menus' => 'Menus',
'successfully' => '成功',
'failed' => '失败',
'successfully' => 'Successfully',
'failed' => 'Failed',
'successfully_message' => ':attribute Successfully',
'failed_message' => ':attribute Failed',
'action_success' => 'Action Success',
Expand Down Expand Up @@ -124,6 +124,12 @@
'import_record' => 'Import Record',
'import_record_placeholder' => 'Please enter the imported json record',
'import_record_desc' => 'You can find some records shared by others on <a href="https://github.com/Slowlyo/owl-admin/discussions/categories/%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90%E8%AE%B0%E5%BD%95" target="_blank">Github</a>',
'load_config' => 'Load Config',
'load_component_config' => 'Load :c Config',
'fill' => 'Fill',
'save_current_config' => 'Save Current Config',
'input_config_name' => 'Please Input Config Name',
'same_name_tips' => 'Configurations with the same name will be overwritten',
],

'admin_users' => 'Admin Users',
Expand Down
6 changes: 6 additions & 0 deletions lang/zh_CN/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
'import_record' => '导入记录',
'import_record_placeholder' => '请输入导入的json记录',
'import_record_desc' => '你可以在 <a href="https://github.com/Slowlyo/owl-admin/discussions/categories/%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90%E8%AE%B0%E5%BD%95" target="_blank">Github</a> 找到一些其他人分享的记录',
'load_config' => '加载配置',
'load_component_config' => '加载 :c 配置',
'fill' => '填充',
'save_current_config' => '保存当前配置',
'input_config_name' => '请填写配置名称',
'same_name_tips' => '相同名称的配置将会被覆盖'
],

'admin_users' => '管理员',
Expand Down
115 changes: 58 additions & 57 deletions src/Controllers/DevTools/CodeGeneratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public function list()
amis()->TableColumn('table_name', __('admin.code_generators.table_name')),
amis()->TableColumn('updated_at', __('admin.updated_at'))->sortable(),
$this->rowActions([
amis()
->AjaxAction()
amis()->AjaxAction()
->label(__('admin.code_generators.generate_code'))
->level('link')
->confirmText(__('admin.code_generators.confirm_generate_code'))
Expand All @@ -127,15 +126,13 @@ public function list()
])
)
->icon('fa fa-code'),
amis()
->DialogAction()
amis()->DialogAction()
->label(__('admin.code_generators.copy_record'))
->icon('fa fa-copy')
->level('link')
->dialog(
amis()->Dialog()->title(false)->body(
amis()
->Form()
amis()->Form()
->initApi('post:/dev_tools/code_generator/get_record?id=${id}')
->mode('normal')
->body(
Expand All @@ -146,23 +143,20 @@ public function list()
),
)->actions([
amis()->VanillaAction()->actionType('cancel')->label(__('admin.cancel')),
amis()
->CopyAction()
amis()->CopyAction()
->label(__('admin.copy'))
->level('success')
->content('${ENCODEJSON(record)}'),
])
),
amis()
->DialogAction()
amis()->DialogAction()
->label(__('admin.code_generators.preview'))
->icon('fa fa-eye')
->level('link')
->dialog(
$this->previewCodeDialog()
),
amis()
->DialogAction()
amis()->DialogAction()
->label(__('admin.edit'))
->icon('fa-regular fa-pen-to-square')
->level('link')
Expand Down Expand Up @@ -712,59 +706,66 @@ public function getPropertyOptions(Request $request)
]);

$cacheAction = amis()->Flex()->justify('start')->items([
amis()->DialogAction()->className('mr-3')->label('加载配置')->level('primary')->dialog(
amis()->Dialog()
->title("加载{$request->c}配置")
->actions([])
->id('load_config_dialog')
->closeOnOutside()
->body(
amis()->Service()
->name('component_property_list_service')
->api('post:/dev_tools/code_generator/component_property/list?key=' . $comboName . '&c=' . $request->c)
->body(
amis()->Table()->source('${component_property_list}')->columns([
amis()->TableColumn('label'),

amis()->Operation()->buttons([
amis()->VanillaAction()->label('填充')->level('primary')->onEvent([
'click' => [
'actions' => [
[
'actionType' => 'setValue',
'componentId' => $comboId,
'args' => ['value' => '${value}',],
],
[
'actionType' => 'closeDialog',
'componentId' => 'load_config_dialog',
amis()->DialogAction()
->className('mr-3')
->label(__('admin.code_generators.load_config'))
->level('primary')
->dialog(
amis()->Dialog()
->title(__('admin.code_generators.load_component_config', ['c' => $request->c]))
->actions([])
->id('load_config_dialog')
->closeOnOutside()
->body(
amis()->Service()
->name('component_property_list_service')
->api('post:/dev_tools/code_generator/component_property/list?key=' . $comboName . '&c=' . $request->c)
->body(
amis()->Table()->source('${component_property_list}')->columns([
amis()->TableColumn('label'),

amis()->Operation()->buttons([
amis()->VanillaAction()
->label(__('admin.code_generators.fill'))
->level('primary')
->onEvent([
'click' => [
'actions' => [
[
'actionType' => 'setValue',
'componentId' => $comboId,
'args' => ['value' => '${value}',],
],
[
'actionType' => 'closeDialog',
'componentId' => 'load_config_dialog',
],
],
],
],
],
]),

amis()->AjaxAction()
->label('删除')
->level('danger')
->confirmText(__('admin.confirm_delete'))
->reload('component_property_list_service')
->api('post:/dev_tools/code_generator/component_property/del?name=' . $comboName),
])->set('width', 150),
])
)
)
),
]),

amis()->AjaxAction()
->label(__('admin.delete'))
->level('danger')
->confirmText(__('admin.confirm_delete'))
->reload('component_property_list_service')
->api('post:/dev_tools/code_generator/component_property/del?name=' . $comboName),
])->set('width', 150),
])
)
)
),

amis()->DialogAction()->label('保存当前配置')->level('success')->dialog(
amis()->Dialog()->title('保存当前配置')->body(
amis()->DialogAction()->label(__('admin.code_generators.save_current_config'))->level('success')->dialog(
amis()->Dialog()->title(__('admin.code_generators.save_current_config'))->body(
amis()->Form()->mode('normal')->api('post:/dev_tools/code_generator/component_property')->body([
amis()->HiddenControl('key')->value($comboName),
amis()->ComboControl('value')->items([
amis()->TextControl('label')
->inline(false)
->required()
->placeholder('请输入组件配置名称')
->description('相同名称的配置将会被覆盖'),
->placeholder(__('admin.code_generators.input_config_name'))
->description(__('admin.code_generators.same_name_tips')),
amis()->HiddenControl('key')->value($request->c),
amis()->HiddenControl('value')->value('${' . $comboName . '}'),
]),
Expand Down

0 comments on commit 5c9e7d3

Please sign in to comment.