From ae5ccfd775087a5e6c3d32b921eb21176f363443 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 22 Apr 2025 11:48:54 +0800 Subject: [PATCH] no message --- app/Http/Controllers/Api/UsersController.php | 11 ++++---- resources/assets/js/App.vue | 25 +++++++++++++++++++ resources/assets/js/functions/eeui.js | 17 +++++++++++++ .../assets/js/pages/manage/setting/device.vue | 4 ++- resources/mobile | 2 +- 5 files changed, 52 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 3aefb4253..6aa44aadb 100755 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -2541,10 +2541,11 @@ class UsersController extends AbstractController * @apiGroup users * @apiName device__edit * - * @apiParam {Object} detail 设备信息 - * @apiParam {String} detail.app_brand 设备品牌 - * @apiParam {String} detail.app_model 设备型号 - * @apiParam {String} detail.app_os 设备操作系统 + * @apiParam {Object} detail 设备信息 + * @apiParam {String} detail.device_name 设备名称 + * @apiParam {String} detail.app_brand 设备品牌 + * @apiParam {String} detail.app_model 设备型号 + * @apiParam {String} detail.app_os 设备操作系统 * * @apiSuccess {Number} ret 返回状态码(1正确、0错误) * @apiSuccess {String} msg 返回信息(错误描述) @@ -2555,7 +2556,7 @@ class UsersController extends AbstractController User::auth(); // $detail = Base::json2array(Request::input('detail')); - $detail = array_intersect_key($detail, array_flip(['app_brand', 'app_model', 'app_os'])); + $detail = array_intersect_key($detail, array_flip([ 'device_name', 'app_brand', 'app_model','app_os'])); if (empty($detail)) { return Base::retError('参数错误'); } diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index 3cdfeb071..6337b31d1 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -208,6 +208,7 @@ export default { if (this.$isEEUiApp) { this.umengAliasTimer && clearTimeout(this.umengAliasTimer) if (this.userId > 0) { + // 给 APP 发送初始化消息 $A.eeuiAppSendMessage({ action: 'initApp', apiUrl: $A.apiUrl(''), @@ -216,6 +217,29 @@ export default { language: languageName, userAgent: window.navigator.userAgent, }); + + // 更新设备信息 + $A.eeuiAppGetDeviceInfo().then(async info => { + let deviceName = info.deviceName || info.modelName + if (info.systemName === 'Android') { + if ($A.strExists(info.modelName, info.brand)) { + deviceName = info.modelName + } else { + deviceName = info.brand + ' ' + info.model + } + } + await this.$store.dispatch("call", { + url: "users/device/edit", + data: { + device_name: deviceName, + app_brand: info.brand, + app_model: info.model, + app_os: info.systemName + ' ' + info.systemVersion, + } + }) + }).catch(console.log) + + // 设置友盟别名 this.umengAliasTimer = setTimeout(_ => { this.umengAliasTimer = null; $A.eeuiAppSendMessage({ @@ -224,6 +248,7 @@ export default { }); }, 6000) } else { + // 删除友盟别名 $A.eeuiAppSendMessage({ action: 'delUmengAlias', url: $A.apiUrl('users/umeng/alias') diff --git a/resources/assets/js/functions/eeui.js b/resources/assets/js/functions/eeui.js index f3b734463..4dae3f41d 100755 --- a/resources/assets/js/functions/eeui.js +++ b/resources/assets/js/functions/eeui.js @@ -330,6 +330,23 @@ import {languageName} from "../language"; "zh-CHT": "zh-Hant" }; return specialMappings[languageName] || languageName; + }, + + // 获取设备信息 + eeuiAppGetDeviceInfo() { + return new Promise(async (resolve, reject) => { + try { + const eeui = await $A.eeuiModulePromise(); + eeui.getDeviceInfo(result => { + if (result.status !== 'success') { + return reject({msg: result.error || "get failed"}); + } + resolve(result); + }); + } catch (e) { + reject(e); + } + }) } }); diff --git a/resources/assets/js/pages/manage/setting/device.vue b/resources/assets/js/pages/manage/setting/device.vue index 1ec2dfebc..536f39ff0 100644 --- a/resources/assets/js/pages/manage/setting/device.vue +++ b/resources/assets/js/pages/manage/setting/device.vue @@ -92,10 +92,12 @@ export default { return 'web'; }, - getName({app_brand, app_model, app_type, app_name, browser}) { + getName({app_brand, app_model, device_name, app_type, app_name, browser}) { const array = []; if (/web/i.test(app_type)) { array.push(...[browser, this.$L("浏览器")]); + } else if (device_name) { + return device_name } else if (app_brand) { array.push(...[app_brand, app_model]) } else { diff --git a/resources/mobile b/resources/mobile index a17453752..5596d130c 160000 --- a/resources/mobile +++ b/resources/mobile @@ -1 +1 @@ -Subproject commit a1745375245f66d9681d2c7ba8a1da413f351469 +Subproject commit 5596d130c5f73f0b8143a3734261f5d3df0c6410