marked
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
"@tarojs/runtime": "3.6.20",
|
||||
"@tarojs/shared": "3.6.20",
|
||||
"@tarojs/taro": "3.6.20",
|
||||
"marked": "^12.0.2",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"sr-sdk-h5": "^1.3.1",
|
||||
|
||||
@@ -18,251 +18,62 @@ import { AtToast } from "taro-ui";
|
||||
import { AtIcon } from "taro-ui";
|
||||
import see from "../../images/see.png";
|
||||
import group from "../../images/group.png";
|
||||
import { marked } from "marked";
|
||||
marked.setOptions({
|
||||
breaks: true, // 是否回车换行
|
||||
highlight(code, lang) {
|
||||
// 语法高亮
|
||||
let val = code;
|
||||
if (lang) {
|
||||
val = hljs.highlight(lang, code).value;
|
||||
} else {
|
||||
val = hljs.highlightAuto(code).value;
|
||||
}
|
||||
return val;
|
||||
},
|
||||
});
|
||||
const renderer = new marked.Renderer();
|
||||
// 图片调整300px
|
||||
renderer.image = function (href, title, text) {
|
||||
console.log("href, title, text", href, title, text);
|
||||
return `<img width="300px" src="${href}" alt="${text}"/>
|
||||
<div class="desc">🥶${text}</div>`;
|
||||
};
|
||||
|
||||
// 引用符号
|
||||
renderer.blockquote = function (quote) {
|
||||
console.log("quote", quote);
|
||||
var regex = /<p>(.*?)<\/p>/;
|
||||
var str = quote;
|
||||
var match = regex.exec(str);
|
||||
if (match != null) {
|
||||
var content = match[1]; // 获取第一个捕获组的内容
|
||||
console.log(content);
|
||||
}
|
||||
return `❣️${content}`;
|
||||
};
|
||||
|
||||
marked.use({ renderer });
|
||||
const markTextStr = marked(
|
||||
` \n
|
||||
> 测试`
|
||||
);
|
||||
// export default class Index extends Component {
|
||||
const Index = () => {
|
||||
const [current, setcurrent] = useState(0);
|
||||
const [openId, setopenId] = useState(null);
|
||||
const [h5openid, seth5openid] = useState(null);
|
||||
|
||||
const [wxid, setwxid] = useState(null);
|
||||
|
||||
const [isOpened, setisOpened] = useState(false);
|
||||
const [joinMeetup, setjoinMeetup] = useState(false);
|
||||
|
||||
const [id, setid] = useState(null);
|
||||
const [userInfo, setuserInfo] = useState({
|
||||
wxid: null,
|
||||
openId: null,
|
||||
h5openid: null,
|
||||
bighead: null,
|
||||
city: null,
|
||||
country: null,
|
||||
generator: null,
|
||||
id: null,
|
||||
labels: null,
|
||||
nickname: null,
|
||||
province: null,
|
||||
remark: null,
|
||||
sex: null, //男
|
||||
smallhead: null,
|
||||
source: null,
|
||||
sourceStr: null,
|
||||
usertype: null,
|
||||
v1: null,
|
||||
wxaccount: null,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
const [markText, setmarkText] = useState(null);
|
||||
|
||||
const onBridgeReady = () => {
|
||||
WeixinJSBridge.call("hideOptionMenu");
|
||||
};
|
||||
|
||||
useEffect(()=>{
|
||||
// window.alert('1111')
|
||||
getopenId()
|
||||
},[])
|
||||
|
||||
const h5openidUser = () => {
|
||||
try {
|
||||
const params = Taro.getCurrentInstance().router.params;
|
||||
let hashopenid = window.localStorage.getItem("h5openid");
|
||||
let localwxid = window.localStorage.getItem("wxid");
|
||||
//发起网络请求
|
||||
Taro.request({
|
||||
// url: "/api/addH5openid",
|
||||
url: "https://kunpeng.hackrobot.cn/addH5openid",
|
||||
data: {
|
||||
h5openid: hashopenid ?? null,
|
||||
wxid: localwxid ?? null, //debug eric 的wxid
|
||||
},
|
||||
success: function (resUser) {
|
||||
console.log(resUser);
|
||||
console.log(resUser.data);
|
||||
setuserInfo({ ...resUser.data });
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
} finally {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
let $instance = Taro.getCurrentInstance();
|
||||
console.log($instance.router.params);
|
||||
// console.log("markTextStr=>", markTextStr);
|
||||
// setmarkText(markTextStr);
|
||||
}, []);
|
||||
|
||||
// 获取openid
|
||||
const getopenId = () => {
|
||||
let hashopenid = null;
|
||||
if (window.location.href.includes("openid")) {
|
||||
hashopenid = window.location.href
|
||||
.split("#")[0]
|
||||
.split("?")[1]
|
||||
.split("=")[1];
|
||||
} else {
|
||||
hashopenid = window.localStorage.getItem("h5openid");
|
||||
}
|
||||
if (!!hashopenid && hashopenid != "undefined" && hashopenid != "null") {
|
||||
window.localStorage.setItem("h5openid", hashopenid);
|
||||
let localwxid = window.localStorage.getItem("wxid");
|
||||
seth5openid(hashopenid);
|
||||
// 查询用户信息
|
||||
h5openidUser();
|
||||
} else {
|
||||
// 获取路由参数
|
||||
const params = Taro.getCurrentInstance().router.params;
|
||||
console.log("params", params);
|
||||
|
||||
if (params?.wxid) {
|
||||
// 本地存储
|
||||
window.localStorage.setItem("wxid", params?.wxid ?? "");
|
||||
setwxid(params?.wxid);
|
||||
let nowUrl = window.location.href;
|
||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
window.location.href = payUrl;
|
||||
}else{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const joinmeet = () => {
|
||||
Taro.request({
|
||||
method: "POST",
|
||||
url: "/api/payh5", //仅为示例,并非真实的接口地址
|
||||
// url: "https://pay.hackrobot.cn/api/payh5", //仅为示例,并非真实的接口地址
|
||||
|
||||
data: {
|
||||
callback_url: window.location.href,
|
||||
openid: window.localStorage.getItem("openid"),
|
||||
},
|
||||
header: {
|
||||
"content-type": "application/json", // 默认值
|
||||
},
|
||||
success: function (res) {
|
||||
console.log(res.data);
|
||||
WeixinJSBridge.invoke(
|
||||
"getBrandWCPayRequest",
|
||||
{
|
||||
// 以下6个支付参数通过payjs的jsapi接口获取
|
||||
// appId: "wxc5205a653b0259bf",
|
||||
// timeStamp: "1701401644",
|
||||
// nonceStr: "KhOYB0wFV6j9qyQK",
|
||||
// package: "prepay_id=wx01113404850024729b35f4d69b73500000",
|
||||
// signType: "MD5",
|
||||
// paySign: "2A823C8D47CCF871C6C65A56DC228CF8",
|
||||
...(res?.data?.jsapi ?? {}),
|
||||
},
|
||||
function (res) {
|
||||
//发起网络请求
|
||||
|
||||
// 付款成功
|
||||
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||||
// 邀请加入微信群
|
||||
joinWechat();
|
||||
WeixinJSBridge.call("closeWindow");
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
// 通过wxid加群微信群
|
||||
const joinWechat = () => {
|
||||
Taro.request({
|
||||
url: "/api/joinwechat",
|
||||
// url: "https://kunpeng.hackrobot.cn/joingroup",
|
||||
data: {
|
||||
// wxid: "wxid_haqoszjheyuz22",
|
||||
wxid: wxid ?? null, //debug eric 的wxid
|
||||
},
|
||||
method: "POST",
|
||||
header: {
|
||||
"content-type": "application/json", // 默认值
|
||||
},
|
||||
success: function (resUser) {
|
||||
console.log("resUser--", resUser);
|
||||
console.log("加入微信群成功");
|
||||
if (resUser?.data?.success == "fail") {
|
||||
//已经在群聊中
|
||||
handleClick("已经在群聊中", "warning");
|
||||
setbtntext("已经在群聊中");
|
||||
} else if (resUser?.data?.success == "ok") {
|
||||
// 发送群聊邀请
|
||||
handleClick("已发送群聊邀请", "warning");
|
||||
setbtntext("已发送群聊邀请");
|
||||
}
|
||||
setdisabled(true);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="index">
|
||||
<View className="at-article">
|
||||
<View className="at-article__h1">微信群加入规则,请知悉</View>
|
||||
<View className="at-article__info">
|
||||
2024-04-10 hackrobot
|
||||
</View>
|
||||
<View className="at-article__content">
|
||||
<View className="at-article__section">
|
||||
<View className="at-article__h2">免费入群</View>
|
||||
{/* <View className="at-article__h3">请给公众号文章点击:"在看"</View> */}
|
||||
|
||||
<View className="at-article__p">
|
||||
为了防止营销广告,以及给订阅号增加曝光度,
|
||||
</View>
|
||||
<View className="at-article__p">
|
||||
1. 请点击下方蓝色文字,跳转到公众号文章
|
||||
</View>
|
||||
<View className="at-article__p">2. 阅读到最底部,点击"在看"</View>
|
||||
<View className="at-article__p">如图所示:</View>
|
||||
<Image className="at-article__img" src={see} mode="widthFix" />
|
||||
<View className="at-article__p">
|
||||
<span>点击跳转</span>
|
||||
<AtIcon value="arrow-right" size="30" color="#F00"></AtIcon>
|
||||
<a href="https://mp.weixin.qq.com/s/MttWjccHsMbLD0pMv1LfYQ">
|
||||
云手机6:内网穿透-frp
|
||||
</a>
|
||||
</View>
|
||||
<View className="at-article__p">
|
||||
稍等几分钟.机器人检测后,会自动发送群聊邀请
|
||||
</View>
|
||||
<Image className="at-article__img" src={group} mode="widthFix" />
|
||||
|
||||
{/* <View className="at-article__p">
|
||||
如果不想点击"在看",也可以选择点击
|
||||
<AtIcon value="arrow-right" size="30" color="#F00"></AtIcon>
|
||||
<Button
|
||||
onClick={() => {
|
||||
joinmeet();
|
||||
}}
|
||||
size="mini"
|
||||
type="primary"
|
||||
className="payBtn"
|
||||
>
|
||||
付费入群
|
||||
</Button>
|
||||
</View> */}
|
||||
<br />
|
||||
|
||||
<View className="at-article__p lastWord">
|
||||
声明:
|
||||
<br />
|
||||
本群是交流平台,请不要发送广告以及敏感内容
|
||||
<br />
|
||||
仅聊天,不承诺其他服务和支持
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View dangerouslySetInnerHTML={{ __html: markTextStr }}></View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
36
yarn.lock
36
yarn.lock
@@ -8280,6 +8280,11 @@ markdown-table@^1.1.0:
|
||||
resolved "https://registry.npmmirror.com/markdown-table/-/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60"
|
||||
integrity sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q==
|
||||
|
||||
marked@^12.0.2:
|
||||
version "12.0.2"
|
||||
resolved "https://registry.yarnpkg.com/marked/-/marked-12.0.2.tgz#b31578fe608b599944c69807b00f18edab84647e"
|
||||
integrity sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q==
|
||||
|
||||
math-random@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.npmmirror.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c"
|
||||
@@ -11291,7 +11296,7 @@ strict-uri-encode@^2.0.0:
|
||||
resolved "https://registry.npmmirror.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
|
||||
integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==
|
||||
|
||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2:
|
||||
"string-width-cjs@npm:string-width@^4.2.0":
|
||||
version "4.2.3"
|
||||
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
@@ -11308,6 +11313,15 @@ string-width@^2.1.0, string-width@^2.1.1:
|
||||
is-fullwidth-code-point "^2.0.0"
|
||||
strip-ansi "^4.0.0"
|
||||
|
||||
string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^5.0.1, string-width@^5.1.2:
|
||||
version "5.1.2"
|
||||
resolved "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
|
||||
@@ -11388,7 +11402,7 @@ stringify-entities@^1.0.1:
|
||||
is-alphanumerical "^1.0.0"
|
||||
is-hexadecimal "^1.0.0"
|
||||
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
@@ -11409,6 +11423,13 @@ strip-ansi@^4.0.0:
|
||||
dependencies:
|
||||
ansi-regex "^3.0.0"
|
||||
|
||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
|
||||
strip-ansi@^7.0.1:
|
||||
version "7.1.0"
|
||||
resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
|
||||
@@ -12734,7 +12755,7 @@ widest-line@^3.1.0:
|
||||
dependencies:
|
||||
string-width "^4.0.0"
|
||||
|
||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
|
||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
@@ -12752,6 +12773,15 @@ wrap-ansi@^6.0.1:
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrap-ansi@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
dependencies:
|
||||
ansi-styles "^4.0.0"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrap-ansi@^8.1.0:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
|
||||
|
||||
Reference in New Issue
Block a user