From 45e133e8a47ea883b9319945f2dbf5180bfcf29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Fri, 9 May 2025 10:24:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=93=8D=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E8=A1=A8=E5=8D=95=E6=96=B9=E5=BC=8F=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=B7=BB=E5=8A=A0=E6=9A=82=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/app/devices/[id]/page.tsx | 36 ++++++ Cunkebao/pages/device/index.vue | 0 .../device/PostAddDeviceV1Controller.php | 106 +----------------- 3 files changed, 37 insertions(+), 105 deletions(-) create mode 100644 Cunkebao/pages/device/index.vue diff --git a/Cunkebao/app/devices/[id]/page.tsx b/Cunkebao/app/devices/[id]/page.tsx index 1989896a..72ec50a9 100644 --- a/Cunkebao/app/devices/[id]/page.tsx +++ b/Cunkebao/app/devices/[id]/page.tsx @@ -93,6 +93,7 @@ export default function DeviceDetailPage() { momentsSync: false, aiChat: false }) + const [tabChangeLoading, setTabChangeLoading] = useState(false) useEffect(() => { if (!params.id) return @@ -330,6 +331,9 @@ export default function DeviceDetailPage() { const handleTabChange = (value: string) => { setActiveTab(value) + // 显示过渡加载状态 + setTabChangeLoading(true) + // 当切换到"关联账号"标签时,获取最新的关联微信账号信息 if (value === "accounts") { fetchRelatedAccounts() @@ -339,6 +343,11 @@ export default function DeviceDetailPage() { if (value === "history") { fetchHandleLogs() } + + // 设置短暂的延迟来关闭加载状态,模拟加载过程 + setTimeout(() => { + setTabChangeLoading(false) + }, 300) } // 处理功能开关状态变化 @@ -599,6 +608,15 @@ export default function DeviceDetailPage() { + {/* 标签切换时的加载状态 */} + {tabChangeLoading && ( +
+
+
+
加载中...
+
+
+ )}
@@ -697,6 +715,15 @@ export default function DeviceDetailPage() {
+ {/* 标签切换时的加载状态 */} + {tabChangeLoading && ( +
+
+
+
加载中...
+
+
+ )} {accountsLoading && (
@@ -781,6 +808,15 @@ export default function DeviceDetailPage() {
+ {/* 标签切换时的加载状态 */} + {tabChangeLoading && ( +
+
+
+
加载中...
+
+
+ )} {logsLoading && handleLogs.length === 0 ? (
diff --git a/Cunkebao/pages/device/index.vue b/Cunkebao/pages/device/index.vue new file mode 100644 index 00000000..e69de29b diff --git a/Server/application/cunkebao/controller/device/PostAddDeviceV1Controller.php b/Server/application/cunkebao/controller/device/PostAddDeviceV1Controller.php index 7f269c3c..5a8477c6 100644 --- a/Server/application/cunkebao/controller/device/PostAddDeviceV1Controller.php +++ b/Server/application/cunkebao/controller/device/PostAddDeviceV1Controller.php @@ -2,123 +2,19 @@ namespace app\cunkebao\controller\device; -use app\common\model\Device as DeviceModel; -use app\common\model\DeviceHandleLog as DeviceHandleLogModel; use app\cunkebao\controller\BaseController; -use library\ResponseHelper; -use library\s2\CurlHandle; -use think\Db; -use think\Validate; /** * 设备管理控制器 */ class PostAddDeviceV1Controller extends BaseController { - /** - * 验证IMEI是否已存在 - * - * @return void - * @throws \Exception - */ - protected function checkDeviceIsExist(): void - { - if ($this->request->param('imei')) { - $where = [ - 'imei' => $this->request->param('imei'), - 'companyId' => $this->getUserInfo('companyId'), - ]; - - $exist = DeviceModel::where($where)->count() > 0; - - if ($exist) { - throw new \Exception('设备IMEI已存在', 400); - } - } else { - throw new \Exception('设备IMEI不能为空', 400); - } - } - - - protected function addDeviceToS2() - { - $curl = CurlHandle::getInstant(); - - // $curl->setMethod() - } - - /** - * 添加设备 - * - * @return void - */ - protected function addDevice() - { - - $id = DeviceModel::addDevice( - $this->request->post() - ); - } - - /** - * 添加设备操作记录 - * - * @param int $deviceId - * @return void - * @throws \Exception - */ - protected function addDeviceHandleLog(int $deviceId): void - { - DeviceHandleLogModel::addLog( - [ - 'deviceId' => $deviceId, - 'content' => '添加设备', - 'userId' => $this->getUserInfo('id'), - 'companyId' => $this->getUserInfo('companyId'), - ] - ); - } - - /** - * 数据验证 - * - * @return $this - * @throws \Exception - */ - protected function dataValidate(): self - { - $validate = Validate::make([ - 'imei' => 'require|length:32', - 'memo' => 'require|/\S+/' - ]); - - if (!$validate->check($this->request->post())) { - throw new \Exception($validate->getError(), 400); - } - - return $this; - } - /** * 添加设备 * @return \think\response\Json */ public function index() { - try { - $this->dataValidate()->checkDeviceIsExist(); - - Db::startTrans(); - - $deviceId = $this->addDevice(); - $this->addDeviceHandleLog($deviceId); - - Db::commit(); - - return ResponseHelper::success(); - } catch (\Exception $e) { - Db::rollback(); - return ResponseHelper::error($e->getMessage(), $e->getCode()); - } + exit('暂未支持'); } } \ No newline at end of file