ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,73 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package GeoIP Data for Magento 2 (System)
*/
/**
* @var \Amasty\Geoip\Block\Adminhtml\Settings\DownloadNImport $block
*/
?>
<div class="amgeoip-import-container" data-bind="scope: 'import'">
<div class="amgeoip-progressbar-container">
<span class="amgeoip-state -done"
data-bind="css: {'-done': downloadStarted() || initialStatus}">
<?= $block->escapeHtml(__("Download")) ?>
</span>
<span class="amgeoip-state -import"
data-bind="css: {'-done': isDownloadCompleted()}">
<?= $block->escapeHtml(__("Import")) ?>
</span>
<span class="amgeoip-state -endimport"
data-bind="css: {'-done': importDone()}">
<?= $block->escapeHtml(__("Completed")) ?>
</span>
<div class="amgeoip-download-container">
<span class="amgeoip-counter -hidden"
data-bind="attr: {'data-count': downloadCounter}, style: {left: downloadStatusWidth() + '%'}, css: {'-hidden': !isShowDownloadCounter()}"></span>
<span class="amgeoip-begin -done" data-bind="css: {'-done': downloadStarted() || initialStatus}"></span>
<div class="amgeoip-line-container">
<div class="amgeoip-line" data-bind="style: {width: downloadStatusWidth() + '%'}"></div>
</div>
</div>
<div class="amgeoip-download-state -download">
<span class="amgeoip-label -import <?= $block->escapeHtml($block->getCompletedClass()) ?>"
data-bind="css: {'-completed': isDownloadCompleted()}"></span>
<div class="amgeoip-line-container">
<span class="amgeoip-counter -hidden"
data-bind="
attr: {'data-count': importCounter},
style: {left: importStatusWidth() + '%'},
css: {'-hidden': !isShowImportCounter()}">
</span>
<div class="amgeoip-line" data-bind="style: {width: importStatusWidth() + '%'}" style="width: <?= (int)$block->getWidth() ?>%"></div>
</div>
<span class="<?= $block->escapeHtml($block->getImportedClass()) ?> amgeoip-label -endimport" data-bind="css: {'-completed': importDone()}"></span>
</div>
</div>
<span class="amgeoip-import-date"><?= $block->escapeHtml($block->getImportDate()) ?></span>
<p class="amgeoip-message" data-bind="text: message"></p>
<button class="action-default amgeoip-button"
type="button"
data-bind="
click: initImportAndDownload.bind($data),
attr: {title: $t('Download and Import')},
i18n: 'Download and Import'">
</button>
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": {
"components": {
"import": {
"component": "Amasty_Geoip/js/image-optimization",
"importItems": <?= /* @noEscape */ $block->getConfig(); ?>,
"initialDownloadPercent" : <?= (int)$block->getWidth() ?>
}
}
}
}
}
</script>
@@ -0,0 +1,55 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package GeoIP Data for Magento 2 (System)
*/
/**
* @var \Amasty\Geoip\Block\Adminhtml\Settings\Import $block
*/
?>
<div class="amgeoip-import-container" data-bind="scope: 'import'">
<div class="amgeoip-progressbar-container -import">
<span class="amgeoip-state -import" data-bind="css: {'-done': isDownloadCompleted()}">
<?= $block->escapeHtml(__('Import')) ?>
</span>
<span class="amgeoip-state -completed" data-bind="css: {'-done': importDone()}">
<?= $block->escapeHtml(__("Completed")) ?>
</span>
<div class="amgeoip-download-state">
<span class="amgeoip-begin -done" data-bind="css: {'-done': isDownloadCompleted()}"></span>
<div class="amgeoip-line-container">
<span class="amgeoip-counter -hidden"
data-bind="
attr: {'data-count': importCounter},
style: {left: importStatusWidth() + '%'},
css: {'-hidden': !isShowImportCounter()}"></span>
<div class="amgeoip-line"
data-bind="style: {width: importStatusWidth() + '%'}"
style="width: <?= (int)$block->getWidth() ?>%"></div>
</div>
<span class="<?= $block->escapeHtml($block->getImportedClass()) ?> amgeoip-label -endimport"
data-bind="css: {'-completed': importDone()}"></span>
</div>
</div>
<div class="amgeoip-files-container">
<div class="amgeoip-files <?= $block->getBlockFileExist() ? '-available' : '' ?>">
var/amasty/geoip/GeoLite2-City-Blocks-IPv4.csv
</div>
<div class="amgeoip-files <?= $block->getBlockV6FileExist() ? '-available' : '' ?>">
var/amasty/geoip/GeoLite2-City-Blocks-IPv6.csv
</div>
<div class="amgeoip-files <?= $block->getLocationFileExist() ? '-available' : '' ?>">
var/amasty/geoip/GeoLite2-City-Locations-en.csv
</div>
</div>
<button class="amgeoip-button action-default"
type="button"
data-bind="
disable: !initialStatus(),
click: initImport.bind($data),
i18n: 'Import',
attr: {title: $t('Import')}">
</button>
</div>
@@ -0,0 +1,2 @@
@import "module/_import";
@import "module/_variables";
+213
View File
@@ -0,0 +1,213 @@
//
// Geo Ip Import Styles
// ____________________________________________
//
// Common
// --------------------------------------------
& when (@media-common = true) {
.amgeoip-import-container {
.amgeoip-message {
color: #ff0000;
}
.amgeoip-button {
margin-top: 30px;
border: none;
border-radius: 3px;
background-color: #e3e3e3;
transition: background-color .3s ease-in;
}
.amgeoip-button:hover {
background: #ccc;
}
.amgeoip-state {
position: relative;
bottom: 8px;
padding: 0;
width: 80px;
height: 18px;
background: #fff;
color: #bbb;
vertical-align: middle;
text-align: center;
font-weight: 400;
}
.amgeoip-state.-done {
color: #514943;
font-weight: 600;
}
.amgeoip-state.-endimport {
left: 190px;
}
.amgeoip-state.-endimport.-done {
left: 184px;
}
.amgeoip-state.-import {
left: 94px;
}
}
.amgeoip-download-state {
& {
margin-left: 25px;
padding: 0 31px 0 27px;
width: 130px;
height: 28px;
}
&.-download {
position: relative;
bottom: 23px;
left: 155px;
}
.amgeoip-label {
position: relative;
z-index: 10;
padding: 14px 32px 4px 0;
}
.amgeoip-label.-import {
top: 21px;
right: 31px;
}
.amgeoip-label.-endimport {
bottom: 2px;
left: 128px;
}
}
.amgeoip-download-state,
.amgeoip-download-container {
& {
position: relative;
}
.amgeoip-begin {
position: relative;
right: 30px;
bottom: 1px;
z-index: 10;
padding-right: 33px;
padding-bottom: 28px;
background: @amgeoip-icon-step__initial__background no-repeat center;
}
.amgeoip-begin.-done {
background: @amgeoip-icon-download__background no-repeat center;
}
.amgeoip-counter {
position: absolute;
bottom: 9px;
left: 34%;
text-align: center;
}
.amgeoip-counter:before {
position: absolute;
right: ~'calc(100% - 17px)';
bottom: 0;
left: -17px;
width: 34px;
height: 21px;
background: @amgeoip-icon-counter__background no-repeat center;
content: attr(data-count);
line-height: 14px;
}
.amgeoip-counter.-hidden {
display: none;
}
}
.amgeoip-download-container {
position: relative;
left: 52px;
width: 130px;
}
.amgeoip-progressbar-container.-import {
.amgeoip-state.-completed {
top: 0;
left: 100px;
}
.amgeoip-state.-import {
top: 0;
left: 15px;
}
.amgeoip-download-container {
left: 0;
}
.amgeoip-download-state {
padding-bottom: 20px;
}
}
.amgeoip-line-container {
& {
position: relative;
top: 2px;
background: #e3e3e3;
}
.amgeoip-line {
position: relative;
height: 4px;
background-color: #2196f3;
background-size: 20px 20px;
white-space: nowrap;
}
}
.amgeoip-download-state .amgeoip-label.-failed,
.amgeoip-download-state .amgeoip-label {
background: @amgeoip-icon-step__initial__background no-repeat center;
}
.amgeoip-download-container .amgeoip-label.-completed,
.amgeoip-download-state .amgeoip-label.-completed {
background: @amgeoip-icon-step__finish__background no-repeat center;
}
.amgeoip-files-container {
& {
margin-top: 20px;
}
.amgeoip-files {
position: relative;
}
.amgeoip-files.-available {
padding-left: 25px;
}
.amgeoip-files.-available:before {
position: absolute;
top: 3px;
left: 0;
width: 16px;
height: 16px;
background: @amgeoip-icon__available no-repeat center;
content: '';
}
}
.amgeoip-import-date {
display: block;
margin-top: 15px;
color: #bbb;
}
}
@@ -0,0 +1,12 @@
//
// Geo Ip Variables
// ____________________________________________
//
// Variables
// --------------------------------------------
@amgeoip-icon-step__initial__background: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGNpcmNsZSBjeD0iMTUiIGN5PSIxNSIgcj0iMTQuNSIgZmlsbD0iI2ZmZiIgc3Ryb2tlPSIjRTNFM0UzIi8+PC9zdmc+');
@amgeoip-icon-download__background: url('data:image/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/modal/alert'
], function (Element, $, $t, message) {
'use strict';
return Element.extend({
defaults: {
importItems: [],
downloadStatusWidth: 0,
initialDownloadPercent: 0,
importStatusWidth: 0,
downloadCounter: '',
importCounter: '',
downloadStarted: false,
isDownloadCompleted: false,
initialStatus: false,
importDone: false,
isShowImportCounter: false,
isShowDownloadCounter: false,
message: '',
messages: {
upToDate: $t('GeoIp data is up-to-date.'),
error: $t('Error.')
}
},
initialize: function () {
this._super();
this.initialStatus(this.getInitialStatus());
this.downloadStatusWidth(this.initialDownloadPercent);
this.importStatusWidth(this.initialDownloadPercent);
this.importDone(this.initialStatus());
this.isDownloadCompleted(this.initialStatus());
this.downloadStep = 1;
this.urls = [];
this.isDownload = false;
},
initObservable: function () {
this._super().observe([
'downloadStatusWidth',
'downloadCounter',
'importStatusWidth',
'downloadStarted',
'isDownloadCompleted',
'importDone',
'importCounter',
'isShowImportCounter',
'isShowDownloadCounter',
'initialStatus',
'message'
]);
return this;
},
getInitialStatus: function () {
return !!this.initialDownloadPercent;
},
initImportAndDownload: function () {
this.initialStatus(false);
this.isDownloadCompleted(false);
this.importDone(false);
this.importStatusWidth(0);
this.importItems.each(function (item) {
this.runDownloading(item.start, item.process, item.commit, item.download);
}.bind(this));
},
initImport: function () {
this.importDone(false);
this.importStatusWidth(0);
this.importItems.each(function (item) {
this.run(item.start, item.process, item.commit, item.download);
}.bind(this));
},
runDownloading: function (startUrl, processUrl, commitUrl, startDownloadingUrl) {
this.isDownload = true;
this.isShowDownloadCounter(true);
this.downloadStarted(true);
this.downloadStatusWidth(30);
this.downloadCounter('0/3');
$.ajax({
url: startDownloadingUrl,
type: 'POST',
dataType: 'json',
data: { form_key: FORM_KEY }
}).done($.proxy(function (response) {
switch (response.status) {
case 'finish_downloading':
this.doneDownloading(startUrl, processUrl, commitUrl);
break;
case 'done':
this.isShowDownloadCounter(false);
this.downloadStatusWidth(100);
this.isDownloadCompleted(true);
this.importDone(true);
this.initialStatus(true);
this.importStatusWidth(100);
this.message(this.messages.upToDate);
break;
case response.error:
this.isShowDownloadCounter(false);
this.message(this.messages.error);
this.downloadStarted(false);
this.downloadStatusWidth(0);
message({ content: response.error });
break;
default:
this.isShowDownloadCounter(false);
this.downloadStarted(false);
}
}, this));
},
doneDownloading: function (startUrl, processUrl, commitUrl) {
if (this.downloadStep === 3) {
this.downloadStatusWidth(100);
this.isDownloadCompleted(true);
this.isShowDownloadCounter(false);
this.urls.each(function (type) {
this.run(type[0], type[1], type[2]);
}.bind(this));
return this.run(startUrl, processUrl, commitUrl);
}
this.downloadStatusWidth(this.downloadStep * 30);
this.downloadCounter(this.downloadStep + '/3');
this.urls.push([startUrl, processUrl, commitUrl]);
this.downloadStep++;
},
run: function (startUrl, processUrl, commitUrl) {
$.ajax({
url: startUrl,
type: 'POST',
dataType: 'json',
data: { form_key: FORM_KEY, is_download: this.isDownload }
}).done(function (response) {
if (response.status === 'started') {
this.isShowImportCounter(true);
this.importCounter('0%');
this.process(processUrl, commitUrl);
} else if (response.error) {
this.importError(response);
}
}.bind(this));
},
process: function (processUrl, commitUrl) {
$.ajax({
url: processUrl,
type: 'POST',
dataType: 'json',
data: { form_key: FORM_KEY }
}).done(function (response) {
if (response.status == 'processing') {
if (response.type === 'block') {
this.importStatusWidth(response.position);
this.importCounter(response.position + '%');
}
if (response.position == 100) {
return this.commit(commitUrl);
}
this.process(processUrl, commitUrl);
} else if (response.error) {
this.importError(response);
}
}.bind(this));
},
commit: function (commitUrl) {
$.ajax({
url: commitUrl,
type: 'POST',
dataType: 'json',
data: { form_key: FORM_KEY }
}).done(function (response) {
if (response.status == 'done') {
this.done(response);
}
}.bind(this));
},
done: function (response) {
if (response.full_import_done == 1) {
location.reload();
}
},
importError: function (response) {
this.isShowImportCounter(false);
this.message(this.messages.error);
this.importDone(false);
this.importCounter(0);
message({ content: response.error });
}
});
});