Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-07-07 15:54:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a4e05c0b2308b45d4412e25af1b848017fb8b246
a4e05c0b
1 parent
c9d7d60f
1.临境新增字段。
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
77 deletions
app/Admin/Controllers/AdminMakeVideoController.php
app/Admin/Controllers/ImmerseController.php
app/Admin/bootstrap.php
app/Http/Controllers/V1/ImmerseController.php
app/Jobs/UserMakeImmerse.php
config/admin.php
database/migrations/2022_07_07_142650_alter_immerse3.php
app/Admin/Controllers/AdminMakeVideoController.php
View file @
a4e05c0
...
...
@@ -47,6 +47,7 @@ class AdminMakeVideoController extends AdminController
$grid
->
column
(
'feel'
,
'有感'
);
$grid
->
column
(
'weather'
,
'天气'
);
$grid
->
column
(
'huangli'
,
'黄历'
);
$grid
->
column
(
'location'
,
'此地'
);
$grid
->
column
(
'poem_id'
);
$grid
->
column
(
'temp_id'
);
$grid
->
column
(
'thumbnail'
);
...
...
@@ -136,7 +137,9 @@ class AdminMakeVideoController extends AdminController
->
when
(
2
,
function
(
Form
$form
){
$form
->
html
(
''
);
})
->
default
(
1
);
->
default
(
2
);
$form
->
text
(
'location'
,
'此地'
)
->
placeholder
(
'暂时先手动输入此地'
);
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
...
...
app/Admin/Controllers/ImmerseController.php
View file @
a4e05c0
...
...
@@ -35,6 +35,9 @@ class ImmerseController extends AdminController
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'content'
,
'有感'
);
$grid
->
column
(
'weather'
,
'天气'
);
$grid
->
column
(
'huangli'
,
'黄历'
);
$grid
->
column
(
'location'
,
'此地'
);
$grid
->
column
(
'url'
)
->
display
(
function
(
$url
){
return
"<a target='_blank' href='"
.
$url
.
"'>查看</a>"
;
});
...
...
app/Admin/bootstrap.php
View file @
a4e05c0
<?php
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Form\Field\Map
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid\Filter
;
...
...
@@ -30,3 +31,5 @@ Admin::asset()->alias('@js', '/asset/js');
Admin
::
asset
()
->
alias
(
'@css'
,
'/asset/css'
);
Column
::
extend
(
'gallery'
,
Gallery
::
class
);
//grid列扩展 - 多图浏览
Map
::
requireAssets
();
// 引入地图资源
...
...
app/Http/Controllers/V1/ImmerseController.php
View file @
a4e05c0
...
...
@@ -39,7 +39,10 @@ class ImmerseController extends Controller
'type'
=>
'required'
,
'content'
=>
'sometimes'
,
'weather'
=>
'sometimes'
,
'thumbnail'
=>
'sometimes'
,
'haungli'
=>
'sometimes'
,
'longitude'
=>
'sometimes'
,
'latitude'
=>
'sometimes'
,
'location'
=>
'sometimes'
,
]);
if
(
$validator
->
fails
()){
...
...
@@ -51,49 +54,16 @@ class ImmerseController extends Controller
$user_id
=
$request
->
user
()
->
id
;
$immerse
=
Immerse
::
query
()
->
find
(
$request
->
item_id
);
// if ($validated['type'] == 1){
// $create = Immerse::query()->create([
// 'user_id' => $user_id,
// 'title' => '',
// 'content' => $validated['content'],
// 'url' => '',
// 'type' => $validated['type'],
// 'duration' => 0,
// 'size' => 0,
// 'poem_id' => $immerse->poem_id,
// 'temp_id' => $immerse->temp_id,
// 'thumbnail' => $immerse->thumbnail,
// 'bgm' => $validated['item_url'],
// 'state' => 0
// ]);
//
// // 添加至队列
// MakeImages::dispatch($create);
// }else{
// // 视频
// $create = Immerse::query()->create([
// 'user_id' => $user_id,
// 'title' => '',
// 'content' => $validated['content'],
// 'url' => '',
// 'type' => $validated['type'],
// 'duration' => 0,
// 'size' => 0,
// 'poem_id' => $immerse->poem_id,
// 'temp_id' => $immerse->temp_id,
// 'thumbnail' => '',
// 'bgm' => $immerse->bgm,
// 'state' => 0
// ]);
//
// // 添加至队列
// MakeVideo::dispatch($create, $validated['item_url']);
// }
$create
=
Immerse
::
query
()
->
create
([
'user_id'
=>
$user_id
,
'title'
=>
''
,
'content'
=>
$validated
[
'content'
],
'weather'
=>
$validated
[
'weather'
],
'haungli'
=>
$validated
[
'haungli'
],
'longitude'
=>
$validated
[
'longitude'
],
'latitude'
=>
$validated
[
'latitude'
],
'location'
=>
$validated
[
'location'
],
'url'
=>
''
,
'type'
=>
$validated
[
'type'
],
'upload_file'
=>
$validated
[
'item_url'
],
...
...
app/Jobs/UserMakeImmerse.php
View file @
a4e05c0
...
...
@@ -486,13 +486,20 @@ class UserMakeImmerse implements ShouldQueue
}
public
function
getTextContentString
(
$font
)
public
function
getTextContentString
()
{
$components
=
$this
->
immerse
->
temp
()
->
first
()
->
components
()
->
get
();
$drawtext
=
''
;
foreach
(
$components
as
$component
)
{
$text_color
=
$component
->
text_color
??
'white'
;
$text_bg_color
=
$component
->
text_bg_color
??
'0xd0cdcc'
;
$opacity
=
$component
->
opacity
?
$component
->
opacity
/
100
:
0.5
;
$font_file
=
Storage
::
disk
(
'public'
)
->
path
(
$component
->
font_file
??
'ffmpeg/arialuni.ttf'
);
$text_bg_box
=
$component
->
text_bg_box
??
0
;
$fix_bounds
=
$component
->
fix_bounds
==
1
;
switch
(
$component
->
name
){
case
'every_poem'
:
case
'one_poem'
:
...
...
@@ -505,63 +512,54 @@ class UserMakeImmerse implements ShouldQueue
$opacity
=
$component
->
opacity
?
$component
->
opacity
/
100
:
'0.5'
;
$drawtext
.=
'drawtext="'
.
'fontfile='
.
escapeshellarg
(
$font
)
.
':'
.
'fontfile='
.
escapeshellarg
(
$font
_file
)
.
':'
.
'textfile='
.
escapeshellarg
(
$text_file
)
.
':'
.
'fontsize='
.
$this
->
calcFontSize
(
$component
->
font_size
)
.
':'
.
'fontcolor='
.
$text_color
.
'@
1.0
:'
.
'fontcolor='
.
$text_color
.
'@
'
.
$opacity
.
'
:'
.
'x='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
0
])
.
':'
.
'y='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
1
])
.
':'
.
'box=1:boxborderw='
.
$this
->
calcBorderSize
(
$component
->
font_size
)
.
':'
.
'fix_bounds='
.
$fix_bounds
.
':'
.
'box=1:boxborderw='
.
$text_bg_box
.
':'
.
'boxcolor='
.
$text_bg_color
.
'@'
.
$opacity
.
'", '
;
break
;
case
'weather'
:
$content
=
'多云'
;
$text_color
=
$component
->
text_color
??
'white'
;
$text_bg_color
=
$component
->
text_bg_color
??
'0xd0cdcc'
;
$opacity
=
$component
->
opacity
?
$component
->
opacity
/
100
:
'0.5'
;
$drawtext
.=
'drawtext="'
.
'fontfile='
.
escapeshellarg
(
$font
)
.
':'
.
'fontfile='
.
escapeshellarg
(
$font
_file
)
.
':'
.
'text='
.
escapeshellarg
(
$content
)
.
':'
.
'fontsize='
.
$this
->
calcFontSize
(
$component
->
font_size
)
.
':'
.
'fontcolor='
.
$text_color
.
'@
1.0
:'
.
'fontcolor='
.
$text_color
.
'@
'
.
$opacity
.
'
:'
.
'x='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
0
])
.
':'
.
'y='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
1
])
.
':'
.
'box=1:boxborderw='
.
$this
->
calcBorderSize
(
$component
->
font_size
)
.
':'
.
'fix_bounds='
.
$fix_bounds
.
':'
.
'box=1:boxborderw='
.
$text_bg_box
.
':'
.
'boxcolor='
.
$text_bg_color
.
'@'
.
$opacity
.
'", '
;
break
;
case
'date'
:
$content
=
Carbon
::
now
()
->
format
(
'Y年m月d日H时'
);
$text_color
=
$component
->
text_color
??
'white'
;
$text_bg_color
=
$component
->
text_bg_color
??
'0xd0cdcc'
;
$opacity
=
$component
->
opacity
?
$component
->
opacity
/
100
:
'0.5'
;
$drawtext
.=
'drawtext="'
.
'fontfile='
.
escapeshellarg
(
$font
)
.
':'
.
'fontfile='
.
escapeshellarg
(
$font
_file
)
.
':'
.
'text='
.
escapeshellarg
(
$content
)
.
':'
.
'fontsize='
.
$this
->
calcFontSize
(
$component
->
font_size
)
.
':'
.
'fontcolor='
.
$text_color
.
'@
1.0
:'
.
'fontcolor='
.
$text_color
.
'@
'
.
$opacity
.
'
:'
.
'x='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
0
])
.
':'
.
'y='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
1
])
.
':'
.
'box=1:boxborderw='
.
$this
->
calcBorderSize
(
$component
->
font_size
)
.
':'
.
'fix_bounds='
.
$fix_bounds
.
':'
.
'box=1:boxborderw='
.
$text_bg_box
.
':'
.
'boxcolor='
.
$text_bg_color
.
'@'
.
$opacity
.
'", '
;
break
;
case
'feel'
:
$content
=
$this
->
immerse
->
content
?:
'这里是发表临境有感'
;
$text_color
=
$component
->
text_color
??
'white'
;
$text_bg_color
=
$component
->
text_bg_color
??
'0xd0cdcc'
;
$opacity
=
$component
->
opacity
?
$component
->
opacity
/
100
:
'0.5'
;
$content
=
$this
->
immerse
->
content
?:
'读此一言,仿佛身临其境。'
;
$drawtext
.=
'drawtext="'
.
'fontfile='
.
escapeshellarg
(
$font
)
.
':'
.
'fontfile='
.
escapeshellarg
(
$font
_file
)
.
':'
.
'text='
.
escapeshellarg
(
$content
)
.
':'
.
'fontsize='
.
$this
->
calcFontSize
(
$component
->
font_size
)
.
':'
.
'fontcolor='
.
$text_color
.
'@
1.0
:'
.
'fontcolor='
.
$text_color
.
'@
'
.
$opacity
.
'
:'
.
'x='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
0
])
.
':'
.
'y='
.
escapeshellarg
(
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
][
1
])
.
':'
.
'box=1:boxborderw='
.
$this
->
calcBorderSize
(
$component
->
font_size
)
.
':'
.
'fix_bounds='
.
$fix_bounds
.
':'
.
'box=1:boxborderw='
.
$text_bg_box
.
':'
.
'boxcolor='
.
$text_bg_color
.
'@'
.
$opacity
.
'", '
;
break
;
}
...
...
@@ -579,14 +577,4 @@ class UserMakeImmerse implements ShouldQueue
{
return
ceil
(
$this
->
output_width
/
360
*
$width
);
}
/**
* @param $width
* @param $content
* @return float
*/
public
function
calcBorderSize
(
$width
)
{
return
ceil
(
$width
/
12
*
10
);
}
}
...
...
config/admin.php
View file @
a4e05c0
...
...
@@ -364,4 +364,17 @@ return [
// the extension files will be generated in this directory.
'dir'
=>
base_path
(
'dcat-admin-extensions'
),
],
'map'
=>
[
'provider'
=>
env
(
'MAP_PROVIDER'
),
'keys'
=>
[
'tencent'
=>
env
(
'TENCENT_MAP_API_KEY'
),
'google'
=>
env
(
'GOOGLE_API_KEY'
),
'baidu'
=>
env
(
'BAIDU_MAP_API_KEY'
),
'amap'
=>
env
(
'AMAP_API_KEY'
),
//高德地图密钥
],
],
];
...
...
database/migrations/2022_07_07_142650_alter_immerse3.php
0 → 100644
View file @
a4e05c0
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AlterImmerse3
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'immerse'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'weather'
)
->
after
(
'content'
)
->
default
(
''
)
->
comment
(
'天气'
);
$table
->
string
(
'huangli'
)
->
after
(
'weather'
)
->
default
(
''
)
->
comment
(
'黄历'
);
$table
->
string
(
'longitude'
)
->
after
(
'huangli'
)
->
default
(
''
)
->
comment
(
'经度'
);
$table
->
string
(
'latitude'
)
->
after
(
'longitude'
)
->
default
(
''
)
->
comment
(
'纬度'
);
$table
->
string
(
'location'
)
->
after
(
'latitude'
)
->
default
(
''
)
->
comment
(
'所在地'
);
});
Schema
::
table
(
'admin_make_video'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'longitude'
)
->
after
(
'huangli'
)
->
default
(
''
)
->
comment
(
'经度'
);
$table
->
string
(
'latitude'
)
->
after
(
'longitude'
)
->
default
(
''
)
->
comment
(
'纬度'
);
$table
->
string
(
'location'
)
->
after
(
'latitude'
)
->
default
(
''
)
->
comment
(
'所在地'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropColumns
(
'immerse'
,
[
'longitude'
,
'latitude'
,
'location'
]);
Schema
::
dropColumns
(
'admin_make_video'
,
[
'longitude'
,
'latitude'
,
'location'
]);
}
}
Please
register
or
login
to post a comment