Skip to content

Commit 43ce683

Browse files
committed
1.1
1 parent a82e1cc commit 43ce683

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,12 @@
1919
"psr-4": {
2020
"DLP\\": "src/"
2121
}
22+
},
23+
"extra": {
24+
"laravel": {
25+
"providers": [
26+
"DLP\\DLPServiceProvider"
27+
]
28+
}
2229
}
2330
}

src/DLPServiceProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace DLP;
44

55
use Illuminate\Support\ServiceProvider;
6+
use Encore\Admin\Admin;
67

78
class DLPServiceProvider extends ServiceProvider
89
{
@@ -13,5 +14,9 @@ public function boot()
1314
$this->publishes([
1415
__DIR__.'/../resources/assets' => public_path('vendor/dlp/')
1516
]);
17+
18+
Admin::booting(function () {
19+
Admin::js('vendor/dlp/component.min.js');
20+
});
1621
}
1722
}

src/DLPViewer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ class DLPViewer
2222
* @param string $title 名称
2323
* @param array $select 全部选项
2424
* @param array $selected 已选择选项
25-
* @param bool $strict json严格模式
25+
* @param bool $strict json严格模式 消除json敏感字符问题
2626
*/
27-
public static function makeComponentDot(Form $form, string $column, string $title, array $select = [], array $selected = [],bool $strict = true)
27+
public static function makeComponentDot(Form $form, string $column, string $title, array $select = [], array $selected = [],bool $strict = false)
2828
{
2929
if ($strict) {
3030
$select = self::safeJson($select);
3131
$selected = self::safeJson($selected);
3232
} else {
33-
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS);
34-
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS);
33+
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
34+
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
3535
}
3636
Admin::script(<<<EOF
3737
componentDot("{$column}",JSON.parse('{$selected}'),JSON.parse('{$select}'));
@@ -47,16 +47,16 @@ public static function makeComponentDot(Form $form, string $column, string $titl
4747
* @param string $title 名称
4848
* @param array $settings 设置项
4949
* @param array $data 数据
50-
* @param bool $strict json严格模式
50+
* @param bool $strict json严格模式 消除json敏感字符问题
5151
*/
52-
public static function makeComponentLine(Form $form, string $column, string $title, array $settings = [], array $data = [], bool $strict = true)
52+
public static function makeComponentLine(Form $form, string $column, string $title, array $settings = [], array $data = [], bool $strict = false)
5353
{
5454
if($strict) {
5555
$data = self::safeJson($data);
5656
}else{
5757
$data = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
5858
}
59-
$settings = json_encode($settings, JSON_UNESCAPED_UNICODE);
59+
$settings = json_encode($settings, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
6060
Admin::script(<<<EOF
6161
componentLine("{$column}",JSON.parse('{$settings}'),JSON.parse('{$data}'));
6262
EOF

0 commit comments

Comments
 (0)