REFactor => 移除安全区域相关功能,优化web-view组件样式,更新导航组件结构,简化代码逻辑。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 全屏web-view容器 -->
|
||||
<web-view :src="currentUrl" :style="webViewStyle" ref="webview" @message="handleMessage" @error="handleError"
|
||||
<web-view :src="currentUrl" class="webview" ref="webview" @message="handleMessage" @error="handleError"
|
||||
@loading="handleLoading">
|
||||
</web-view>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<view v-if="config.appConfig.debug" class="debug-info">
|
||||
<text>当前URL: {{ currentUrl }}</text>
|
||||
<text>加载状态: {{ loading ? '加载中' : '已加载' }}</text>
|
||||
<text>navBarHeight: {{ navBarHeight }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -54,24 +53,6 @@ export default {
|
||||
onUnload() {
|
||||
this.cleanup();
|
||||
},
|
||||
computed: {
|
||||
navBarHeight() {
|
||||
return (this.getSafeAreaHeight().navBarHeight || 44) + 'px'
|
||||
},
|
||||
webViewStyle() {
|
||||
const safeArea = this.getSafeAreaHeight();
|
||||
return {
|
||||
position: 'absolute',
|
||||
top: safeArea.navBarHeight + 'px',
|
||||
left: '0px',
|
||||
right: '0px',
|
||||
bottom: '0px',
|
||||
width: '100%',
|
||||
height: `calc(100vh - ${safeArea.navBarHeight}px)`,
|
||||
zIndex: 1
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 获取初始URL
|
||||
@@ -632,118 +613,6 @@ export default {
|
||||
console.log('超时已清除');
|
||||
},
|
||||
|
||||
// 获取安全区域高度
|
||||
getSafeAreaHeight() {
|
||||
|
||||
try {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
console.log('UniApp: 系统信息:', systemInfo);
|
||||
|
||||
// 安全区域信息
|
||||
const safeArea = systemInfo.safeArea || {};
|
||||
const safeAreaInsets = systemInfo.safeAreaInsets || {};
|
||||
|
||||
console.log('UniApp: 安全区域:', safeArea);
|
||||
console.log('UniApp: 安全区域边距:', safeAreaInsets);
|
||||
|
||||
// 状态栏高度
|
||||
const statusBarHeight = systemInfo.statusBarHeight || 0;
|
||||
console.log('UniApp: 状态栏高度:', statusBarHeight);
|
||||
|
||||
// 计算顶部安全区域高度
|
||||
let topSafeAreaHeight = statusBarHeight;
|
||||
|
||||
// 如果有安全区域边距信息,优先使用它
|
||||
if (safeAreaInsets.top !== undefined) {
|
||||
topSafeAreaHeight = safeAreaInsets.top;
|
||||
console.log('UniApp: 使用safeAreaInsets.top:', topSafeAreaHeight);
|
||||
} else if (safeArea.top !== undefined) {
|
||||
topSafeAreaHeight = safeArea.top;
|
||||
console.log('UniApp: 使用safeArea.top:', topSafeAreaHeight);
|
||||
} else {
|
||||
// 根据平台和设备类型计算
|
||||
topSafeAreaHeight = this.calculatePlatformSafeArea(statusBarHeight, systemInfo);
|
||||
}
|
||||
|
||||
// 返回完整的安全区域信息
|
||||
const safeAreaInfo = {
|
||||
top: topSafeAreaHeight,
|
||||
bottom: safeAreaInsets.bottom || safeArea.bottom || 0,
|
||||
left: safeAreaInsets.left || safeArea.left || 0,
|
||||
right: safeAreaInsets.right || safeArea.right || 0,
|
||||
statusBarHeight: statusBarHeight,
|
||||
navBarHeight: 44, // 导航栏高度通常是44px
|
||||
platform: systemInfo.platform,
|
||||
model: systemInfo.model,
|
||||
system: systemInfo.system,
|
||||
screenWidth: systemInfo.screenWidth,
|
||||
screenHeight: systemInfo.screenHeight
|
||||
};
|
||||
|
||||
return safeAreaInfo;
|
||||
|
||||
} catch (error) {
|
||||
console.error('UniApp: 获取安全区域信息失败:', error);
|
||||
|
||||
// 返回默认值
|
||||
return {
|
||||
top: 44,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 44,
|
||||
platform: 'unknown',
|
||||
model: 'unknown',
|
||||
system: 'unknown',
|
||||
screenWidth: 375,
|
||||
screenHeight: 667
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 根据平台计算安全区域
|
||||
calculatePlatformSafeArea(statusBarHeight, systemInfo) {
|
||||
const platform = systemInfo.platform.toLowerCase();
|
||||
const model = systemInfo.model || '';
|
||||
const screenHeight = systemInfo.screenHeight;
|
||||
const screenWidth = systemInfo.screenWidth;
|
||||
|
||||
console.log('UniApp: 平台信息:', { platform, model, screenHeight, screenWidth });
|
||||
|
||||
// iOS设备
|
||||
if (platform === 'ios') {
|
||||
// iPhone X及以后的设备(刘海屏)
|
||||
if (screenHeight >= 812 || screenWidth >= 812) {
|
||||
console.log('UniApp: 检测到iPhone X及以后设备');
|
||||
return 44; // iPhone X状态栏高度
|
||||
}
|
||||
// 传统iPhone设备
|
||||
else {
|
||||
console.log('UniApp: 检测到传统iPhone设备');
|
||||
return statusBarHeight || 20;
|
||||
}
|
||||
}
|
||||
// Android设备
|
||||
else if (platform === 'android') {
|
||||
// 高分辨率设备可能是刘海屏
|
||||
if (screenHeight >= 800 || screenWidth >= 800) {
|
||||
console.log('UniApp: 检测到高分辨率Android设备');
|
||||
return Math.max(statusBarHeight, 24); // 至少24px
|
||||
}
|
||||
// 传统Android设备
|
||||
else {
|
||||
console.log('UniApp: 检测到传统Android设备');
|
||||
return statusBarHeight || 24;
|
||||
}
|
||||
}
|
||||
// 其他平台
|
||||
else {
|
||||
console.log('UniApp: 其他平台设备');
|
||||
return statusBarHeight || 20;
|
||||
}
|
||||
},
|
||||
|
||||
// 动态设置web-view高度
|
||||
setWebViewHeight(height) {
|
||||
console.log('设置web-view高度:', height);
|
||||
@@ -763,7 +632,6 @@ export default {
|
||||
|
||||
// 设置web-view为全屏
|
||||
setWebViewFullscreen() {
|
||||
const safeArea = this.getSafeAreaHeight();
|
||||
const fullHeight = uni.getSystemInfoSync().windowHeight;
|
||||
console.log('设置web-view全屏,高度:', fullHeight);
|
||||
this.setWebViewHeight(fullHeight);
|
||||
@@ -771,7 +639,6 @@ export default {
|
||||
|
||||
// 设置web-view为部分高度
|
||||
setWebViewPartialHeight(percentage = 0.8) {
|
||||
const safeArea = this.getSafeAreaHeight();
|
||||
const windowHeight = uni.getSystemInfoSync().windowHeight;
|
||||
const partialHeight = windowHeight * percentage;
|
||||
console.log('设置web-view部分高度:', partialHeight, '百分比:', percentage);
|
||||
|
||||
274
Appbuild/unpackage/dist/dev/app-plus/app-service.js
vendored
274
Appbuild/unpackage/dist/dev/app-plus/app-service.js
vendored
@@ -126,33 +126,15 @@ if (uni.restoreGlobal) {
|
||||
this.resumeMessageQueue();
|
||||
},
|
||||
onHide() {
|
||||
formatAppLog("log", "at pages/index/index.vue:52", "WebView页面隐藏");
|
||||
formatAppLog("log", "at pages/index/index.vue:51", "WebView页面隐藏");
|
||||
},
|
||||
onUnload() {
|
||||
this.cleanup();
|
||||
},
|
||||
computed: {
|
||||
navBarHeight() {
|
||||
return (this.getSafeAreaHeight().navBarHeight || 44) + "px";
|
||||
},
|
||||
webViewStyle() {
|
||||
const safeArea = this.getSafeAreaHeight();
|
||||
return {
|
||||
position: "absolute",
|
||||
top: safeArea.navBarHeight + "px",
|
||||
left: "0px",
|
||||
right: "0px",
|
||||
bottom: "0px",
|
||||
width: "100%",
|
||||
height: `calc(100vh - ${safeArea.navBarHeight}px)`,
|
||||
zIndex: 1
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取初始URL
|
||||
getInitialUrl() {
|
||||
formatAppLog("log", "at pages/index/index.vue:79", "获取初始URL,config:", this.config);
|
||||
formatAppLog("log", "at pages/index/index.vue:60", "获取初始URL,config:", this.config);
|
||||
if (this.config && this.config.appConfig && this.config.appConfig.useTestPage) {
|
||||
return this.config.webConfig.testUrl;
|
||||
}
|
||||
@@ -160,12 +142,12 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 初始化应用
|
||||
initApp() {
|
||||
formatAppLog("log", "at pages/index/index.vue:88", "UniApp: 开始初始化应用");
|
||||
formatAppLog("log", "at pages/index/index.vue:69", "UniApp: 开始初始化应用");
|
||||
this.currentUrl = this.getInitialUrl();
|
||||
formatAppLog("log", "at pages/index/index.vue:91", "UniApp: 设置URL:", this.currentUrl);
|
||||
formatAppLog("log", "at pages/index/index.vue:72", "UniApp: 设置URL:", this.currentUrl);
|
||||
this.setupLoadingTimeout();
|
||||
this.initMessageHandler();
|
||||
formatAppLog("log", "at pages/index/index.vue:97", "UniApp: 立即注入桥接代码");
|
||||
formatAppLog("log", "at pages/index/index.vue:78", "UniApp: 立即注入桥接代码");
|
||||
this.injectBridgeCode();
|
||||
},
|
||||
// 设置加载超时
|
||||
@@ -174,14 +156,14 @@ if (uni.restoreGlobal) {
|
||||
clearTimeout(this.loadingTimer);
|
||||
}
|
||||
if (!this.config.appConfig.enableTimeout) {
|
||||
formatAppLog("log", "at pages/index/index.vue:110", "超时检测已禁用");
|
||||
formatAppLog("log", "at pages/index/index.vue:91", "超时检测已禁用");
|
||||
return;
|
||||
}
|
||||
if (this.config.appConfig.loadingTimeout > 0) {
|
||||
formatAppLog("log", "at pages/index/index.vue:115", "设置加载超时:", this.config.appConfig.loadingTimeout + "ms");
|
||||
formatAppLog("log", "at pages/index/index.vue:96", "设置加载超时:", this.config.appConfig.loadingTimeout + "ms");
|
||||
this.loadingTimer = setTimeout(() => {
|
||||
if (this.loading) {
|
||||
formatAppLog("warn", "at pages/index/index.vue:118", "页面加载超时,当前状态:", this.loading);
|
||||
formatAppLog("warn", "at pages/index/index.vue:99", "页面加载超时,当前状态:", this.loading);
|
||||
this.handleTimeout();
|
||||
}
|
||||
}, this.config.appConfig.loadingTimeout);
|
||||
@@ -189,7 +171,7 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 处理加载超时
|
||||
handleTimeout() {
|
||||
formatAppLog("warn", "at pages/index/index.vue:127", "触发页面加载超时处理");
|
||||
formatAppLog("warn", "at pages/index/index.vue:108", "触发页面加载超时处理");
|
||||
this.error = "页面加载超时,请检查网络连接";
|
||||
this.loading = false;
|
||||
if (this.loadingTimer) {
|
||||
@@ -199,9 +181,9 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 初始化消息处理器
|
||||
initMessageHandler() {
|
||||
formatAppLog("log", "at pages/index/index.vue:139", "UniApp: 初始化消息处理器");
|
||||
formatAppLog("log", "at pages/index/index.vue:120", "UniApp: 初始化消息处理器");
|
||||
window.addEventListener("message", (event) => {
|
||||
formatAppLog("log", "at pages/index/index.vue:142", "UniApp: 收到window.message事件:", event.data);
|
||||
formatAppLog("log", "at pages/index/index.vue:123", "UniApp: 收到window.message事件:", event.data);
|
||||
this.handleIframeMessage(event);
|
||||
});
|
||||
},
|
||||
@@ -211,21 +193,21 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 注入桥接代码
|
||||
injectBridgeCode() {
|
||||
formatAppLog("log", "at pages/index/index.vue:155", "UniApp: 开始注入桥接代码");
|
||||
formatAppLog("log", "at pages/index/index.vue:136", "UniApp: 开始注入桥接代码");
|
||||
const bridgeCode = `
|
||||
// UniApp WebView 桥接代码
|
||||
__f__('log','at pages/index/index.vue:159','开始注入UniApp桥接代码...');
|
||||
__f__('log','at pages/index/index.vue:140','开始注入UniApp桥接代码...');
|
||||
|
||||
// 检查是否已经存在桥接
|
||||
if (window.uniAppBridge) {
|
||||
__f__('log','at pages/index/index.vue:163','UniApp桥接已存在,跳过注入');
|
||||
__f__('log','at pages/index/index.vue:144','UniApp桥接已存在,跳过注入');
|
||||
return;
|
||||
}
|
||||
|
||||
window.uniAppBridge = {
|
||||
// 发送消息到UniApp
|
||||
postMessage: function(type, data) {
|
||||
__f__('log','at pages/index/index.vue:170','UniApp桥接发送消息:', type, data);
|
||||
__f__('log','at pages/index/index.vue:151','UniApp桥接发送消息:', type, data);
|
||||
window.parent.postMessage({
|
||||
type: type,
|
||||
data: data,
|
||||
@@ -235,68 +217,68 @@ if (uni.restoreGlobal) {
|
||||
|
||||
// 获取用户信息
|
||||
getUserInfo: function() {
|
||||
__f__('log','at pages/index/index.vue:180','UniApp桥接: 请求用户信息');
|
||||
__f__('log','at pages/index/index.vue:161','UniApp桥接: 请求用户信息');
|
||||
this.postMessage('getUserInfo', {});
|
||||
},
|
||||
|
||||
// 获取设备信息
|
||||
getDeviceInfo: function() {
|
||||
__f__('log','at pages/index/index.vue:186','UniApp桥接: 请求设备信息');
|
||||
__f__('log','at pages/index/index.vue:167','UniApp桥接: 请求设备信息');
|
||||
this.postMessage('getDeviceInfo', {});
|
||||
},
|
||||
|
||||
// 显示Toast
|
||||
showToast: function(message, duration = 2000) {
|
||||
__f__('log','at pages/index/index.vue:192','UniApp桥接: 显示Toast', message, duration);
|
||||
__f__('log','at pages/index/index.vue:173','UniApp桥接: 显示Toast', message, duration);
|
||||
this.postMessage('toast', { message, duration });
|
||||
},
|
||||
|
||||
// 显示Alert
|
||||
showAlert: function(title, content) {
|
||||
__f__('log','at pages/index/index.vue:198','UniApp桥接: 显示Alert', title, content);
|
||||
__f__('log','at pages/index/index.vue:179','UniApp桥接: 显示Alert', title, content);
|
||||
this.postMessage('alert', { title, content });
|
||||
},
|
||||
|
||||
// 显示Confirm
|
||||
showConfirm: function(title, content) {
|
||||
__f__('log','at pages/index/index.vue:204','UniApp桥接: 显示Confirm', title, content);
|
||||
__f__('log','at pages/index/index.vue:185','UniApp桥接: 显示Confirm', title, content);
|
||||
this.postMessage('confirm', { title, content });
|
||||
},
|
||||
|
||||
// 分享
|
||||
share: function(data) {
|
||||
__f__('log','at pages/index/index.vue:210','UniApp桥接: 分享', data);
|
||||
__f__('log','at pages/index/index.vue:191','UniApp桥接: 分享', data);
|
||||
this.postMessage('share', data);
|
||||
},
|
||||
|
||||
// 支付
|
||||
payment: function(data) {
|
||||
__f__('log','at pages/index/index.vue:216','UniApp桥接: 支付', data);
|
||||
__f__('log','at pages/index/index.vue:197','UniApp桥接: 支付', data);
|
||||
this.postMessage('payment', data);
|
||||
},
|
||||
|
||||
// 页面导航
|
||||
navigate: function(url) {
|
||||
__f__('log','at pages/index/index.vue:222','UniApp桥接: 导航', url);
|
||||
__f__('log','at pages/index/index.vue:203','UniApp桥接: 导航', url);
|
||||
this.postMessage('navigate', { url });
|
||||
},
|
||||
|
||||
// 自定义消息
|
||||
sendCustomMessage: function(type, data) {
|
||||
__f__('log','at pages/index/index.vue:228','UniApp桥接: 自定义消息', type, data);
|
||||
__f__('log','at pages/index/index.vue:209','UniApp桥接: 自定义消息', type, data);
|
||||
this.postMessage(type, data);
|
||||
},
|
||||
|
||||
// 页面准备就绪
|
||||
notifyPageReady: function(data) {
|
||||
__f__('log','at pages/index/index.vue:234','UniApp桥接: 页面准备就绪', data);
|
||||
__f__('log','at pages/index/index.vue:215','UniApp桥接: 页面准备就绪', data);
|
||||
this.postMessage('pageReady', data);
|
||||
}
|
||||
};
|
||||
|
||||
// 监听来自UniApp的消息
|
||||
window.addEventListener('message', function(event) {
|
||||
__f__('log','at pages/index/index.vue:241','UniApp桥接收到消息:', event.data);
|
||||
__f__('log','at pages/index/index.vue:222','UniApp桥接收到消息:', event.data);
|
||||
if (event.data && event.data.type) {
|
||||
// 触发自定义事件
|
||||
const customEvent = new CustomEvent('uniAppMessage', {
|
||||
@@ -306,7 +288,7 @@ if (uni.restoreGlobal) {
|
||||
}
|
||||
});
|
||||
|
||||
__f__('log','at pages/index/index.vue:251','UniApp桥接代码注入成功');
|
||||
__f__('log','at pages/index/index.vue:232','UniApp桥接代码注入成功');
|
||||
|
||||
// 通知UniApp页面已加载完成
|
||||
window.parent.postMessage({
|
||||
@@ -315,47 +297,47 @@ if (uni.restoreGlobal) {
|
||||
timestamp: Date.now()
|
||||
}, '*');
|
||||
`;
|
||||
formatAppLog("log", "at pages/index/index.vue:262", "UniApp: 立即注入桥接代码");
|
||||
formatAppLog("log", "at pages/index/index.vue:243", "UniApp: 立即注入桥接代码");
|
||||
this.evalJS(bridgeCode);
|
||||
setTimeout(() => {
|
||||
formatAppLog("log", "at pages/index/index.vue:267", "UniApp: 延迟500ms后再次注入");
|
||||
formatAppLog("log", "at pages/index/index.vue:248", "UniApp: 延迟500ms后再次注入");
|
||||
this.evalJS(bridgeCode);
|
||||
}, 500);
|
||||
setTimeout(() => {
|
||||
formatAppLog("log", "at pages/index/index.vue:273", "UniApp: 延迟1000ms后备用注入");
|
||||
formatAppLog("log", "at pages/index/index.vue:254", "UniApp: 延迟1000ms后备用注入");
|
||||
this.evalJS(bridgeCode);
|
||||
}, 1e3);
|
||||
},
|
||||
// 执行JavaScript代码
|
||||
evalJS(code) {
|
||||
formatAppLog("log", "at pages/index/index.vue:280", "UniApp: 执行JavaScript代码");
|
||||
formatAppLog("log", "at pages/index/index.vue:281", "UniApp: 当前平台:", uni.getSystemInfoSync().platform);
|
||||
formatAppLog("log", "at pages/index/index.vue:261", "UniApp: 执行JavaScript代码");
|
||||
formatAppLog("log", "at pages/index/index.vue:262", "UniApp: 当前平台:", uni.getSystemInfoSync().platform);
|
||||
const webview = this.$refs.webview;
|
||||
formatAppLog("log", "at pages/index/index.vue:284", "UniApp: webview引用:", webview);
|
||||
formatAppLog("log", "at pages/index/index.vue:265", "UniApp: webview引用:", webview);
|
||||
if (webview && webview.evalJS) {
|
||||
try {
|
||||
webview.evalJS(code);
|
||||
formatAppLog("log", "at pages/index/index.vue:291", "UniApp: JavaScript代码执行成功 (App环境)");
|
||||
formatAppLog("log", "at pages/index/index.vue:272", "UniApp: JavaScript代码执行成功 (App环境)");
|
||||
} catch (error) {
|
||||
formatAppLog("error", "at pages/index/index.vue:293", "UniApp: JavaScript代码执行失败:", error);
|
||||
formatAppLog("error", "at pages/index/index.vue:274", "UniApp: JavaScript代码执行失败:", error);
|
||||
}
|
||||
} else {
|
||||
formatAppLog("warn", "at pages/index/index.vue:296", "UniApp: webview或evalJS方法不存在 (App环境)");
|
||||
formatAppLog("warn", "at pages/index/index.vue:277", "UniApp: webview或evalJS方法不存在 (App环境)");
|
||||
this.tryAlternativeInjection(code);
|
||||
}
|
||||
},
|
||||
// 备用注入方案
|
||||
tryAlternativeInjection(code) {
|
||||
formatAppLog("log", "at pages/index/index.vue:315", "UniApp: 尝试备用注入方案");
|
||||
formatAppLog("log", "at pages/index/index.vue:296", "UniApp: 尝试备用注入方案");
|
||||
try {
|
||||
window.postMessage({
|
||||
type: "injectCode",
|
||||
data: { code },
|
||||
timestamp: Date.now()
|
||||
}, "*");
|
||||
formatAppLog("log", "at pages/index/index.vue:323", "UniApp: 备用方案1执行成功");
|
||||
formatAppLog("log", "at pages/index/index.vue:304", "UniApp: 备用方案1执行成功");
|
||||
} catch (error) {
|
||||
formatAppLog("error", "at pages/index/index.vue:325", "UniApp: 备用方案1失败:", error);
|
||||
formatAppLog("error", "at pages/index/index.vue:306", "UniApp: 备用方案1失败:", error);
|
||||
try {
|
||||
const webview = this.$refs.webview;
|
||||
if (webview && webview.postMessage) {
|
||||
@@ -363,34 +345,34 @@ if (uni.restoreGlobal) {
|
||||
type: "injectCode",
|
||||
data: { code }
|
||||
});
|
||||
formatAppLog("log", "at pages/index/index.vue:335", "UniApp: 备用方案2执行成功");
|
||||
formatAppLog("log", "at pages/index/index.vue:316", "UniApp: 备用方案2执行成功");
|
||||
} else {
|
||||
formatAppLog("error", "at pages/index/index.vue:337", "UniApp: 备用方案2失败 - webview.postMessage不存在");
|
||||
formatAppLog("error", "at pages/index/index.vue:318", "UniApp: 备用方案2失败 - webview.postMessage不存在");
|
||||
}
|
||||
} catch (error2) {
|
||||
formatAppLog("error", "at pages/index/index.vue:340", "UniApp: 备用方案2失败:", error2);
|
||||
formatAppLog("error", "at pages/index/index.vue:321", "UniApp: 备用方案2失败:", error2);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 处理web-view组件的消息
|
||||
handleMessage(event) {
|
||||
formatAppLog("log", "at pages/index/index.vue:347", "收到web-view消息:", event.detail);
|
||||
formatAppLog("log", "at pages/index/index.vue:328", "收到web-view消息:", event.detail);
|
||||
try {
|
||||
const data = event.detail.data;
|
||||
if (data && data.type) {
|
||||
this.processMessage(data);
|
||||
}
|
||||
} catch (error) {
|
||||
formatAppLog("error", "at pages/index/index.vue:354", "处理消息失败:", error);
|
||||
formatAppLog("error", "at pages/index/index.vue:335", "处理消息失败:", error);
|
||||
}
|
||||
},
|
||||
// 处理iframe消息
|
||||
handleIframeMessage(event) {
|
||||
formatAppLog("log", "at pages/index/index.vue:360", "收到iframe消息:", event.data);
|
||||
formatAppLog("log", "at pages/index/index.vue:341", "收到iframe消息:", event.data);
|
||||
try {
|
||||
if (event.data && event.data.type) {
|
||||
if (event.data.type === "pageLoaded") {
|
||||
formatAppLog("log", "at pages/index/index.vue:365", "收到页面加载完成消息:", event.data.data);
|
||||
formatAppLog("log", "at pages/index/index.vue:346", "收到页面加载完成消息:", event.data.data);
|
||||
if (this.loadingTimer) {
|
||||
clearTimeout(this.loadingTimer);
|
||||
this.loadingTimer = null;
|
||||
@@ -402,55 +384,55 @@ if (uni.restoreGlobal) {
|
||||
this.processMessage(event.data);
|
||||
}
|
||||
} catch (error) {
|
||||
formatAppLog("error", "at pages/index/index.vue:380", "处理iframe消息失败:", error);
|
||||
formatAppLog("error", "at pages/index/index.vue:361", "处理iframe消息失败:", error);
|
||||
}
|
||||
},
|
||||
// 处理消息
|
||||
processMessage(data) {
|
||||
formatAppLog("log", "at pages/index/index.vue:386", "UniApp处理消息:", data.type, data);
|
||||
formatAppLog("log", "at pages/index/index.vue:367", "UniApp处理消息:", data.type, data);
|
||||
switch (data.type) {
|
||||
case this.config.communication.messageTypes.GET_USER_INFO:
|
||||
formatAppLog("log", "at pages/index/index.vue:390", "UniApp: 处理获取用户信息请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:371", "UniApp: 处理获取用户信息请求");
|
||||
this.sendUserInfo();
|
||||
break;
|
||||
case this.config.communication.messageTypes.GET_DEVICE_INFO:
|
||||
formatAppLog("log", "at pages/index/index.vue:394", "UniApp: 处理获取设备信息请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:375", "UniApp: 处理获取设备信息请求");
|
||||
this.sendDeviceInfo();
|
||||
break;
|
||||
case this.config.communication.messageTypes.NAVIGATE:
|
||||
formatAppLog("log", "at pages/index/index.vue:398", "UniApp: 处理导航请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:379", "UniApp: 处理导航请求");
|
||||
this.handleNavigation(data);
|
||||
break;
|
||||
case this.config.communication.messageTypes.SHARE:
|
||||
formatAppLog("log", "at pages/index/index.vue:402", "UniApp: 处理分享请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:383", "UniApp: 处理分享请求");
|
||||
this.handleShare(data);
|
||||
break;
|
||||
case this.config.communication.messageTypes.PAYMENT:
|
||||
formatAppLog("log", "at pages/index/index.vue:406", "UniApp: 处理支付请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:387", "UniApp: 处理支付请求");
|
||||
this.handlePayment(data);
|
||||
break;
|
||||
case this.config.communication.messageTypes.TOAST:
|
||||
formatAppLog("log", "at pages/index/index.vue:410", "UniApp: 处理Toast请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:391", "UniApp: 处理Toast请求");
|
||||
this.handleToast(data);
|
||||
break;
|
||||
case this.config.communication.messageTypes.ALERT:
|
||||
formatAppLog("log", "at pages/index/index.vue:414", "UniApp: 处理Alert请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:395", "UniApp: 处理Alert请求");
|
||||
this.handleAlert(data);
|
||||
break;
|
||||
case this.config.communication.messageTypes.CONFIRM:
|
||||
formatAppLog("log", "at pages/index/index.vue:418", "UniApp: 处理Confirm请求");
|
||||
formatAppLog("log", "at pages/index/index.vue:399", "UniApp: 处理Confirm请求");
|
||||
this.handleConfirm(data);
|
||||
break;
|
||||
case "pageReady":
|
||||
formatAppLog("log", "at pages/index/index.vue:422", "UniApp: 处理页面准备就绪消息");
|
||||
formatAppLog("log", "at pages/index/index.vue:403", "UniApp: 处理页面准备就绪消息");
|
||||
break;
|
||||
default:
|
||||
formatAppLog("log", "at pages/index/index.vue:426", "UniApp: 未知消息类型:", data.type);
|
||||
formatAppLog("log", "at pages/index/index.vue:407", "UniApp: 未知消息类型:", data.type);
|
||||
}
|
||||
},
|
||||
// 发送用户信息到iframe
|
||||
sendUserInfo() {
|
||||
formatAppLog("log", "at pages/index/index.vue:432", "UniApp: 发送用户信息");
|
||||
formatAppLog("log", "at pages/index/index.vue:413", "UniApp: 发送用户信息");
|
||||
const userInfo = {
|
||||
type: "userInfo",
|
||||
data: this.config.userConfig.defaultUser
|
||||
@@ -459,7 +441,7 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 发送设备信息到iframe
|
||||
sendDeviceInfo() {
|
||||
formatAppLog("log", "at pages/index/index.vue:442", "UniApp: 发送设备信息");
|
||||
formatAppLog("log", "at pages/index/index.vue:423", "UniApp: 发送设备信息");
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const deviceInfo = {
|
||||
type: "deviceInfo",
|
||||
@@ -479,12 +461,12 @@ if (uni.restoreGlobal) {
|
||||
// 处理导航
|
||||
handleNavigation(data) {
|
||||
if (data.url) {
|
||||
formatAppLog("log", "at pages/index/index.vue:463", "导航到:", data.url);
|
||||
formatAppLog("log", "at pages/index/index.vue:444", "导航到:", data.url);
|
||||
}
|
||||
},
|
||||
// 处理分享
|
||||
handleShare(data) {
|
||||
formatAppLog("log", "at pages/index/index.vue:470", "UniApp: 处理分享请求", data);
|
||||
formatAppLog("log", "at pages/index/index.vue:451", "UniApp: 处理分享请求", data);
|
||||
uni.share({
|
||||
provider: "weixin",
|
||||
scene: "WXSceneSession",
|
||||
@@ -493,18 +475,18 @@ if (uni.restoreGlobal) {
|
||||
title: data.title || this.config.appConfig.appName,
|
||||
summary: data.summary || "分享内容",
|
||||
success: (res) => {
|
||||
formatAppLog("log", "at pages/index/index.vue:479", "UniApp: 分享成功:", res);
|
||||
formatAppLog("log", "at pages/index/index.vue:460", "UniApp: 分享成功:", res);
|
||||
this.sendToIframe("shareResult", { success: true });
|
||||
},
|
||||
fail: (err) => {
|
||||
formatAppLog("error", "at pages/index/index.vue:483", "UniApp: 分享失败:", err);
|
||||
formatAppLog("error", "at pages/index/index.vue:464", "UniApp: 分享失败:", err);
|
||||
this.sendToIframe("shareResult", { success: false, error: err });
|
||||
}
|
||||
});
|
||||
},
|
||||
// 处理支付
|
||||
handlePayment(data) {
|
||||
formatAppLog("log", "at pages/index/index.vue:491", "UniApp: 处理支付请求", data);
|
||||
formatAppLog("log", "at pages/index/index.vue:472", "UniApp: 处理支付请求", data);
|
||||
setTimeout(() => {
|
||||
this.sendToIframe("paymentResult", {
|
||||
success: true,
|
||||
@@ -514,7 +496,7 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 处理Toast
|
||||
handleToast(data) {
|
||||
formatAppLog("log", "at pages/index/index.vue:504", "UniApp: 处理Toast请求", data);
|
||||
formatAppLog("log", "at pages/index/index.vue:485", "UniApp: 处理Toast请求", data);
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
icon: "none",
|
||||
@@ -523,7 +505,7 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 处理Alert
|
||||
handleAlert(data) {
|
||||
formatAppLog("log", "at pages/index/index.vue:514", "UniApp: 处理Alert请求", data);
|
||||
formatAppLog("log", "at pages/index/index.vue:495", "UniApp: 处理Alert请求", data);
|
||||
uni.showModal({
|
||||
title: data.title || "提示",
|
||||
content: data.content,
|
||||
@@ -532,12 +514,12 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 处理Confirm
|
||||
handleConfirm(data) {
|
||||
formatAppLog("log", "at pages/index/index.vue:524", "UniApp: 处理Confirm请求", data);
|
||||
formatAppLog("log", "at pages/index/index.vue:505", "UniApp: 处理Confirm请求", data);
|
||||
uni.showModal({
|
||||
title: data.title || "确认",
|
||||
content: data.content,
|
||||
success: (res) => {
|
||||
formatAppLog("log", "at pages/index/index.vue:529", "UniApp: Confirm结果:", res);
|
||||
formatAppLog("log", "at pages/index/index.vue:510", "UniApp: Confirm结果:", res);
|
||||
this.sendToIframe("confirmResult", {
|
||||
confirmed: res.confirm
|
||||
});
|
||||
@@ -551,10 +533,10 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 处理消息队列
|
||||
processMessageQueue() {
|
||||
formatAppLog("log", "at pages/index/index.vue:545", "UniApp: 处理消息队列, 队列长度:", this.messageQueue.length, "加载状态:", this.loading);
|
||||
formatAppLog("log", "at pages/index/index.vue:526", "UniApp: 处理消息队列, 队列长度:", this.messageQueue.length, "加载状态:", this.loading);
|
||||
if (this.messageQueue.length > 0 && !this.loading) {
|
||||
const message = this.messageQueue.shift();
|
||||
formatAppLog("log", "at pages/index/index.vue:548", "UniApp: 发送消息到iframe:", message);
|
||||
formatAppLog("log", "at pages/index/index.vue:529", "UniApp: 发送消息到iframe:", message);
|
||||
this.evalJS(`
|
||||
window.postMessage(${JSON.stringify(message)}, '*');
|
||||
`);
|
||||
@@ -575,12 +557,12 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 处理加载状态
|
||||
handleLoading(event) {
|
||||
formatAppLog("log", "at pages/index/index.vue:572", "WebView加载状态变化:", event.detail);
|
||||
formatAppLog("log", "at pages/index/index.vue:553", "WebView加载状态变化:", event.detail);
|
||||
const newLoadingState = event.detail.loading;
|
||||
formatAppLog("log", "at pages/index/index.vue:574", "加载状态从", this.loading, "变为", newLoadingState);
|
||||
formatAppLog("log", "at pages/index/index.vue:555", "加载状态从", this.loading, "变为", newLoadingState);
|
||||
this.loading = newLoadingState;
|
||||
if (!this.loading) {
|
||||
formatAppLog("log", "at pages/index/index.vue:580", "页面加载完成,清除超时定时器");
|
||||
formatAppLog("log", "at pages/index/index.vue:561", "页面加载完成,清除超时定时器");
|
||||
if (this.loadingTimer) {
|
||||
clearTimeout(this.loadingTimer);
|
||||
this.loadingTimer = null;
|
||||
@@ -588,13 +570,13 @@ if (uni.restoreGlobal) {
|
||||
this.injectBridgeCode();
|
||||
this.processMessageQueue();
|
||||
} else {
|
||||
formatAppLog("log", "at pages/index/index.vue:592", "页面开始加载,设置超时检测");
|
||||
formatAppLog("log", "at pages/index/index.vue:573", "页面开始加载,设置超时检测");
|
||||
this.setupLoadingTimeout();
|
||||
}
|
||||
},
|
||||
// 处理错误
|
||||
handleError(event) {
|
||||
formatAppLog("error", "at pages/index/index.vue:599", "WebView错误:", event.detail);
|
||||
formatAppLog("error", "at pages/index/index.vue:580", "WebView错误:", event.detail);
|
||||
this.error = "页面加载失败,请检查网络连接";
|
||||
this.loading = false;
|
||||
clearTimeout(this.loadingTimer);
|
||||
@@ -616,99 +598,18 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 清除超时
|
||||
clearTimeout() {
|
||||
formatAppLog("log", "at pages/index/index.vue:625", "手动清除超时");
|
||||
formatAppLog("log", "at pages/index/index.vue:606", "手动清除超时");
|
||||
if (this.loadingTimer) {
|
||||
clearTimeout(this.loadingTimer);
|
||||
this.loadingTimer = null;
|
||||
}
|
||||
this.error = "";
|
||||
this.loading = false;
|
||||
formatAppLog("log", "at pages/index/index.vue:632", "超时已清除");
|
||||
},
|
||||
// 获取安全区域高度
|
||||
getSafeAreaHeight() {
|
||||
try {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
formatAppLog("log", "at pages/index/index.vue:640", "UniApp: 系统信息:", systemInfo);
|
||||
const safeArea = systemInfo.safeArea || {};
|
||||
const safeAreaInsets = systemInfo.safeAreaInsets || {};
|
||||
formatAppLog("log", "at pages/index/index.vue:646", "UniApp: 安全区域:", safeArea);
|
||||
formatAppLog("log", "at pages/index/index.vue:647", "UniApp: 安全区域边距:", safeAreaInsets);
|
||||
const statusBarHeight = systemInfo.statusBarHeight || 0;
|
||||
formatAppLog("log", "at pages/index/index.vue:651", "UniApp: 状态栏高度:", statusBarHeight);
|
||||
let topSafeAreaHeight = statusBarHeight;
|
||||
if (safeAreaInsets.top !== void 0) {
|
||||
topSafeAreaHeight = safeAreaInsets.top;
|
||||
formatAppLog("log", "at pages/index/index.vue:659", "UniApp: 使用safeAreaInsets.top:", topSafeAreaHeight);
|
||||
} else if (safeArea.top !== void 0) {
|
||||
topSafeAreaHeight = safeArea.top;
|
||||
formatAppLog("log", "at pages/index/index.vue:662", "UniApp: 使用safeArea.top:", topSafeAreaHeight);
|
||||
} else {
|
||||
topSafeAreaHeight = this.calculatePlatformSafeArea(statusBarHeight, systemInfo);
|
||||
}
|
||||
const safeAreaInfo = {
|
||||
top: topSafeAreaHeight,
|
||||
bottom: safeAreaInsets.bottom || safeArea.bottom || 0,
|
||||
left: safeAreaInsets.left || safeArea.left || 0,
|
||||
right: safeAreaInsets.right || safeArea.right || 0,
|
||||
statusBarHeight,
|
||||
navBarHeight: 44,
|
||||
// 导航栏高度通常是44px
|
||||
platform: systemInfo.platform,
|
||||
model: systemInfo.model,
|
||||
system: systemInfo.system,
|
||||
screenWidth: systemInfo.screenWidth,
|
||||
screenHeight: systemInfo.screenHeight
|
||||
};
|
||||
return safeAreaInfo;
|
||||
} catch (error) {
|
||||
formatAppLog("error", "at pages/index/index.vue:686", "UniApp: 获取安全区域信息失败:", error);
|
||||
return {
|
||||
top: 44,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 44,
|
||||
platform: "unknown",
|
||||
model: "unknown",
|
||||
system: "unknown",
|
||||
screenWidth: 375,
|
||||
screenHeight: 667
|
||||
};
|
||||
}
|
||||
},
|
||||
// 根据平台计算安全区域
|
||||
calculatePlatformSafeArea(statusBarHeight, systemInfo) {
|
||||
const platform = systemInfo.platform.toLowerCase();
|
||||
const model = systemInfo.model || "";
|
||||
const screenHeight = systemInfo.screenHeight;
|
||||
const screenWidth = systemInfo.screenWidth;
|
||||
formatAppLog("log", "at pages/index/index.vue:712", "UniApp: 平台信息:", { platform, model, screenHeight, screenWidth });
|
||||
if (platform === "ios") {
|
||||
if (screenHeight >= 812 || screenWidth >= 812) {
|
||||
formatAppLog("log", "at pages/index/index.vue:718", "UniApp: 检测到iPhone X及以后设备");
|
||||
return 44;
|
||||
} else {
|
||||
formatAppLog("log", "at pages/index/index.vue:723", "UniApp: 检测到传统iPhone设备");
|
||||
return statusBarHeight || 20;
|
||||
}
|
||||
} else if (platform === "android") {
|
||||
if (screenHeight >= 800 || screenWidth >= 800) {
|
||||
formatAppLog("log", "at pages/index/index.vue:731", "UniApp: 检测到高分辨率Android设备");
|
||||
return Math.max(statusBarHeight, 24);
|
||||
} else {
|
||||
formatAppLog("log", "at pages/index/index.vue:736", "UniApp: 检测到传统Android设备");
|
||||
return statusBarHeight || 24;
|
||||
}
|
||||
} else {
|
||||
formatAppLog("log", "at pages/index/index.vue:742", "UniApp: 其他平台设备");
|
||||
return statusBarHeight || 20;
|
||||
}
|
||||
formatAppLog("log", "at pages/index/index.vue:613", "超时已清除");
|
||||
},
|
||||
// 动态设置web-view高度
|
||||
setWebViewHeight(height) {
|
||||
formatAppLog("log", "at pages/index/index.vue:749", "设置web-view高度:", height);
|
||||
formatAppLog("log", "at pages/index/index.vue:618", "设置web-view高度:", height);
|
||||
if (this.$refs.webview) {
|
||||
this.$refs.webview.$el.style.height = height + "px";
|
||||
this.$refs.webview.$el.className = "webview custom-height";
|
||||
@@ -719,17 +620,15 @@ if (uni.restoreGlobal) {
|
||||
},
|
||||
// 设置web-view为全屏
|
||||
setWebViewFullscreen() {
|
||||
this.getSafeAreaHeight();
|
||||
const fullHeight = uni.getSystemInfoSync().windowHeight;
|
||||
formatAppLog("log", "at pages/index/index.vue:768", "设置web-view全屏,高度:", fullHeight);
|
||||
formatAppLog("log", "at pages/index/index.vue:636", "设置web-view全屏,高度:", fullHeight);
|
||||
this.setWebViewHeight(fullHeight);
|
||||
},
|
||||
// 设置web-view为部分高度
|
||||
setWebViewPartialHeight(percentage = 0.8) {
|
||||
this.getSafeAreaHeight();
|
||||
const windowHeight = uni.getSystemInfoSync().windowHeight;
|
||||
const partialHeight = windowHeight * percentage;
|
||||
formatAppLog("log", "at pages/index/index.vue:777", "设置web-view部分高度:", partialHeight, "百分比:", percentage);
|
||||
formatAppLog("log", "at pages/index/index.vue:644", "设置web-view部分高度:", partialHeight, "百分比:", percentage);
|
||||
this.setWebViewHeight(partialHeight);
|
||||
},
|
||||
// 清理资源
|
||||
@@ -745,12 +644,12 @@ if (uni.restoreGlobal) {
|
||||
vue.createCommentVNode(" 全屏web-view容器 "),
|
||||
vue.createElementVNode("web-view", {
|
||||
src: $data.currentUrl,
|
||||
style: vue.normalizeStyle($options.webViewStyle),
|
||||
class: "webview",
|
||||
ref: "webview",
|
||||
onMessage: _cache[0] || (_cache[0] = (...args) => $options.handleMessage && $options.handleMessage(...args)),
|
||||
onError: _cache[1] || (_cache[1] = (...args) => $options.handleError && $options.handleError(...args)),
|
||||
onLoading: _cache[2] || (_cache[2] = (...args) => $options.handleLoading && $options.handleLoading(...args))
|
||||
}, null, 44, ["src"]),
|
||||
}, null, 40, ["src"]),
|
||||
vue.createCommentVNode(" 加载状态 "),
|
||||
$data.loading ? (vue.openBlock(), vue.createElementBlock("view", {
|
||||
key: 0,
|
||||
@@ -802,13 +701,6 @@ if (uni.restoreGlobal) {
|
||||
"加载状态: " + vue.toDisplayString($data.loading ? "加载中" : "已加载"),
|
||||
1
|
||||
/* TEXT */
|
||||
),
|
||||
vue.createElementVNode(
|
||||
"text",
|
||||
null,
|
||||
"navBarHeight: " + vue.toDisplayString($options.navBarHeight),
|
||||
1
|
||||
/* TEXT */
|
||||
)
|
||||
])) : vue.createCommentVNode("v-if", true)
|
||||
]);
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
# AI图标使用指南
|
||||
|
||||
## 概述
|
||||
|
||||
本文档为AI助手提供标准化的图标选择和使用流程,确保在代码生成时使用正确的图标包和图标名称。
|
||||
|
||||
## AI使用流程
|
||||
|
||||
### 1. 项目类型判断
|
||||
首先判断项目类型:
|
||||
- **PC端项目**: 使用 `@ant-design/icons`
|
||||
- **移动端项目**: 使用 `antd-mobile-icons`
|
||||
|
||||
### 2. 图标查找流程
|
||||
1. 根据功能需求确定图标类型
|
||||
2. 在对应图标包中查找合适的图标
|
||||
3. 如果图标不存在,查找替代方案
|
||||
4. 使用正确的导入语法
|
||||
|
||||
### 3. 代码生成模板
|
||||
|
||||
#### PC端项目模板
|
||||
```typescript
|
||||
import {
|
||||
// 导航类
|
||||
HomeOutlined,
|
||||
UserOutlined,
|
||||
SettingOutlined,
|
||||
|
||||
// 操作类
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
CopyOutlined,
|
||||
SearchOutlined,
|
||||
ReloadOutlined,
|
||||
|
||||
// 状态类
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
CheckCircleOutlined,
|
||||
CloseCircleOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
InfoCircleOutlined,
|
||||
LoadingOutlined,
|
||||
|
||||
// 方向类
|
||||
UpOutlined,
|
||||
DownOutlined,
|
||||
LeftOutlined,
|
||||
RightOutlined,
|
||||
ArrowLeftOutlined,
|
||||
|
||||
// 其他
|
||||
MessageOutlined,
|
||||
CalendarOutlined,
|
||||
ClockCircleOutlined,
|
||||
PictureOutlined,
|
||||
FileOutlined,
|
||||
CameraOutlined,
|
||||
QrcodeOutlined,
|
||||
} from '@ant-design/icons';
|
||||
```
|
||||
|
||||
#### 移动端项目模板
|
||||
```typescript
|
||||
import {
|
||||
// 导航类
|
||||
HomeOutline,
|
||||
UserOutline,
|
||||
SettingOutline,
|
||||
|
||||
// 操作类
|
||||
AddOutline,
|
||||
EditSOutline,
|
||||
DeleteOutline,
|
||||
CopyOutline,
|
||||
SearchOutline,
|
||||
RefreshOutline,
|
||||
|
||||
// 状态类
|
||||
CheckOutline,
|
||||
CloseOutline,
|
||||
CheckCircleOutline,
|
||||
CloseCircleOutline,
|
||||
ExclamationCircleOutline,
|
||||
InfoCircleOutline,
|
||||
LoadingOutline,
|
||||
|
||||
// 方向类
|
||||
UpOutline,
|
||||
DownOutline,
|
||||
LeftOutline,
|
||||
RightOutline,
|
||||
|
||||
// 其他
|
||||
MessageOutline,
|
||||
CalendarOutline,
|
||||
ClockCircleOutline,
|
||||
PictureOutline,
|
||||
FileOutline,
|
||||
CameraOutline,
|
||||
QrCodeOutline,
|
||||
} from 'antd-mobile-icons';
|
||||
```
|
||||
|
||||
## 功能到图标映射
|
||||
|
||||
### 基础功能映射
|
||||
| 功能需求 | PC端图标 | 移动端图标 | 说明 |
|
||||
|---------|---------|-----------|------|
|
||||
| 添加/新建 | PlusOutlined | AddOutline | 通用添加功能 |
|
||||
| 编辑/修改 | EditOutlined | EditSOutline | 编辑功能 |
|
||||
| 删除/移除 | DeleteOutlined | DeleteOutline | 删除功能 |
|
||||
| 复制/克隆 | CopyOutlined | CopyOutline | 复制功能 |
|
||||
| 搜索/查找 | SearchOutlined | SearchOutline | 搜索功能 |
|
||||
| 刷新/重新加载 | ReloadOutlined | RefreshOutline | 刷新功能 |
|
||||
| 设置/配置 | SettingOutlined | SettingOutline | 设置功能 |
|
||||
| 用户/个人 | UserOutlined | UserOutline | 用户相关 |
|
||||
| 首页/主页 | HomeOutlined | HomeOutline | 首页导航 |
|
||||
| 返回/后退 | ArrowLeftOutlined | LeftOutline | 返回功能 |
|
||||
| 关闭/取消 | CloseOutlined | CloseOutline | 关闭功能 |
|
||||
| 确认/确定 | CheckOutlined | CheckOutline | 确认功能 |
|
||||
|
||||
### 状态指示映射
|
||||
| 状态需求 | PC端图标 | 移动端图标 | 说明 |
|
||||
|---------|---------|-----------|------|
|
||||
| 成功/完成 | CheckCircleOutlined | CheckCircleOutline | 成功状态 |
|
||||
| 错误/失败 | CloseCircleOutlined | CloseCircleOutline | 错误状态 |
|
||||
| 警告/注意 | ExclamationCircleOutlined | ExclamationCircleOutline | 警告状态 |
|
||||
| 信息/提示 | InfoCircleOutlined | InfoCircleOutline | 信息提示 |
|
||||
| 加载/等待 | LoadingOutlined | LoadingOutline | 加载状态 |
|
||||
| 时间/等待 | ClockCircleOutlined | ClockCircleOutline | 时间相关 |
|
||||
|
||||
### 方向导航映射
|
||||
| 方向需求 | PC端图标 | 移动端图标 | 说明 |
|
||||
|---------|---------|-----------|------|
|
||||
| 向上/上升 | UpOutlined | UpOutline | 向上方向 |
|
||||
| 向下/下降 | DownOutlined | DownOutline | 向下方向 |
|
||||
| 向左/后退 | LeftOutlined | LeftOutline | 向左方向 |
|
||||
| 向右/前进 | RightOutlined | RightOutline | 向右方向 |
|
||||
|
||||
### 业务功能映射
|
||||
| 业务需求 | PC端图标 | 移动端图标 | 说明 |
|
||||
|---------|---------|-----------|------|
|
||||
| 消息/通知 | MessageOutlined | MessageOutline | 消息功能 |
|
||||
| 日历/日期 | CalendarOutlined | CalendarOutline | 日历功能 |
|
||||
| 图片/照片 | PictureOutlined | PictureOutline | 图片功能 |
|
||||
| 文件/文档 | FileOutlined | FileOutline | 文件功能 |
|
||||
| 相机/拍照 | CameraOutlined | CameraOutline | 相机功能 |
|
||||
| 二维码 | QrcodeOutlined | QrCodeOutline | 二维码功能 |
|
||||
| 微信/社交 | WechatOutlined | WechatOutline | 微信功能 |
|
||||
| 设备/手机 | MobileOutlined | MobileOutline | 设备功能 |
|
||||
| 团队/群组 | TeamOutlined | TeamOutline | 团队功能 |
|
||||
| 订单/购物 | ShoppingOutlined | ShoppingOutline | 订单功能 |
|
||||
| 支付/钱包 | PayCircleOutlined | PayCircleOutline | 支付功能 |
|
||||
|
||||
## 特殊替换规则
|
||||
|
||||
### 移动端不存在的图标替换
|
||||
| 原需求 | 替换方案 | 说明 |
|
||||
|--------|----------|------|
|
||||
| RiseOutlined | UpOutline | 上升趋势 |
|
||||
| ThumbsUpOutlined | LikeOutline | 点赞功能 |
|
||||
| ShareAltOutlined | LinkOutline | 分享功能 |
|
||||
| BarChartOutlined | PieOutline | 图表功能 |
|
||||
| LineChartOutlined | PieOutline | 图表功能 |
|
||||
| UserAddOutlined | UserOutline | 用户添加 |
|
||||
| Progress | 自定义div | 进度条组件 |
|
||||
|
||||
### PC端不存在的图标替换
|
||||
| 原需求 | 替换方案 | 说明 |
|
||||
|--------|----------|------|
|
||||
| AntOutline | HomeOutlined | 蚂蚁图标 |
|
||||
| AppOutline | AppstoreOutlined | 应用图标 |
|
||||
|
||||
## AI代码生成示例
|
||||
|
||||
### 场景1: 移动端列表页面
|
||||
```typescript
|
||||
// AI应该生成的代码
|
||||
import {
|
||||
AddOutline, // 添加按钮
|
||||
EditSOutline, // 编辑按钮
|
||||
DeleteOutline, // 删除按钮
|
||||
CopyOutline, // 复制按钮
|
||||
SearchOutline, // 搜索框
|
||||
RefreshOutline, // 刷新按钮
|
||||
UserOutline, // 用户信息
|
||||
CalendarOutline, // 时间信息
|
||||
UpOutline, // 上升趋势(替换RiseOutlined)
|
||||
} from 'antd-mobile-icons';
|
||||
|
||||
// 使用示例
|
||||
<Button>
|
||||
<AddOutline /> 新建
|
||||
</Button>
|
||||
<Button>
|
||||
<EditSOutline /> 编辑
|
||||
</Button>
|
||||
<Button color="danger">
|
||||
<DeleteOutline /> 删除
|
||||
</Button>
|
||||
```
|
||||
|
||||
### 场景2: PC端管理页面
|
||||
```typescript
|
||||
// AI应该生成的代码
|
||||
import {
|
||||
PlusOutlined, // 添加按钮
|
||||
EditOutlined, // 编辑按钮
|
||||
DeleteOutlined, // 删除按钮
|
||||
CopyOutlined, // 复制按钮
|
||||
SearchOutlined, // 搜索框
|
||||
ReloadOutlined, // 刷新按钮
|
||||
UserOutlined, // 用户信息
|
||||
CalendarOutlined, // 时间信息
|
||||
RiseOutlined, // 上升趋势(PC端存在)
|
||||
} from '@ant-design/icons';
|
||||
|
||||
// 使用示例
|
||||
<Button icon={<PlusOutlined />}>新建</Button>
|
||||
<Button icon={<EditOutlined />}>编辑</Button>
|
||||
<Button icon={<DeleteOutlined />} danger>删除</Button>
|
||||
```
|
||||
|
||||
## 错误检测和修正
|
||||
|
||||
### 常见错误模式
|
||||
1. **混用图标包**: 同时导入PC端和移动端图标
|
||||
2. **使用不存在的图标**: 在移动端使用PC端特有的图标
|
||||
3. **命名错误**: 图标名称大小写错误
|
||||
4. **导入路径错误**: 使用错误的包名
|
||||
|
||||
### 修正策略
|
||||
1. **统一图标包**: 根据项目类型选择单一图标包
|
||||
2. **查找替代**: 使用对照表查找替代图标
|
||||
3. **验证存在**: 确保图标在目标包中存在
|
||||
4. **测试验证**: 在代码中测试图标是否正常显示
|
||||
|
||||
## AI使用检查清单
|
||||
|
||||
### 代码生成前
|
||||
- [ ] 确认项目类型(PC端/移动端)
|
||||
- [ ] 选择对应的图标包
|
||||
- [ ] 根据功能需求选择合适图标
|
||||
- [ ] 检查图标是否存在
|
||||
|
||||
### 代码生成中
|
||||
- [ ] 使用正确的导入语法
|
||||
- [ ] 图标名称大小写正确
|
||||
- [ ] 避免混用不同包的图标
|
||||
- [ ] 为不存在的图标提供替代方案
|
||||
|
||||
### 代码生成后
|
||||
- [ ] 验证图标导入正确
|
||||
- [ ] 检查图标使用语法
|
||||
- [ ] 确保样式设置合理
|
||||
- [ ] 提供使用示例
|
||||
|
||||
## 更新和维护
|
||||
|
||||
- 定期更新图标对照表
|
||||
- 记录新发现的图标差异
|
||||
- 更新替换规则
|
||||
- 优化AI使用流程
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **优先使用语义化图标**: 选择最能表达功能的图标
|
||||
2. **保持一致性**: 在同一项目中保持图标风格一致
|
||||
3. **考虑可访问性**: 为图标添加适当的aria-label
|
||||
4. **性能优化**: 按需导入图标,避免全量导入
|
||||
5. **版本兼容**: 注意图标包版本与UI框架版本的兼容性
|
||||
@@ -1,205 +0,0 @@
|
||||
# 详细图标对照表
|
||||
|
||||
## 基础图标对照
|
||||
|
||||
### 导航类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 首页 | HomeOutlined | HomeOutline | ✅ |
|
||||
| 返回 | ArrowLeftOutlined | LeftOutline | ✅ |
|
||||
| 菜单 | MenuOutlined | MenuOutline | ✅ |
|
||||
| 设置 | SettingOutlined | SettingOutline | ✅ |
|
||||
| 用户 | UserOutlined | UserOutline | ✅ |
|
||||
| 个人中心 | UserOutlined | UserOutline | ✅ |
|
||||
|
||||
### 操作类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 添加 | PlusOutlined | AddOutline | ✅ |
|
||||
| 编辑 | EditOutlined | EditSOutline | ✅ |
|
||||
| 删除 | DeleteOutlined | DeleteOutline | ✅ |
|
||||
| 复制 | CopyOutlined | CopyOutline | ✅ |
|
||||
| 保存 | SaveOutlined | SaveOutline | ✅ |
|
||||
| 刷新 | ReloadOutlined | RefreshOutline | ✅ |
|
||||
| 搜索 | SearchOutlined | SearchOutline | ✅ |
|
||||
| 关闭 | CloseOutlined | CloseOutline | ✅ |
|
||||
| 确认 | CheckOutlined | CheckOutline | ✅ |
|
||||
| 取消 | CloseOutlined | CloseOutline | ✅ |
|
||||
|
||||
### 状态类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 成功 | CheckCircleOutlined | CheckCircleOutline | ✅ |
|
||||
| 错误 | CloseCircleOutlined | CloseCircleOutline | ✅ |
|
||||
| 警告 | ExclamationCircleOutlined | ExclamationCircleOutline | ✅ |
|
||||
| 信息 | InfoCircleOutlined | InfoCircleOutline | ✅ |
|
||||
| 加载 | LoadingOutlined | LoadingOutline | ✅ |
|
||||
| 等待 | ClockCircleOutlined | ClockCircleOutline | ✅ |
|
||||
|
||||
### 方向类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 向上 | UpOutlined | UpOutline | ✅ |
|
||||
| 向下 | DownOutlined | DownOutline | ✅ |
|
||||
| 向左 | LeftOutlined | LeftOutline | ✅ |
|
||||
| 向右 | RightOutlined | RightOutline | ✅ |
|
||||
| 向上圆形 | UpCircleOutlined | UpCircleOutline | ✅ |
|
||||
| 向下圆形 | DownCircleOutlined | DownCircleOutline | ✅ |
|
||||
|
||||
### 通信类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 消息 | MessageOutlined | MessageOutline | ✅ |
|
||||
| 邮件 | MailOutlined | MailOutline | ✅ |
|
||||
| 电话 | PhoneOutlined | PhoneOutline | ✅ |
|
||||
| 视频 | VideoCameraOutlined | VideoCameraOutline | ✅ |
|
||||
| 语音 | AudioOutlined | AudioOutline | ✅ |
|
||||
|
||||
### 媒体类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 图片 | PictureOutlined | PictureOutline | ✅ |
|
||||
| 文件 | FileOutlined | FileOutline | ✅ |
|
||||
| 文件夹 | FolderOutlined | FolderOutline | ✅ |
|
||||
| 相机 | CameraOutlined | CameraOutline | ✅ |
|
||||
| 二维码 | QrcodeOutlined | QrCodeOutline | ✅ |
|
||||
|
||||
### 时间类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 日历 | CalendarOutlined | CalendarOutline | ✅ |
|
||||
| 时钟 | ClockCircleOutlined | ClockCircleOutline | ✅ |
|
||||
| 历史 | HistoryOutlined | HistoryOutline | ✅ |
|
||||
|
||||
### 数据类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 统计 | BarChartOutlined | BarChartOutline | ✅ |
|
||||
| 饼图 | PieChartOutlined | PieChartOutline | ✅ |
|
||||
| 折线图 | LineChartOutlined | LineChartOutline | ✅ |
|
||||
| 表格 | TableOutlined | TableOutline | ✅ |
|
||||
| 列表 | UnorderedListOutlined | UnorderedListOutline | ✅ |
|
||||
|
||||
## 特殊图标对照
|
||||
|
||||
### 业务相关
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 设备 | MobileOutlined | MobileOutline | ✅ |
|
||||
| 微信 | WechatOutlined | WechatOutline | ✅ |
|
||||
| 群组 | TeamOutlined | TeamOutline | ✅ |
|
||||
| 客户 | UserAddOutlined | UserAddOutline | ❌ |
|
||||
| 订单 | ShoppingOutlined | ShoppingOutline | ✅ |
|
||||
| 支付 | PayCircleOutlined | PayCircleOutline | ✅ |
|
||||
|
||||
### 工具类
|
||||
| 功能 | PC端 | 移动端 | 状态 |
|
||||
|------|------|--------|------|
|
||||
| 工具 | ToolOutlined | ToolOutline | ✅ |
|
||||
| 配置 | SettingOutlined | SettingOutline | ✅ |
|
||||
| 帮助 | QuestionCircleOutlined | QuestionCircleOutline | ✅ |
|
||||
| 反馈 | MessageOutlined | MessageOutline | ✅ |
|
||||
| 分享 | ShareAltOutlined | ShareOutline | ❌ |
|
||||
|
||||
## 不存在的图标替换方案
|
||||
|
||||
### PC端存在但移动端不存在的图标
|
||||
| PC端图标 | 推荐替换 | 说明 |
|
||||
|----------|----------|------|
|
||||
| UserAddOutlined | UserOutline | 用户添加功能 |
|
||||
| ShareAltOutlined | LinkOutline | 分享功能 |
|
||||
| RiseOutlined | UpOutline | 上升趋势 |
|
||||
| ThumbsUpOutlined | LikeOutline | 点赞功能 |
|
||||
| BarChartOutlined | PieOutline | 图表功能 |
|
||||
| LineChartOutlined | PieOutline | 图表功能 |
|
||||
|
||||
### 移动端存在但PC端不存在的图标
|
||||
| 移动端图标 | 推荐替换 | 说明 |
|
||||
|------------|----------|------|
|
||||
| AntOutline | HomeOutlined | 蚂蚁图标 |
|
||||
| AppOutline | AppstoreOutlined | 应用图标 |
|
||||
|
||||
## 使用规范
|
||||
|
||||
### 1. 导入规范
|
||||
```typescript
|
||||
// PC端项目
|
||||
import {
|
||||
HomeOutlined,
|
||||
UserOutlined,
|
||||
SettingOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
// 移动端项目
|
||||
import {
|
||||
HomeOutline,
|
||||
UserOutline,
|
||||
SettingOutline,
|
||||
} from 'antd-mobile-icons';
|
||||
```
|
||||
|
||||
### 2. 命名规范
|
||||
- PC端:使用 `Outlined` 后缀
|
||||
- 移动端:使用 `Outline` 后缀
|
||||
- 保持语义化命名
|
||||
|
||||
### 3. 使用建议
|
||||
- 优先使用语义明确的图标
|
||||
- 保持图标风格一致性
|
||||
- 考虑图标在不同尺寸下的清晰度
|
||||
- 为图标添加适当的aria-label
|
||||
|
||||
### 4. 错误处理
|
||||
当图标不存在时:
|
||||
1. 查找语义相近的图标
|
||||
2. 使用通用图标(如QuestionOutlined)
|
||||
3. 考虑使用文字替代
|
||||
4. 创建自定义图标组件
|
||||
|
||||
## 项目中的实际应用
|
||||
|
||||
### 场景获客模块使用的图标
|
||||
```typescript
|
||||
// 移动端项目中的图标使用
|
||||
import {
|
||||
AddOutline, // 添加
|
||||
UpOutline, // 上升趋势(替换RiseOutline)
|
||||
UserOutline, // 用户
|
||||
CalendarOutline, // 日历
|
||||
CopyOutline, // 复制
|
||||
DeleteOutline, // 删除
|
||||
EditSOutline, // 编辑
|
||||
SettingOutline, // 设置
|
||||
SearchOutline, // 搜索
|
||||
RefreshOutline, // 刷新
|
||||
QrCodeOutline, // 二维码
|
||||
} from 'antd-mobile-icons';
|
||||
```
|
||||
|
||||
### 工作台模块使用的图标
|
||||
```typescript
|
||||
// 移动端项目中的图标使用
|
||||
import {
|
||||
LikeOutline, // 点赞(替换ThumbsUpOutline)
|
||||
LinkOutline, // 链接(替换ShareOutline)
|
||||
PieOutline, // 饼图(替换BarChartOutline/LineChartOutline)
|
||||
UserOutline, // 用户
|
||||
TeamOutline, // 团队
|
||||
MessageOutline, // 消息
|
||||
} from 'antd-mobile-icons';
|
||||
```
|
||||
|
||||
## 更新和维护
|
||||
|
||||
1. **定期检查**: 定期检查新版本中新增的图标
|
||||
2. **文档更新**: 及时更新图标对照表
|
||||
3. **团队协作**: 团队成员共享图标使用规范
|
||||
4. **代码审查**: 在代码审查中检查图标使用是否正确
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **包版本**: 确保图标包版本与UI框架版本兼容
|
||||
2. **按需导入**: 避免全量导入图标,影响打包体积
|
||||
3. **样式覆盖**: 可以通过CSS自定义图标样式
|
||||
4. **无障碍**: 为图标添加适当的无障碍属性
|
||||
5. **性能**: 大量使用图标时注意性能优化
|
||||
@@ -1,230 +0,0 @@
|
||||
# PC端与移动端图标对照文档
|
||||
|
||||
## 概述
|
||||
|
||||
本文档记录了PC端(@ant-design/icons)和移动端(antd-mobile-icons)的图标名称对照,以及正确的导入方式。
|
||||
|
||||
## 导入方式
|
||||
|
||||
### PC端图标 (@ant-design/icons)
|
||||
```typescript
|
||||
import {
|
||||
HomeOutlined,
|
||||
UserOutlined,
|
||||
SettingOutlined,
|
||||
// ... 其他图标
|
||||
} from '@ant-design/icons';
|
||||
```
|
||||
|
||||
### 移动端图标 (antd-mobile-icons)
|
||||
```typescript
|
||||
import {
|
||||
AntOutline,
|
||||
ArrowDownCircleOutline,
|
||||
UserOutline,
|
||||
// ... 其他图标
|
||||
} from 'antd-mobile-icons';
|
||||
```
|
||||
|
||||
## 图标对照表
|
||||
|
||||
### 常用图标对照
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 | 备注 |
|
||||
|---------|---------|-----------|------|
|
||||
| 首页 | HomeOutlined | HomeOutline | 完全对应 |
|
||||
| 用户 | UserOutlined | UserOutline | 完全对应 |
|
||||
| 设置 | SettingOutlined | SettingOutline | 完全对应 |
|
||||
| 搜索 | SearchOutlined | SearchOutline | 完全对应 |
|
||||
| 添加 | PlusOutlined | AddOutline | 完全对应 |
|
||||
| 编辑 | EditOutlined | EditSOutline | 移动端略有不同 |
|
||||
| 删除 | DeleteOutlined | DeleteOutline | 完全对应 |
|
||||
| 复制 | CopyOutlined | CopyOutline | 完全对应 |
|
||||
| 刷新 | ReloadOutlined | RefreshOutline | 完全对应 |
|
||||
| 二维码 | QrcodeOutlined | QrCodeOutline | 完全对应 |
|
||||
| 日历 | CalendarOutlined | CalendarOutline | 完全对应 |
|
||||
| 时钟 | ClockCircleOutlined | ClockCircleOutline | 完全对应 |
|
||||
| 箭头向上 | UpOutlined | UpOutline | 完全对应 |
|
||||
| 箭头向下 | DownOutlined | DownOutline | 完全对应 |
|
||||
| 箭头向左 | LeftOutlined | LeftOutline | 完全对应 |
|
||||
| 箭头向右 | RightOutlined | RightOutline | 完全对应 |
|
||||
| 返回 | ArrowLeftOutlined | LeftOutline | 移动端使用LeftOutline |
|
||||
| 关闭 | CloseOutlined | CloseOutline | 完全对应 |
|
||||
| 检查 | CheckOutlined | CheckOutline | 完全对应 |
|
||||
| 警告 | ExclamationCircleOutlined | ExclamationCircleOutline | 完全对应 |
|
||||
| 信息 | InfoCircleOutlined | InfoCircleOutline | 完全对应 |
|
||||
| 成功 | CheckCircleOutlined | CheckCircleOutline | 完全对应 |
|
||||
| 错误 | CloseCircleOutlined | CloseCircleOutline | 完全对应 |
|
||||
|
||||
### 方向性图标
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 |
|
||||
|---------|---------|-----------|
|
||||
| 向上 | UpOutlined | UpOutline |
|
||||
| 向下 | DownOutlined | DownOutline |
|
||||
| 向左 | LeftOutlined | LeftOutline |
|
||||
| 向右 | RightOutlined | RightOutline |
|
||||
| 向上圆形 | UpCircleOutlined | UpCircleOutline |
|
||||
| 向下圆形 | DownCircleOutlined | DownCircleOutline |
|
||||
| 向左圆形 | LeftCircleOutlined | LeftCircleOutline |
|
||||
| 向右圆形 | RightCircleOutlined | RightCircleOutline |
|
||||
|
||||
### 编辑类图标
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 |
|
||||
|---------|---------|-----------|
|
||||
| 编辑 | EditOutlined | EditSOutline |
|
||||
| 删除 | DeleteOutlined | DeleteOutline |
|
||||
| 复制 | CopyOutlined | CopyOutline |
|
||||
| 剪切 | ScissorOutlined | ScissorOutline |
|
||||
| 撤销 | UndoOutlined | UndoOutline |
|
||||
| 重做 | RedoOutlined | RedoOutline |
|
||||
| 保存 | SaveOutlined | SaveOutline |
|
||||
|
||||
### 通信类图标
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 |
|
||||
|---------|---------|-----------|
|
||||
| 消息 | MessageOutlined | MessageOutline |
|
||||
| 邮件 | MailOutlined | MailOutline |
|
||||
| 电话 | PhoneOutlined | PhoneOutline |
|
||||
| 视频通话 | VideoCameraOutlined | VideoCameraOutline |
|
||||
| 语音 | AudioOutlined | AudioOutline |
|
||||
|
||||
### 媒体类图标
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 |
|
||||
|---------|---------|-----------|
|
||||
| 图片 | PictureOutlined | PictureOutline |
|
||||
| 视频 | VideoCameraOutlined | VideoCameraOutline |
|
||||
| 音频 | AudioOutlined | AudioOutline |
|
||||
| 文件 | FileOutlined | FileOutline |
|
||||
| 文件夹 | FolderOutlined | FolderOutline |
|
||||
| 相机 | CameraOutlined | CameraOutline |
|
||||
|
||||
### 导航类图标
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 |
|
||||
|---------|---------|-----------|
|
||||
| 菜单 | MenuOutlined | MenuOutline |
|
||||
| 汉堡菜单 | MenuFoldOutlined | MenuOutline |
|
||||
| 展开菜单 | MenuUnfoldOutlined | MenuOutline |
|
||||
| 面包屑 | BreadcrumbOutlined | BreadcrumbOutline |
|
||||
| 分页 | PaginationOutlined | PaginationOutline |
|
||||
|
||||
### 数据展示类图标
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 |
|
||||
|---------|---------|-----------|
|
||||
| 表格 | TableOutlined | TableOutline |
|
||||
| 列表 | UnorderedListOutlined | UnorderedListOutline |
|
||||
| 卡片 | CreditCardOutlined | CreditCardOutline |
|
||||
| 统计 | BarChartOutlined | BarChartOutline |
|
||||
| 饼图 | PieChartOutlined | PieChartOutline |
|
||||
| 折线图 | LineChartOutlined | LineChartOutline |
|
||||
| 仪表盘 | DashboardOutlined | DashboardOutline |
|
||||
|
||||
### 反馈类图标
|
||||
|
||||
| 功能描述 | PC端图标 | 移动端图标 |
|
||||
|---------|---------|-----------|
|
||||
| 成功 | CheckCircleOutlined | CheckCircleOutline |
|
||||
| 错误 | CloseCircleOutlined | CloseCircleOutline |
|
||||
| 警告 | ExclamationCircleOutlined | ExclamationCircleOutline |
|
||||
| 信息 | InfoCircleOutlined | InfoCircleOutline |
|
||||
| 加载 | LoadingOutlined | LoadingOutline |
|
||||
| 等待 | ClockCircleOutlined | ClockCircleOutline |
|
||||
|
||||
## 使用建议
|
||||
|
||||
### 1. 项目类型判断
|
||||
- **PC端项目**: 使用 `@ant-design/icons`
|
||||
- **移动端项目**: 使用 `antd-mobile-icons`
|
||||
|
||||
### 2. 图标选择原则
|
||||
- 优先选择语义化图标
|
||||
- 保持图标风格一致性
|
||||
- 考虑图标在不同尺寸下的清晰度
|
||||
|
||||
### 3. 常见错误避免
|
||||
- 不要混用PC端和移动端图标
|
||||
- 注意图标名称的大小写
|
||||
- 确保图标在对应包中存在
|
||||
|
||||
### 4. 图标替换策略
|
||||
当某个图标在目标包中不存在时:
|
||||
1. 查找语义相近的图标
|
||||
2. 使用通用图标(如QuestionOutlined)
|
||||
3. 考虑使用文字替代
|
||||
4. 创建自定义图标组件
|
||||
|
||||
## 实际项目中的使用示例
|
||||
|
||||
### PC端项目示例
|
||||
```typescript
|
||||
import {
|
||||
HomeOutlined,
|
||||
UserOutlined,
|
||||
SettingOutlined,
|
||||
SearchOutlined,
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
CopyOutlined,
|
||||
ReloadOutlined,
|
||||
QrcodeOutlined,
|
||||
CalendarOutlined,
|
||||
ClockCircleOutlined,
|
||||
UpOutlined,
|
||||
DownOutlined,
|
||||
LeftOutlined,
|
||||
RightOutlined,
|
||||
CloseOutlined,
|
||||
CheckOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
InfoCircleOutlined,
|
||||
CheckCircleOutlined,
|
||||
CloseCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
```
|
||||
|
||||
### 移动端项目示例
|
||||
```typescript
|
||||
import {
|
||||
HomeOutline,
|
||||
UserOutline,
|
||||
SettingOutline,
|
||||
SearchOutline,
|
||||
AddOutline,
|
||||
EditSOutline,
|
||||
DeleteOutline,
|
||||
CopyOutline,
|
||||
RefreshOutline,
|
||||
QrCodeOutline,
|
||||
CalendarOutline,
|
||||
ClockCircleOutline,
|
||||
UpOutline,
|
||||
DownOutline,
|
||||
LeftOutline,
|
||||
RightOutline,
|
||||
CloseOutline,
|
||||
CheckOutline,
|
||||
ExclamationCircleOutline,
|
||||
InfoCircleOutline,
|
||||
CheckCircleOutline,
|
||||
CloseCircleOutline,
|
||||
} from 'antd-mobile-icons';
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **包依赖**: 确保项目中已安装对应的图标包
|
||||
2. **版本兼容**: 注意图标包版本与UI框架版本的兼容性
|
||||
3. **性能考虑**: 按需导入图标,避免全量导入
|
||||
4. **样式覆盖**: 可以通过CSS自定义图标颜色和大小
|
||||
5. **无障碍**: 为图标添加适当的aria-label属性
|
||||
|
||||
## 更新记录
|
||||
|
||||
- 2024-01-XX: 初始版本,包含常用图标对照
|
||||
- 后续根据实际使用情况持续更新
|
||||
@@ -1,271 +0,0 @@
|
||||
# 图标快速参考表
|
||||
|
||||
## 快速查找
|
||||
|
||||
### 🔍 按功能查找
|
||||
|
||||
| 功能 | PC端 | 移动端 | 导入方式 |
|
||||
|------|------|--------|----------|
|
||||
| **添加** | PlusOutlined | AddOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **编辑** | EditOutlined | EditSOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **删除** | DeleteOutlined | DeleteOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **复制** | CopyOutlined | CopyOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **搜索** | SearchOutlined | SearchOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **刷新** | ReloadOutlined | RefreshOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **设置** | SettingOutlined | SettingOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **用户** | UserOutlined | UserOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **首页** | HomeOutlined | HomeOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **返回** | ArrowLeftOutlined | LeftOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **关闭** | CloseOutlined | CloseOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **确认** | CheckOutlined | CheckOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **成功** | CheckCircleOutlined | CheckCircleOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **错误** | CloseCircleOutlined | CloseCircleOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **警告** | ExclamationCircleOutlined | ExclamationCircleOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **信息** | InfoCircleOutlined | InfoCircleOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **加载** | LoadingOutlined | LoadingOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **向上** | UpOutlined | UpOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **向下** | DownOutlined | DownOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **向左** | LeftOutlined | LeftOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **向右** | RightOutlined | RightOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **消息** | MessageOutlined | MessageOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **电话** | PhoneOutlined | PhoneOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **日历** | CalendarOutlined | CalendarOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **时钟** | ClockCircleOutlined | ClockCircleOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **图片** | PictureOutlined | PictureOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **文件** | FileOutlined | FileOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **相机** | CameraOutlined | CameraOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **二维码** | QrcodeOutlined | QrCodeOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **微信** | WechatOutlined | WechatOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **设备** | MobileOutlined | MobileOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **团队** | TeamOutlined | TeamOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **订单** | ShoppingOutlined | ShoppingOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
| **支付** | PayCircleOutlined | PayCircleOutline | `@ant-design/icons` / `antd-mobile-icons` |
|
||||
|
||||
### 🔄 常见替换
|
||||
|
||||
| 原图标 | 替换为 | 说明 |
|
||||
|--------|--------|------|
|
||||
| RiseOutlined | UpOutline | 上升趋势 |
|
||||
| ThumbsUpOutlined | LikeOutline | 点赞功能 |
|
||||
| ShareAltOutlined | LinkOutline | 分享功能 |
|
||||
| BarChartOutlined | PieOutline | 图表功能 |
|
||||
| LineChartOutlined | PieOutline | 图表功能 |
|
||||
| UserAddOutlined | UserOutline | 用户添加 |
|
||||
| SettingOutline | SettingOutline | 设置(移动端) |
|
||||
|
||||
## 导入模板
|
||||
|
||||
### PC端项目模板
|
||||
```typescript
|
||||
import {
|
||||
HomeOutlined,
|
||||
UserOutlined,
|
||||
SettingOutlined,
|
||||
SearchOutlined,
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
CopyOutlined,
|
||||
ReloadOutlined,
|
||||
CloseOutlined,
|
||||
CheckOutlined,
|
||||
UpOutlined,
|
||||
DownOutlined,
|
||||
LeftOutlined,
|
||||
RightOutlined,
|
||||
MessageOutlined,
|
||||
CalendarOutlined,
|
||||
ClockCircleOutlined,
|
||||
PictureOutlined,
|
||||
FileOutlined,
|
||||
CameraOutlined,
|
||||
QrcodeOutlined,
|
||||
WechatOutlined,
|
||||
MobileOutlined,
|
||||
TeamOutlined,
|
||||
ShoppingOutlined,
|
||||
PayCircleOutlined,
|
||||
CheckCircleOutlined,
|
||||
CloseCircleOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
InfoCircleOutlined,
|
||||
LoadingOutlined,
|
||||
} from '@ant-design/icons';
|
||||
```
|
||||
|
||||
### 移动端项目模板
|
||||
```typescript
|
||||
import {
|
||||
HomeOutline,
|
||||
UserOutline,
|
||||
SettingOutline,
|
||||
SearchOutline,
|
||||
AddOutline,
|
||||
EditSOutline,
|
||||
DeleteOutline,
|
||||
CopyOutline,
|
||||
RefreshOutline,
|
||||
CloseOutline,
|
||||
CheckOutline,
|
||||
UpOutline,
|
||||
DownOutline,
|
||||
LeftOutline,
|
||||
RightOutline,
|
||||
MessageOutline,
|
||||
CalendarOutline,
|
||||
ClockCircleOutline,
|
||||
PictureOutline,
|
||||
FileOutline,
|
||||
CameraOutline,
|
||||
QrCodeOutline,
|
||||
WechatOutline,
|
||||
MobileOutline,
|
||||
TeamOutline,
|
||||
ShoppingOutline,
|
||||
PayCircleOutline,
|
||||
CheckCircleOutline,
|
||||
CloseCircleOutline,
|
||||
ExclamationCircleOutline,
|
||||
InfoCircleOutline,
|
||||
LoadingOutline,
|
||||
} from 'antd-mobile-icons';
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
|
||||
### 基础使用
|
||||
```typescript
|
||||
// PC端
|
||||
import { HomeOutlined, UserOutlined } from '@ant-design/icons';
|
||||
|
||||
<HomeOutlined style={{ fontSize: 16, color: '#1890ff' }} />
|
||||
<UserOutlined style={{ fontSize: 16, color: '#52c41a' }} />
|
||||
|
||||
// 移动端
|
||||
import { HomeOutline, UserOutline } from 'antd-mobile-icons';
|
||||
|
||||
<HomeOutline style={{ fontSize: 16, color: '#1890ff' }} />
|
||||
<UserOutline style={{ fontSize: 16, color: '#52c41a' }} />
|
||||
```
|
||||
|
||||
### 按钮中使用
|
||||
```typescript
|
||||
// PC端
|
||||
import { PlusOutlined, EditOutlined } from '@ant-design/icons';
|
||||
|
||||
<Button icon={<PlusOutlined />}>添加</Button>
|
||||
<Button icon={<EditOutlined />}>编辑</Button>
|
||||
|
||||
// 移动端
|
||||
import { AddOutline, EditSOutline } from 'antd-mobile-icons';
|
||||
|
||||
<Button>
|
||||
<AddOutline /> 添加
|
||||
</Button>
|
||||
<Button>
|
||||
<EditSOutline /> 编辑
|
||||
</Button>
|
||||
```
|
||||
|
||||
### 列表中使用
|
||||
```typescript
|
||||
// PC端
|
||||
import { DeleteOutlined, CopyOutlined } from '@ant-design/icons';
|
||||
|
||||
<Button icon={<DeleteOutlined />} danger>删除</Button>
|
||||
<Button icon={<CopyOutlined />}>复制</Button>
|
||||
|
||||
// 移动端
|
||||
import { DeleteOutline, CopyOutline } from 'antd-mobile-icons';
|
||||
|
||||
<Button color="danger">
|
||||
<DeleteOutline /> 删除
|
||||
</Button>
|
||||
<Button>
|
||||
<CopyOutline /> 复制
|
||||
</Button>
|
||||
```
|
||||
|
||||
## 常见错误
|
||||
|
||||
### ❌ 错误示例
|
||||
```typescript
|
||||
// 错误:混用PC端和移动端图标
|
||||
import { HomeOutlined } from '@ant-design/icons'; // PC端
|
||||
import { UserOutline } from 'antd-mobile-icons'; // 移动端
|
||||
|
||||
// 错误:使用不存在的图标
|
||||
import { RiseOutlined } from 'antd-mobile-icons'; // 不存在
|
||||
import { UserAddOutline } from 'antd-mobile-icons'; // 不存在
|
||||
```
|
||||
|
||||
### ✅ 正确示例
|
||||
```typescript
|
||||
// 正确:统一使用移动端图标
|
||||
import {
|
||||
HomeOutline,
|
||||
UserOutline,
|
||||
UpOutline, // 替换RiseOutlined
|
||||
UserOutline // 替换UserAddOutline
|
||||
} from 'antd-mobile-icons';
|
||||
|
||||
// 正确:统一使用PC端图标
|
||||
import {
|
||||
HomeOutlined,
|
||||
UserOutlined,
|
||||
RiseOutlined, // PC端存在
|
||||
UserAddOutlined // PC端存在
|
||||
} from '@ant-design/icons';
|
||||
```
|
||||
|
||||
## 快速检查清单
|
||||
|
||||
### 开发前检查
|
||||
- [ ] 确认项目类型(PC端/移动端)
|
||||
- [ ] 选择对应的图标包
|
||||
- [ ] 检查图标是否存在
|
||||
- [ ] 准备替换方案
|
||||
|
||||
### 开发中检查
|
||||
- [ ] 使用正确的导入方式
|
||||
- [ ] 图标名称大小写正确
|
||||
- [ ] 避免混用不同包的图标
|
||||
- [ ] 为图标添加适当的样式
|
||||
|
||||
### 开发后检查
|
||||
- [ ] 图标显示正常
|
||||
- [ ] 样式符合设计要求
|
||||
- [ ] 无障碍属性完整
|
||||
- [ ] 性能影响最小
|
||||
|
||||
## 紧急替换方案
|
||||
|
||||
当遇到图标不存在时,使用以下通用图标:
|
||||
|
||||
```typescript
|
||||
// 移动端通用图标
|
||||
import {
|
||||
QuestionCircleOutline, // 通用问号
|
||||
AppOutline, // 通用应用
|
||||
ToolOutline, // 通用工具
|
||||
SettingOutline, // 通用设置
|
||||
UserOutline, // 通用用户
|
||||
} from 'antd-mobile-icons';
|
||||
|
||||
// PC端通用图标
|
||||
import {
|
||||
QuestionCircleOutlined, // 通用问号
|
||||
AppstoreOutlined, // 通用应用
|
||||
ToolOutlined, // 通用工具
|
||||
SettingOutlined, // 通用设置
|
||||
UserOutlined, // 通用用户
|
||||
} from '@ant-design/icons';
|
||||
```
|
||||
|
||||
## 更新日志
|
||||
|
||||
- 2024-01-XX: 初始版本
|
||||
- 添加常用图标对照
|
||||
- 添加错误示例和正确示例
|
||||
- 添加快速检查清单
|
||||
- 添加紧急替换方案
|
||||
@@ -18,10 +18,9 @@ const NavCommon: React.FC<NavCommonProps> = ({
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<>
|
||||
<div style={{ paddingTop: "44px", background: "#fff" }}>
|
||||
<NavBar
|
||||
back={null}
|
||||
style={{ background: "#fff" }}
|
||||
left={
|
||||
left ? (
|
||||
left
|
||||
@@ -46,7 +45,7 @@ const NavCommon: React.FC<NavCommonProps> = ({
|
||||
{title}
|
||||
</span>
|
||||
</NavBar>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createRoot } from "react-dom/client";
|
||||
import App from "./App";
|
||||
import "./styles/global.scss";
|
||||
|
||||
// import VConsole from "vconsole";
|
||||
// new VConsole();
|
||||
import VConsole from "vconsole";
|
||||
new VConsole();
|
||||
const root = createRoot(document.getElementById("root")!);
|
||||
root.render(<App />);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Card, NavBar, List, Button, Toast } from "antd-mobile";
|
||||
import { Card, NavBar, List, Button } from "antd-mobile";
|
||||
import {
|
||||
PhoneOutlined,
|
||||
MessageOutlined,
|
||||
@@ -13,8 +13,7 @@ import Layout from "@/components/Layout/Layout";
|
||||
import style from "./index.module.scss";
|
||||
import { useUserStore } from "@/store/module/user";
|
||||
import { getDashboard } from "./api";
|
||||
import { DEV_FEATURES } from "@/utils/env";
|
||||
|
||||
import NavCommon from "@/components/NavCommon";
|
||||
const Mine: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const { user } = useUserStore();
|
||||
@@ -136,13 +135,7 @@ const Mine: React.FC = () => {
|
||||
|
||||
return (
|
||||
<Layout
|
||||
header={
|
||||
<NavBar back={null} style={{ background: "#fff" }}>
|
||||
<div style={{ color: "var(--primary-color)", fontWeight: 600 }}>
|
||||
我的
|
||||
</div>
|
||||
</NavBar>
|
||||
}
|
||||
header={<NavCommon title="我的" />}
|
||||
footer={<MeauMobile activeKey="mine" />}
|
||||
>
|
||||
<div className={style["mine-page"]}>
|
||||
|
||||
Reference in New Issue
Block a user