|
@@ -9,6 +9,7 @@ use app\common\model\Area; |
|
@@ -9,6 +9,7 @@ use app\common\model\Area; |
9
|
use app\common\model\Version;
|
9
|
use app\common\model\Version;
|
10
|
use fast\Random;
|
10
|
use fast\Random;
|
11
|
use think\Config;
|
11
|
use think\Config;
|
|
|
12
|
+use think\Hook;
|
12
|
|
13
|
|
13
|
/**
|
14
|
/**
|
14
|
* 公共接口
|
15
|
* 公共接口
|
|
@@ -30,10 +31,28 @@ class Common extends Api |
|
@@ -30,10 +31,28 @@ class Common extends Api |
30
|
if ($version = $this->request->request('version')) {
|
31
|
if ($version = $this->request->request('version')) {
|
31
|
$lng = $this->request->request('lng');
|
32
|
$lng = $this->request->request('lng');
|
32
|
$lat = $this->request->request('lat');
|
33
|
$lat = $this->request->request('lat');
|
|
|
34
|
+
|
|
|
35
|
+ //配置信息
|
|
|
36
|
+ $upload = Config::get('upload');
|
|
|
37
|
+ //如果非服务端中转模式需要修改为中转
|
|
|
38
|
+ if ($upload['storage'] != 'local' && isset($upload['uploadmode']) && $upload['uploadmode'] != 'server') {
|
|
|
39
|
+ //临时修改上传模式为服务端中转
|
|
|
40
|
+ set_addon_config($upload['storage'], ["uploadmode" => "server"], false);
|
|
|
41
|
+
|
|
|
42
|
+ $upload = \app\common\model\Config::upload();
|
|
|
43
|
+ // 上传信息配置后
|
|
|
44
|
+ Hook::listen("upload_config_init", $upload);
|
|
|
45
|
+
|
|
|
46
|
+ $upload = Config::set('upload', array_merge(Config::get('upload'), $upload));
|
|
|
47
|
+ }
|
|
|
48
|
+
|
|
|
49
|
+ $upload['cdnurl'] = $upload['cdnurl'] ? $upload['cdnurl'] : cdnurl('', true);
|
|
|
50
|
+ $upload['uploadurl'] = $upload['bucket'] == 'local' ? cdnurl('/api/common/upload', true) : url($upload['uploadurl'], '', false, true);
|
|
|
51
|
+
|
33
|
$content = [
|
52
|
$content = [
|
34
|
'citydata' => Area::getCityFromLngLat($lng, $lat),
|
53
|
'citydata' => Area::getCityFromLngLat($lng, $lat),
|
35
|
'versiondata' => Version::check($version),
|
54
|
'versiondata' => Version::check($version),
|
36
|
- 'uploaddata' => Config::get('upload'),
|
55
|
+ 'uploaddata' => $upload,
|
37
|
'coverdata' => Config::get("cover"),
|
56
|
'coverdata' => Config::get("cover"),
|
38
|
];
|
57
|
];
|
39
|
$this->success('', $content);
|
58
|
$this->success('', $content);
|