methods: { ...mapMutations('m_user', ['updateAddress']), async chooseAddress() { const [err, succ] = await uni.chooseAddress().catch(err => err) if (err === null & succ.errMsg === 'chooseAddress:ok') { // this.address=succ this.updateAddress(succ) } } },
时间: 2024-04-28 07:25:32 浏览: 19
这是一个 Vue.js 中的方法,使用了 Vuex 中的 mapMutations 方法来将 m_user 模块中的 updateAddress mutation 映射到当前组件中。在 chooseAddress 方法中,使用了 async/await 来等待 uni.chooseAddress() 方法返回结果,如果结果成功则调用 updateAddress 方法将地址信息更新到 Vuex 中的状态管理中。
相关问题
async def check_connect(office_site_id: str, end_user_id: str, password: str, desktop_type: str = None, desktop_group_id: str = None, desktop_id: str = None): """ 验证桌面连接 """ from fvtdesktop.ad_user_api import AdUserApi client_id = uuid.uuid4().hex token = await AdUserApi.get_login_token(client_id=client_id, office_site_id=office_site_id, end_user_id=end_user_id, password=password, current_stage=get_current_stage()) if desktop_type == 'Desktopgroup': describe = await AdUserApi.describe_desktops(login_token=token.login_token, protocol_type='BOTH', client_id=client_id, session_id=token.session_id, office_site_id=office_site_id) desktop = list(filter(lambda x: 'desktop_group_id' in x.keys() and x['desktop_group_id'] == desktop_group_id, describe)) result = await get_ticket(desktop_id=desktop[0].desktop_id, client_id=client_id, login_token=token.login_token, session_id=token.session_id) if result == 'Again': await sleep(30) result = await get_ticket(desktop_id=desktop[0].desktop_id, client_id=client_id, login_token=token.login_token, session_id=token.session_id) assert result == 'True' else: result = await get_ticket(desktop_id=desktop_id, client_id=client_id, login_token=token.login_token, session_id=token.session_id) if result == 'Again': await sleep(30) result = await get_ticket(desktop_id=desktop_id, client_id=client_id, login_token=token.login_token, session_id=token.session_id) assert result == 'True'
这是一段 Python 代码,它定义了一个名为 "check_connect" 的异步函数(async function)。该函数的目的是验证桌面连接,它接受以下参数:office_site_id(办公地点 ID)、end_user_id(终端用户 ID)、password(密码)、desktop_type(桌面类型,默认为 None)、desktop_group_id(桌面组 ID,默认为 None)和 desktop_id(桌面 ID,默认为 None)。
函数通过调用 "AdUserApi" 中的 "get_login_token" 方法来获取登录 token。如果 "desktop_type" 等于 "Desktopgroup",则调用 "describe_desktops" 方法,获取桌面的详细信息,并过滤出 "desktop_group_id" 等于 "desktop_group_id" 参数的桌面。然后,调用 "get_ticket" 方法来获取桌面连接的票据。如果返回值为 "Again",则等待 30 秒后再次尝试获取票据。最后,使用 "assert" 语句来断言结果是否为 "True"。
如果 "desktop_type" 不等于 "Desktopgroup",则直接调用 "get_ticket" 方法来获取桌面连接的票据,并执行与上述相同的操作。
desktops = await respool.new_desktop(desktop_status=DesktopStatus.RUNNING) desktop = desktops[0] async with desktop: await sleep(60) snapshot_system = await Snapshot.create(desktop_id=desktop.desktop_id, source_disk_type=SnapshotSourceDiskType.System, wait=True) snapshot_data = await Snapshot.create(desktop_id=desktop.desktop_id, wait=True) assert snapshot_system.snapshot_id assert snapshot_data.snapshot_id # 通过snapshot_id删除快照 await Snapshot.delete(snapshot_ids=[snapshot_system.snapshot_id, snapshot_data.snapshot_id]) snapshots = await Snapshot.describe(desktop_id=desktop.desktop_id) # 防止创建时间太长有自动快照的生成 result = [sna for sna in snapshots if sna.snapshot_type == SnapshotType.User] assert len(result) == 0
这段代码的作用是创建一个新的虚拟桌面,等待 60 秒后创建两个快照(一个系统快照和一个数据快照),然后检查这两个快照是否创建成功。接着,使用快照 ID 删除这两个快照,并检查是否删除成功。最后,检查是否还有自动快照存在。如果没有自动快照存在,则表示代码执行成功。
需要注意的是,这段代码中的 `await respool.new_desktop(desktop_status=DesktopStatus.RUNNING)` 用于创建一个运行中的虚拟桌面,并将其赋值给 `desktops` 变量。然后,使用 `desktops[0]` 获取第一个虚拟桌面,并将其赋值给 `desktop` 变量。接着,使用 `async with desktop:` 异步上下文管理器来确保在代码块执行期间保持对虚拟桌面的独占访问权限。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)