微信分享

This commit is contained in:
黄心宇 2024-04-25 14:53:50 +08:00
parent 7a2580f51f
commit 176058e9b0
8 changed files with 22 additions and 22 deletions

View File

@ -16,7 +16,7 @@ const TerserWebpackPlugin = require('terser-webpack-plugin');
const paths = require("./paths");
const getClientEnvironment = require("./env");
let publicPath = "/react/build/";
let publicPath = "/build/";
const publicUrl = publicPath.slice(0, -1);
// const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
const shouldUseSourceMap = process.env.NODE_ENV !== "production";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -50,7 +50,7 @@
<script src="%PUBLIC_URL%js/codemirror/merge/merge.js"></script>
<script src="%PUBLIC_URL%js/alex/moment.js"></script>
<script src="https://gw.alipayobjects.com/os/lib/alipay/alex/2.0.19/bundle/alex.all.global.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<meta name="viewport" content="">
<%= htmlWebpackPlugin.tags.bodyTags %>
<script>

View File

@ -20,11 +20,12 @@ import SiderBar from './forge/Component/SiderBar';
import SiderBarHelp from './glcc/siderBarHelp';
// import GlccModal from './modules/glccModal';
import { SnackbarHOC } from 'educoder';
import { SnackbarHOC, configShareForCustom } from 'educoder';
import { initAxiosInterceptors } from './AppConfig'
import { Provider } from 'react-redux';
import configureStore from './redux/stores/configureStore';
import cookie from 'react-cookies';
const store = configureStore();
window.marked = marked;
@ -302,6 +303,9 @@ class App extends Component {
this.setState({
mygetHelmetapi: response.data.setting
});
configShareForCustom(response.data.name)
//存储配置到游览器
localStorage.setItem('chromesetting', JSON.stringify(response.data.setting));
localStorage.setItem('chromesettingresponse', JSON.stringify(response));

View File

@ -1,6 +1,7 @@
import axios from 'axios'
const host = window.location.protocol + '//' + window.location.host
const wx = window.wx
const appId = 'wxf8debe756b4a0309'
let settings = localStorage.chromesetting&&JSON.parse(localStorage.chromesetting);
let actionUrl = settings && settings.common.zone +'/api';
@ -12,11 +13,8 @@ const service = axios.create({
function share(shareData) {
try {
wx.onMenuShareAppMessage(shareData);//分享给好友
wx.onMenuShareTimeline(shareData);//分享到朋友圈
wx.onMenuShareQQ(shareData);//分享给手机QQ
wx.onMenuShareWeibo(shareData);//分享腾讯微博
wx.onMenuShareQZone(shareData);//分享到QQ空间
wx.updateAppMessageShareData(shareData);//分享给好友
wx.updateTimelineShareData(shareData);//分享到朋友圈
} catch(e) {
console.log(e)
}
@ -34,23 +32,20 @@ function requestForSignatrue (callback) {
urlDoneMap[currentUrl] = true
// window.encodeURIComponent()
service.post(url, {
url: 'https://www.gitlink.org.cn' || currentUrl,
url: currentUrl,
}).then((response) => {
console.log('got res')
const data = response.data && response.data.data;
wx.config({
debug: true,
appId: 'wxf8debe756b4a0309', // data.appid,
debug: false,
appId: appId, // data.appid,
timestamp: data.timestamp,
nonceStr: data.noncestr,
signature: data.signature,
jsApiList: [
'onMenuShareTimeline',//
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'onMenuShareQZone'
'updateAppMessageShareData',//
'updateTimelineShareData',
]
});
wx.ready(function () {
@ -135,11 +130,10 @@ export function configShareForCustom (title, desc, imgUrl, path) {
console.log('configShareForCustom', host)
const _url = window.location.href.split('#')[0];
var shareData = {
title: title,
desc: desc,
title: title || 'GitLink | 确实开源',
desc: desc || 'GitLink新一代开源创新服务平台',
link: path ? `${host}/${path}` : _url,
imgUrl: imgUrl || window.__testImageUrl
|| host + '/react/build/images/share_logo_icon.jpg'
imgUrl: imgUrl || host + '/build/images/share_logo_icon.png'
};
share(shareData)
})

View File

@ -28,7 +28,9 @@ function NewsDetail(props){
const { name, cmsDir, summary} = detail;
document.title = `${ name }/${ cmsDir.name }`;
addMeta('Keywords', `${ name },${ cmsDir.name },${ summary }`);
configShareForCustom(detail.name, detail.summary, detail.headImg)
setTimeout(() => {
configShareForCustom(detail.name, detail.summary, detail.headImg)
}, 1000);
}
if(isPhone() && zonedetail){
setTimeout(()=>{

View File

@ -143,7 +143,7 @@ function Index(props){
getAdminUrl(data.id);
getRole(data.id)
}
configShareForCustom(data.mainTitle, data.subTitle)
configShareForCustom(data.mainTitle, data.subTitle, data.introductionImage)
// deptIdheader
sessionStorage.setItem('deptId', data.deptId)
setSeoMeta(`${data.name},`, data.name, data.subTitle, `/zone/${deptId}`)