修改插件前台路由格式
This commit is contained in:
parent
e69f9f819a
commit
02855c5fb3
|
|
@ -107,18 +107,6 @@ function shop_route($route, $params = []): string
|
|||
return route('shop.' . $route, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件链接
|
||||
*
|
||||
* @param $route
|
||||
* @param mixed $params
|
||||
* @return string
|
||||
*/
|
||||
function plugin_route($route, $params = []): string
|
||||
{
|
||||
return route('plugin.' . $route, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 category, product, brand, page, static, custom 路由链接
|
||||
*
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class PluginServiceProvider extends ServiceProvider
|
|||
$pluginBasePath = $this->pluginBasePath;
|
||||
$shopRoutePath = "{$pluginBasePath}/{$pluginCode}/Routes/shop.php";
|
||||
if (file_exists($shopRoutePath)) {
|
||||
Route::prefix('plugin')
|
||||
Route::name('shop.')
|
||||
->middleware('shop')
|
||||
->group(function () use ($shopRoutePath) {
|
||||
$this->loadRoutesFrom($shopRoutePath);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Bootstrap
|
|||
add_filter('menu.content', function ($data) {
|
||||
$data[] = [
|
||||
'name' => trans('LatestProducts::header.latest_products'),
|
||||
"link" => plugin_route('latest_products'),
|
||||
"link" => shop_route('latest_products'),
|
||||
];
|
||||
return $data;
|
||||
}, 0);
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@
|
|||
use Illuminate\Support\Facades\Route;
|
||||
use Plugin\LatestProducts\Controllers\MenusController;
|
||||
|
||||
Route::get('/latest_products', [MenusController::class, 'latestProducts'])->name('plugin.latest_products');
|
||||
Route::get('/latest_products', [MenusController::class, 'latestProducts'])->name('latest_products');
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
// Call your server to set up the transaction
|
||||
createOrder: function (data, actions) {
|
||||
const token = $('meta[name="csrf-token"]').attr('content')
|
||||
return fetch('/plugin/paypal/create', {
|
||||
return fetch('/paypal/create', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-Token': token
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
// Call your server to finalize the transaction
|
||||
onApprove: function (data, actions) {
|
||||
const token = $('meta[name="csrf-token"]').attr('content')
|
||||
return fetch('/plugin/paypal/capture', {
|
||||
return fetch('/paypal/capture', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-Token': token
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class ShopSocialController extends Controller
|
|||
$config = [
|
||||
'client_id' => $providerSetting['key'],
|
||||
'client_secret' => $providerSetting['secret'],
|
||||
'redirect' => plugin_route('social.callback', $provider),
|
||||
'redirect' => shop_route('social.callback', $provider),
|
||||
];
|
||||
Config::set("services.{$provider}", $config);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
use Illuminate\Support\Facades\Route;
|
||||
use Plugin\Social\Controllers\ShopSocialController;
|
||||
|
||||
Route::get('/social/redirect/{provider}', [ShopSocialController::class, 'redirect'])->name('plugin.social.redirect');
|
||||
Route::get('/social/callbacks/{provider}', [ShopSocialController::class, 'callback'])->name('plugin.social.callback');
|
||||
Route::get('/social/redirect/{provider}', [ShopSocialController::class, 'redirect'])->name('social.redirect');
|
||||
Route::get('/social/callbacks/{provider}', [ShopSocialController::class, 'callback'])->name('social.callback');
|
||||
|
|
|
|||
|
|
@ -173,13 +173,13 @@
|
|||
},
|
||||
|
||||
providerChange(e, index) {
|
||||
this.form.social[index].callback = `{{ shop_route('home.index') }}/plugin/social/callbacks/${e}`
|
||||
this.form.social[index].callback = `{{ shop_route('home.index') }}/social/callbacks/${e}`
|
||||
},
|
||||
|
||||
addRow() {
|
||||
let providers = this.source.providers.filter(e => !this.form.social.some(s => s.provider == e.code))
|
||||
if (providers.length) {
|
||||
this.form.social.push({provider: providers[0].code, status: 1, key: '', secret: '', callback: `{{ shop_route('home.index') }}/plugin/social/callbacks/${this.source.providers[0].code}`, sort_order: this.form.social.length})
|
||||
this.form.social.push({provider: providers[0].code, status: 1, key: '', secret: '', callback: `{{ shop_route('home.index') }}/social/callbacks/${this.source.providers[0].code}`, sort_order: this.form.social.length})
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<button type="button" class="btn border fw-bold w-100 mb-3" class="provider-btn" onclick="bk.openWin('{{ plugin_route('social.redirect', $provider['provider']) }}')">
|
||||
<button type="button" class="btn border fw-bold w-100 mb-3" class="provider-btn" onclick="bk.openWin('{{ shop_route('social.redirect', $provider['provider']) }}')">
|
||||
<img src="{{ plugin_resize('social' , '/image/' . $provider['provider'] . '.png') }}" class="img-fluid wh-20 me-2">
|
||||
{{ __("Social::providers.".$provider['provider']) }}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@
|
|||
use Illuminate\Support\Facades\Route;
|
||||
use Plugin\Stripe\Controllers\StripeController;
|
||||
|
||||
Route::post('/stripe/capture', [StripeController::class, 'capture'])->name('plugin.stripe_capture');
|
||||
Route::post('/stripe/capture', [StripeController::class, 'capture'])->name('stripe_capture');
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
$http.post(`/plugin/stripe/capture`, this.form).then((res) => {
|
||||
$http.post(`/stripe/capture`, this.form).then((res) => {
|
||||
layer.msg(res.message)
|
||||
console.log(res)
|
||||
location = "{{ shop_route('account.order.show', ['number' => $order->number]) }}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue