MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / getMessageDisplayData

Function getMessageDisplayData

devtools/panel.bundle.js:886–921  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

884 }
885
886 function getMessageDisplayData(msg) {
887 const path = state.displayFieldPath.trim();
888 if (!path) {
889 return {
890 text: msg.data || '',
891 title: msg.data || '',
892 isEmpty: false
893 };
894 }
895
896 try {
897 const parsed = JSON.parse(msg.data);
898 const value = getValueByPath(parsed, path);
899
900 if (value === undefined) {
901 return {
902 text: '字段不存在',
903 title: `未找到字段:${path}`,
904 isEmpty: true
905 };
906 }
907
908 const text = formatDisplayFieldValue(value);
909 return {
910 text,
911 title: text,
912 isEmpty: false
913 };
914 } catch (error) {
915 return {
916 text: '非 JSON 数据',
917 title: '当前消息无法解析为 JSON',
918 isEmpty: true
919 };
920 }
921 }
922
923 function getValueByPath(value, path) {
924 const keys = path.split('.').filter(Boolean);

Callers 1

createMessageRowFunction · 0.70

Calls 2

getValueByPathFunction · 0.70
formatDisplayFieldValueFunction · 0.70

Tested by

no test coverage detected