Commit a3e54f75 by liimin

Merge branch 'feature/rework' of http://192.168.3.233:8090/monorepo/venus into feature/rework

2 parents 93d61dc9 aa939457
Showing 54 changed files with 349 additions and 270 deletions
<script lang="uts"> <script lang="uts">
// #ifdef APP // #ifdef APP
import { layoutService } from "@/services/LayoutService.uts"; import { layoutService } from "@/services/LayoutService.uts";
import { recordService } from "@/services/recorder";
// #endif // #endif
let firstBackTime = 0; let firstBackTime = 0;
...@@ -15,11 +16,11 @@ export default { ...@@ -15,11 +16,11 @@ export default {
setTimeout(() => { setTimeout(() => {
// 模拟接待开始 // 模拟接待开始
console.log("Simulating reception start..."); console.log("Simulating reception start...");
// recordService.startAudio(); recordService.startAudio();
// 模拟接待结束 // 模拟接待结束
console.log("Simulating reception end..."); console.log("Simulating reception end...");
setTimeout(() => { setTimeout(() => {
// recordService.stopAudio(); recordService.stopAudio();
}, 10_000); }, 10_000);
}, 1000); }, 1000);
}, },
......
...@@ -6,15 +6,7 @@ export async function getToken(params: UTSJSONObject): Promise<UTSJSONObject> { ...@@ -6,15 +6,7 @@ export async function getToken(params: UTSJSONObject): Promise<UTSJSONObject> {
projectName: "boutique", projectName: "boutique",
...params ...params
}; };
console.log("🚀 ~ getToken ~ data:", data); return http.fetch("dj.api.smartcarlife.recepiton.customer.oss.getToken", data, false, "dj");
try {
const d = await http.fetch("dj.api.smartcarlife.recepiton.customer.oss.getToken", data, false, "dj");
console.log("🚀 ~ getToken ~ d:", d);
return d;
} catch (error) {
console.log("🚀 ~ getToken ~ error:", error);
return {};
}
} }
export async function saveRecCustomer(params: UTSJSONObject): Promise<UTSJSONObject> { export async function saveRecCustomer(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = { const data: UTSJSONObject = {
......
<template> <template>
<view v-if="visible" class="popup-mask" @tap="close"> <view v-if="visible"
<view class="popup-box" @tap.stop=""> class="popup-mask"
<view class="popup-title"> @tap="close">
<text class="popup-title-text">{{ title }}</text> <view class="popup-box" @tap.stop="">
<view class="popup-close" @tap="close"> <view class="popup-title">
<text class="close-icon">×</text> <image class="popup-title-bg-img"
mode="aspectFill"
src="/static/images/boutique/customer-type-bg.webp" />
<text class="popup-title-text">{{ title }}</text>
<view class="popup-close" @tap="close">
<text class="close-icon">×</text>
</view>
</view>
<view class="popup-content">
<view v-for="(item, index) in list"
:key="index"
class="popup-item"
@tap="handleChoose(index)">
<view class="item-icon">
{{ (item as UTSJSONObject).icon ?? '' }}
</view>
<view class="item-text">
<text class="item-title">{{ (item as UTSJSONObject).title ?? '' }}</text>
<text class="item-describe">{{ (item as UTSJSONObject).describe ?? '' }}</text>
</view>
</view>
</view>
</view> </view>
</view>
<view class="popup-content">
<view
v-for="(item, index) in list"
:key="index"
class="popup-item"
@tap="handleChoose(index)"
>
<view class="item-icon">{{ (item as UTSJSONObject)['icon'] ?? '' }}</view>
<view class="item-text">
<text class="item-title">{{ (item as UTSJSONObject)['title'] ?? '' }}</text>
<text class="item-describe">{{ (item as UTSJSONObject)['describe'] ?? '' }}</text>
</view>
</view>
</view>
</view> </view>
</view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, defineExpose } from 'vue' import { computed, defineExpose, ref } from "vue";
const props = defineProps<{ const props = defineProps<{
list?: any[] list?: any[]
title?: string title?: string
}>() /** 受控显示,父组件传 true 即打开 */
visible?: boolean
}>();
const emit = defineEmits<{ const emit = defineEmits<{
choose: [index: number] choose: [index: number]
}>() "update:visible": [value: boolean]
}>();
const visible = ref(false) const internalVisible = ref(false);
const visible = computed((): boolean => {
if (props.visible != null) return props.visible === true;
return internalVisible.value;
});
function open(): void { function open(): void {
visible.value = true if (props.visible != null) {
emit("update:visible", true);
} else {
internalVisible.value = true;
}
} }
function close(): void { function close(): void {
visible.value = false internalVisible.value = false;
emit("update:visible", false);
} }
function handleChoose(index: number): void { function handleChoose(index: number): void {
emit('choose', index) emit("choose", index);
close() close();
} }
defineExpose({ defineExpose({
open, open,
close close
}) });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -92,9 +109,24 @@ defineExpose({ ...@@ -92,9 +109,24 @@ defineExpose({
justify-content: center; justify-content: center;
position: relative; position: relative;
flex-shrink: 0; flex-shrink: 0;
background-image: url('@/assets/images/boutique/customer-type-bg.webp'); overflow: hidden;
background-repeat: no-repeat; background-image: linear-gradient(to right, #e8f0fe, #f5f7fa);
background-size: 100% 100%; }
.popup-title-bg-img {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
pointer-events: none;
}
.popup-title .popup-title-text,
.popup-title .popup-close {
position: relative;
z-index: 1;
} }
.popup-title-text { .popup-title-text {
......
...@@ -24,17 +24,35 @@ ...@@ -24,17 +24,35 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, defineExpose } from 'vue' import { computed, ref, defineExpose } from 'vue'
const visible = ref(false) const props = defineProps<{
/** 受控显示,父组件传 true 即打开 */
visible?: boolean
}>()
const emit = defineEmits<{
'update:visible': [value: boolean]
}>()
const internalVisible = ref(false)
const version = ref('1.0.0') const version = ref('1.0.0')
const visible = computed((): boolean => {
if (props.visible != null) return props.visible === true
return internalVisible.value
})
function open(): void { function open(): void {
visible.value = true if (props.visible != null) {
emit('update:visible', true)
} else {
internalVisible.value = true
}
} }
function close(): void { function close(): void {
visible.value = false internalVisible.value = false
emit('update:visible', false)
} }
function handleCheck(): void { function handleCheck(): void {
......
...@@ -333,7 +333,6 @@ class TempRecord { ...@@ -333,7 +333,6 @@ class TempRecord {
this.timer = null; this.timer = null;
} }
} }
/** /**
* 清除已保存的录音文件 * 清除已保存的录音文件
* @param {object} options - 配置参数 * @param {object} options - 配置参数
......
...@@ -5,92 +5,92 @@ ...@@ -5,92 +5,92 @@
* - values: 分辨率 -> 值;未列出的分辨率用 baseWidth 线性缩放 * - values: 分辨率 -> 值;未列出的分辨率用 baseWidth 线性缩放
*/ */
export const LAYOUT_VARS: UTSJSONObject = { export const LAYOUT_VARS: UTSJSONObject = {
'spacingXs': { "spacingXs": {
'css': '--l-spacing-xs', "css": "--l-spacing-xs",
'values': { '1024': 8, '1174': 8, '1920': 15 } as UTSJSONObject "values": { "1024": 8, "1174": 8, "1920": 15 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'spacingSm': { "spacingSm": {
'css': '--l-spacing-sm', "css": "--l-spacing-sm",
'values': { '1024': 12, '1174': 12, '1920': 23 } as UTSJSONObject "values": { "1024": 12, "1174": 12, "1920": 23 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'spacingMd': { "spacingMd": {
'css': '--l-spacing-md', "css": "--l-spacing-md",
'values': { '1024': 16, '1174': 16, '1920': 30 } as UTSJSONObject "values": { "1024": 16, "1174": 16, "1920": 30 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'spacingLg': { "spacingLg": {
'css': '--l-spacing-lg', "css": "--l-spacing-lg",
'values': { '1024': 24, '1174': 24, '1920': 45 } as UTSJSONObject "values": { "1024": 24, "1174": 24, "1920": 45 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'spacingXl': { "spacingXl": {
'css': '--l-spacing-xl', "css": "--l-spacing-xl",
'values': { '1024': 32, '1174': 32, '1920': 60 } as UTSJSONObject "values": { "1024": 32, "1174": 32, "1920": 60 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'spacing2xl': { "spacing2xl": {
'css': '--l-spacing-2xl', "css": "--l-spacing-2xl",
'values': { '1024': 40, '1174': 40, '1920': 75 } as UTSJSONObject "values": { "1024": 40, "1174": 40, "1920": 75 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'fontXs': { "fontXs": {
'css': '--l-font-xs', "css": "--l-font-xs",
'values': { '1024': 12, '1174': 12, '1920': 23 } as UTSJSONObject "values": { "1024": 12, "1174": 12, "1920": 23 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'fontSm': { "fontSm": {
'css': '--l-font-sm', "css": "--l-font-sm",
'values': { '1024': 14, '1174': 14, '1920': 26 } as UTSJSONObject "values": { "1024": 14, "1174": 14, "1920": 26 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'fontBase': { "fontBase": {
'css': '--l-font-base', "css": "--l-font-base",
'values': { '1024': 16, '1174': 16, '1920': 30 } as UTSJSONObject "values": { "1024": 16, "1174": 16, "1920": 30 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'fontLg': { "fontLg": {
'css': '--l-font-lg', "css": "--l-font-lg",
'values': { '1024': 18, '1174': 18, '1920': 34 } as UTSJSONObject "values": { "1024": 18, "1174": 18, "1920": 34 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'fontXl': { "fontXl": {
'css': '--l-font-xl', "css": "--l-font-xl",
'values': { '1024': 20, '1174': 20, '1920': 38 } as UTSJSONObject "values": { "1024": 20, "1174": 20, "1920": 38 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'font2xl': { "font2xl": {
'css': '--l-font-2xl', "css": "--l-font-2xl",
'values': { '1024': 24, '1174': 24, '1920': 45 } as UTSJSONObject "values": { "1024": 24, "1174": 24, "1920": 45 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'radiusSm': { "radiusSm": {
'css': '--l-radius-sm', "css": "--l-radius-sm",
'values': { '1024': 4, '1174': 4, '1920': 8 } as UTSJSONObject "values": { "1024": 4, "1174": 4, "1920": 8 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'radiusMd': { "radiusMd": {
'css': '--l-radius-md', "css": "--l-radius-md",
'values': { '1024': 8, '1174': 8, '1920': 15 } as UTSJSONObject "values": { "1024": 8, "1174": 8, "1920": 15 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'radiusLg': { "radiusLg": {
'css': '--l-radius-lg', "css": "--l-radius-lg",
'values': { '1024': 12, '1174': 12, '1920': 23 } as UTSJSONObject "values": { "1024": 12, "1174": 12, "1920": 23 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'radiusXl': { "radiusXl": {
'css': '--l-radius-xl', "css": "--l-radius-xl",
'values': { '1024': 16, '1174': 16, '1920': 30 } as UTSJSONObject "values": { "1024": 16, "1174": 16, "1920": 30 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'sidebarWidth': { "sidebarWidth": {
'css': '--l-sidebar-width', "css": "--l-sidebar-width",
'values': { '1024': 120, '1174': 120, '1920': 225 } as UTSJSONObject "values": { "1024": 120, "1174": 120, "1920": 225 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'contentLeftWidth': { "contentLeftWidth": {
'css': '--l-content-left-width', "css": "--l-content-left-width",
'values': { '1024': 605, '1174': 605, '1920': 1134 } as UTSJSONObject "values": { "1024": 605, "1174": 605, "1920": 1134 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'moduleBoxHeight': { "moduleBoxHeight": {
'css': '--l-module-box-height', "css": "--l-module-box-height",
'values': { '1024': 332, '1174': 332, '1920': 623 } as UTSJSONObject "values": { "1024": 332, "1174": 332, "1920": 623 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'toolBoxMinHeight': { "toolBoxMinHeight": {
'css': '--l-tool-box-min-height', "css": "--l-tool-box-min-height",
'values': { '1024': 120, '1174': 120, '1920': 225 } as UTSJSONObject "values": { "1024": 120, "1174": 120, "1920": 225 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'commonTitleHeight': { "commonTitleHeight": {
'css': '--l-common-title-height', "css": "--l-common-title-height",
'values': { '1024': 60, '1174': 60, '1920': 113 } as UTSJSONObject "values": { "1024": 60, "1174": 60, "1920": 113 } as UTSJSONObject
} as UTSJSONObject, } as UTSJSONObject,
'storeFooterHeight': { "storeFooterHeight": {
'css': '--l-store-footer-height', "css": "--l-store-footer-height",
'values': { '1024': 60, '1174': 60, '1920': 113 } as UTSJSONObject "values": { "1024": 60, "1174": 60, "1920": 113 } as UTSJSONObject
} as UTSJSONObject } as UTSJSONObject
} };
import { createSSRApp } from "vue"; import { createSSRApp } from "vue";
import { appMixin } from "./utilsApi";
import { logger } from "./composables/logger";
import App from "./App.uvue"; import App from "./App.uvue";
import DBRecord from './composables/recorder/DBRecord.uts' import { logger } from "@/services/logger";
import DBRecord from "@/services/recorder/DBRecord.uts";
import { appMixin } from "./utilsApi";
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App);
// 挂载日志模块到 uni.$logger // 挂载日志模块到 uni.$logger
// logger.mount(); // logger.mount();
initDB() initDB();
appMixin(app); appMixin(app);
return { return {
...@@ -18,10 +19,10 @@ initDB() ...@@ -18,10 +19,10 @@ initDB()
} }
function initDB() { function initDB() {
// 数据库初始化 // 数据库初始化
DBRecord.getInstance().init().then((res): void => { DBRecord.getInstance().init().then((res): void => {
logger.info('〖数据库初始化完成〗', "Main") logger.info("〖数据库初始化完成〗", "Main");
}).catch((e): void => { }).catch((error): void => {
logger.error(`〖数据库初始化失败〗: ${e}`, "Main") logger.error(`〖数据库初始化失败〗: ${error}`, "Main");
}) });
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
```typescript ```typescript
// 直接导入单例对象和枚举 // 直接导入单例对象和枚举
import { recordService, BusinessDataType } from '@/composables/recorder/index.uts' import { recordService, BusinessDataType } from '@/services/recorder/index.uts'
``` ```
### 开始接待/录音 ### 开始接待/录音
...@@ -80,7 +80,7 @@ recordService.updateBusinessData( ...@@ -80,7 +80,7 @@ recordService.updateBusinessData(
### 3.1 定义新策略 ### 3.1 定义新策略
创建 `composables/recorder/strategies/RealEstateStrategy.uts`: 创建 `services/recorder/strategies/RealEstateStrategy.uts`:
```typescript ```typescript
import { IRecorderStrategy } from "../types/strategy.uts"; import { IRecorderStrategy } from "../types/strategy.uts";
......
import { RecordService } from '@/composables/recorder/index.uts' import { RecordService } from "@/services/recorder/index.uts";
import TempRecord from '@/composables/recorder/TempRecord.uts' import TempRecord from "@/services/recorder/TempRecord.uts";
import { RecordData } from '@/composables/recorder/types/index.uts' import { RecordData } from "@/services/recorder/types/index.uts";
import { state as storeState, commit } from '@/store/index.uts' import { commit } from "@/store/index.uts";
/** /**
* 测试 RecordService 的监听器功能 * 测试 RecordService 的监听器功能
...@@ -12,120 +12,120 @@ import { state as storeState, commit } from '@/store/index.uts' ...@@ -12,120 +12,120 @@ import { state as storeState, commit } from '@/store/index.uts'
* testRecordWatchers() * testRecordWatchers()
*/ */
export function testRecordWatchers() { export function testRecordWatchers() {
console.log('=== 开始测试 RecordService 监听器 ===') console.log("=== 开始测试 RecordService 监听器 ===");
const service = RecordService.getInstance() const service = RecordService.getInstance();
// 1. 模拟 isReceptioning 为 true,使 handler 能执行回调 // 1. 模拟 isReceptioning 为 true,使 handler 能执行回调
// 只有在接待中 (isReceptioning() == true) 才会响应状态变化 // 只有在接待中 (isReceptioning() == true) 才会响应状态变化
// 我们通过设置一个 endReasonType=1 (异常结束/暂存状态?) 的伪造记录来模拟此条件 // 我们通过设置一个 endReasonType=1 (异常结束/暂存状态?) 的伪造记录来模拟此条件
// 或者更直接地,我们可以临时覆盖 isReceptioning 方法(如果 UTS 允许) // 或者更直接地,我们可以临时覆盖 isReceptioning 方法(如果 UTS 允许)
// 方案 A: 构造伪造数据让 isReceptioning 返回 true // 方案 A: 构造伪造数据让 isReceptioning 返回 true
// isReceptioning() => (audioManager?.isRecording) || (record?.currentRecord?.endReasonType == 1) // isReceptioning() => (audioManager?.isRecording) || (record?.currentRecord?.endReasonType == 1)
const mockRecordData = { const mockRecordData = {
id: 'mock_test_id', id: "mock_test_id",
endReasonType: 1 endReasonType: 1
} as RecordData } as RecordData;
// 创建 TempRecord 实例并注入 // 创建 TempRecord 实例并注入
// 注意:TempRecord 构造函数可能依赖 uni.$dbRecord,但在测试环境下可能未初始化 // 注意:TempRecord 构造函数可能依赖 uni.$dbRecord,但在测试环境下可能未初始化
// 如果报错,可能需要 Mock DBRecord.getInstance() // 如果报错,可能需要 Mock DBRecord.getInstance()
try { try {
const mockTempRecord = new TempRecord(mockRecordData, null, null) const mockTempRecord = new TempRecord(mockRecordData, null, null);
service.record = mockTempRecord service.record = mockTempRecord;
console.log(`[Test] 注入 Mock Record, isReceptioning 当前状态: ${service.isReceptioning()}`) console.log(`[Test] 注入 Mock Record, isReceptioning 当前状态: ${service.isReceptioning()}`);
} catch (e) { } catch (error) {
console.error('[Test] 注入 Mock Record 失败:', e) console.error("[Test] 注入 Mock Record 失败:", error);
return return;
} }
// 2. Mock 目标方法以验证调用 // 2. Mock 目标方法以验证调用
// 使用 any 类型绕过类型检查进行方法覆写 (Monkey Patching) // 使用 any 类型绕过类型检查进行方法覆写 (Monkey Patching)
const serviceAny = service as any const serviceAny = service as any;
// 备份原方法,以便测试后恢复 // 备份原方法,以便测试后恢复
const originalUpdateCustomerInfo = serviceAny.updateCustomerInfo const originalUpdateCustomerInfo = serviceAny.updateCustomerInfo;
const originalUpdateReceptionStatus = serviceAny.updateReceptionStatus const originalUpdateReceptionStatus = serviceAny.updateReceptionStatus;
const originalUpdateBookList = serviceAny.updateBookList const originalUpdateBookList = serviceAny.updateBookList;
const originalUpdateMaterialPointList = serviceAny.updateMaterialPointList const originalUpdateMaterialPointList = serviceAny.updateMaterialPointList;
// 计数器 // 计数器
let customerInfoCount = 0 let customerInfoCount = 0;
let receptionStatusCount = 0 let receptionStatusCount = 0;
let bookListCount = 0 let bookListCount = 0;
let materialPointListCount = 0 let materialPointListCount = 0;
// 覆写方法 (Spy) // 覆写方法 (Spy)
serviceAny.updateCustomerInfo = (val: any) => { serviceAny.updateCustomerInfo = (val: any) => {
console.log(`[Test] updateCustomerInfo 被调用,参数: ${JSON.stringify(val)}`) console.log(`[Test] updateCustomerInfo 被调用,参数: ${JSON.stringify(val)}`);
customerInfoCount++ customerInfoCount++;
} };
serviceAny.updateReceptionStatus = (val: any) => { serviceAny.updateReceptionStatus = (val: any) => {
console.log(`[Test] updateReceptionStatus 被调用,参数: ${val}`) console.log(`[Test] updateReceptionStatus 被调用,参数: ${val}`);
receptionStatusCount++ receptionStatusCount++;
} };
serviceAny.updateBookList = (val: any) => { serviceAny.updateBookList = (val: any) => {
console.log(`[Test] updateBookList 被调用`) console.log(`[Test] updateBookList 被调用`);
bookListCount++ bookListCount++;
} };
serviceAny.updateMaterialPointList = (val: any) => { serviceAny.updateMaterialPointList = (val: any) => {
console.log(`[Test] updateMaterialPointList 被调用`) console.log(`[Test] updateMaterialPointList 被调用`);
materialPointListCount++ materialPointListCount++;
} };
// 3. 触发 Store 变化 // 3. 触发 Store 变化
console.log('[Test] 正在触发 Store 变化...') console.log("[Test] 正在触发 Store 变化...");
// --- 测试 updateCustomerInfo (debounce 1000ms) --- // --- 测试 updateCustomerInfo (debounce 1000ms) ---
// 监听的是 customerKey 变化,回调中使用 customerInfo // 监听的是 customerKey 变化,回调中使用 customerInfo
const testCustomerInfo = { customerName: '测试客户', phoneNumber: '13800000000' } const testCustomerInfo = { customerName: "测试客户", phoneNumber: "13800000000" };
commit('updateCustomerInfo', testCustomerInfo) commit("updateCustomerInfo", testCustomerInfo);
// 触发 watcher // 触发 watcher
commit('updateCustomerKey', 'KEY_' + Date.now()) commit("updateCustomerKey", `KEY_${ Date.now()}`);
// --- 测试 updateReceptionStatus (debounce 200ms) --- // --- 测试 updateReceptionStatus (debounce 200ms) ---
commit('updateReceptionStatus', '1') // 状态变更 commit("updateReceptionStatus", "1"); // 状态变更
// --- 测试 updateBookList (debounce 1500ms) --- // --- 测试 updateBookList (debounce 1500ms) ---
const testBookList = [{ id: 'book1', imgUrl: 'url1' }] const testBookList = [{ id: "book1", imgUrl: "url1" }];
commit('updateBookList', testBookList) // 数组变更可能不触发 watcher? commit("updateBookList", testBookList); // 数组变更可能不触发 watcher?
// 注意:监听的是 storeState.booksList 引用变化。commit 会替换数组,应该能触发。 // 注意:监听的是 storeState.booksList 引用变化。commit 会替换数组,应该能触发。
// --- 测试 updateMaterialPointList (debounce 1000ms) --- // --- 测试 updateMaterialPointList (debounce 1000ms) ---
// 监听 receptionKey,回调中使用 receptionTrack // 监听 receptionKey,回调中使用 receptionTrack
const testTrack = [{ id: 'point1', x: 10, y: 20 }] const testTrack = [{ id: "point1", x: 10, y: 20 }];
commit('updateReceptionTrack', testTrack) commit("updateReceptionTrack", testTrack);
// 触发 watcher // 触发 watcher
commit('updateReceptionKey', 'REC_KEY_' + Date.now()) commit("updateReceptionKey", `REC_KEY_${ Date.now()}`);
// 4. 等待 Debounce 结束 // 4. 等待 Debounce 结束
// 最长 delay 是 1500ms,我们等待 2000ms // 最长 delay 是 1500ms,我们等待 2000ms
console.log('[Test] 等待防抖结束 (2000ms)...') console.log("[Test] 等待防抖结束 (2000ms)...");
setTimeout(() => { setTimeout(() => {
console.log('=== 测试结果报告 ===') console.log("=== 测试结果报告 ===");
const check = (name: string, count: number) => { const check = (name: string, count: number) => {
const pass = count >= 1 const pass = count >= 1;
console.log(`${name}: ${pass ? 'PASS ✅' : 'FAIL ❌'} (调用次数: ${count})`) console.log(`${name}: ${pass ? "PASS ✅" : "FAIL ❌"} (调用次数: ${count})`);
} };
check('updateCustomerInfo', customerInfoCount) check("updateCustomerInfo", customerInfoCount);
check('updateReceptionStatus', receptionStatusCount) check("updateReceptionStatus", receptionStatusCount);
check('updateBookList', bookListCount) check("updateBookList", bookListCount);
check('updateMaterialPointList', materialPointListCount) check("updateMaterialPointList", materialPointListCount);
// 5. 恢复环境 // 5. 恢复环境
serviceAny.updateCustomerInfo = originalUpdateCustomerInfo serviceAny.updateCustomerInfo = originalUpdateCustomerInfo;
serviceAny.updateReceptionStatus = originalUpdateReceptionStatus serviceAny.updateReceptionStatus = originalUpdateReceptionStatus;
serviceAny.updateBookList = originalUpdateBookList serviceAny.updateBookList = originalUpdateBookList;
serviceAny.updateMaterialPointList = originalUpdateMaterialPointList serviceAny.updateMaterialPointList = originalUpdateMaterialPointList;
service.record = null // 重置 record service.record = null; // 重置 record
console.log('=== 测试结束,环境已恢复 ===') console.log("=== 测试结束,环境已恢复 ===");
}, 2000) }, 2000);
} }
// uni_modules/permission-handler-plus 根入口
export * from "./utssdk/index.uts";
// permission-handler-plus 统一入口,按平台导出实现
export type { SuccessCallBack, FailCallBack, PermissionObject } from "./interface.uts";
export { permissionStatusName, permissionIdByName, permissionNameById } from "./interface.uts";
// #ifdef APP-ANDROID
export { checkPermission, requestPermissions } from "./app-android/index.uts";
// #endif
// #ifdef APP-IOS
export { checkPermission, requestPermissions } from "./app-ios/index.uts";
// #endif
// #ifdef APP-HARMONY
export { checkPermission, requestPermissions } from "./app-harmony/index.uts";
// #endif
// #ifndef APP-ANDROID || APP-IOS || APP-HARMONY
// Web 等非 App 平台:导出 stub,避免运行时 "does not provide an export named 'checkPermission'" 报错
import type { PermissionObject } from "./interface.uts";
export function checkPermission(permission: string, complete: (result: string) => void): void {
complete("granted")
}
export function requestPermissions(permission: PermissionObject): void {
const nameMap = new Map<string, string>()
if (permission.names != null && permission.names.length > 0) {
permission.names.forEach((name: string) => {
nameMap.set(name, "granted")
})
}
permission.success(nameMap)
}
// #endif
...@@ -18,7 +18,7 @@ export default defineConfig({ ...@@ -18,7 +18,7 @@ export default defineConfig({
], ],
resolve: { resolve: {
alias: { alias: {
"@": resolve("src") "@": resolve(".")
} }
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!