diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index e95cffd11..9756df5bb 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -17,6 +17,13 @@ const paths = require("./paths"); const publicPath = "/"; const env = getClientEnvironment("/","development"); +const process = require('process'); + +process.on('uncaughtException', function (err) { + // 开发时,websocket proxy 会因服务重新部署而报错中断本地 server,这里拦截一下 + console.log('拦截未处理异常:', err); +}); + module.exports = { optimization: { splitChunks: { @@ -273,12 +280,11 @@ module.exports = { reactPath:'react.production.min.js', }), new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw), - // Add module names to factory functions so they appear in browser profiler. new webpack.NamedModulesPlugin(), // Makes some environment variables available to the JS code, for example: // if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`. - new webpack.DefinePlugin(env.stringified), + new webpack.DefinePlugin({ ...env.stringified, __SERVER__: 'false',__CLIENT__: 'true' }), // This is necessary to emit hot updates (currently CSS only): new webpack.HotModuleReplacementPlugin(), // Watcher doesn't work well if you mistype casing in a path so we use diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index a7811c3a1..98c2f41b7 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -294,6 +294,7 @@ module.exports = { minifyURLs: true, }, }), + new webpack.DefinePlugin({ ...env.stringified, __SERVER__: 'false',__CLIENT__: 'true' }), new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw), // Makes some environment variables available to the JS code, for example: // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`. diff --git a/package-lock.json b/package-lock.json index be7f27fb4..53001c72b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11029,6 +11029,11 @@ "resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.1.tgz", "integrity": "sha512-Rdgz9Hl9Iv4QKi8b0OlCRQEzp4AgVxyCtz5S/+VIHezDmrDhkp2N2TqBWOLz0/gbeREXOOiI9/4b8BY9uw2vFg==" }, + "keypress": { + "version": "0.1.0", + "resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz", + "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA==" + }, "killable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", @@ -12777,6 +12782,24 @@ "pinkie": "^2.0.0" } }, + "pinyin": { + "version": "4.0.0-alpha.0", + "resolved": "https://registry.npmmirror.com/pinyin/-/pinyin-4.0.0-alpha.0.tgz", + "integrity": "sha512-hdxO/2RuLWarhLaIcGKdXjkFZ0hFr3W/Yrvrd0YPxuIafixMZSAa4jvxskYLgYHE8OkOXkGsxMsEScwGzqKe3g==", + "requires": { + "commander": "~1.1.1" + }, + "dependencies": { + "commander": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz", + "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==", + "requires": { + "keypress": "0.1.x" + } + } + } + }, "pkg-dir": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", diff --git a/package.json b/package.json index a6fe11241..c78b0e864 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "nvm": "0.0.4", "object-assign": "4.1.1", "papaparse": "^5.3.2", + "pinyin": "^4.0.0-alpha.0", "postcss-flexbugs-fixes": "3.2.0", "promise": "8.0.1", "prop-types": "^15.6.1", diff --git a/src/common/UrlTool.js b/src/common/UrlTool.js index e45ae6ba2..a7bba73cb 100644 --- a/src/common/UrlTool.js +++ b/src/common/UrlTool.js @@ -1,6 +1,7 @@ import React from "react"; import md5 from 'md5'; import {Input} from "antd"; +import { url as ssrOrigin, host as ssrHost } from '../ssrUrl' const { Search } = Input; const $ = window.$; @@ -198,7 +199,7 @@ function railsgettimess(proxy) { } }}) - window.setTimeout(function () { + setTimeout(function () { checkSubmitFlgs=false; }, 2500); } @@ -345,15 +346,15 @@ export function addMeta(name, content){ */ export function setSeoMeta(keyWords, title, description, url, owner, projectId) { // 服务端没有location - const host = window.location.host - const origin = window.location.origin - document.querySelector(`meta[property='og:title']`).content = title + ' | GitLink'; - document.querySelector(`title`).textContent = title + ' | GitLink'; + const host = window.location.host === 'null' || !window.location.host ? ssrHost : window.location.host + const origin = window.location.origin === 'null' || !window.location.origin ? ssrOrigin : window.location.origin + document.querySelector(`meta[property='og:title']`).content = title; + document.querySelector(`title`).textContent = title; document.querySelector(`meta[property='og:url']`).content = origin + url; - document.querySelector(`meta[property='og:description']`).content = description + ' | GitLink'; - document.querySelector(`meta[property='og:image:alt']`).content = description + ' | GitLink'; - document.querySelector('meta[name="Keywords"]').content= `${ keyWords },${ keyWords ? '' : 'GitLink, git, 开源, 代码托管, 项目管理, 版本控制, 代码分享, 项目协作, 协同开发平台' }` ; - document.querySelector(`meta[name='description']`).content = description + ' | GitLink'; + document.querySelector(`meta[property='og:description']`).content = description; + document.querySelector(`meta[property='og:image:alt']`).content = description; + document.querySelector('meta[name="Keywords"]').content= `${ keyWords }${ keyWords ? '' : 'GitLink, git, 开源, 代码托管, 项目管理, 版本控制, 代码分享, 项目协作, 协同开发平台' }` ; + document.querySelector(`meta[name='description']`).content = description; document.querySelector(`meta[name='go-import']`).content = host + url + ' git ' + origin + url; document.querySelector(`meta[name='octolytics-dimension-user_login']`).content = owner; if (projectId) { diff --git a/src/forge/Badge/Index.jsx b/src/forge/Badge/Index.jsx index 121267d50..a84fc8a54 100644 --- a/src/forge/Badge/Index.jsx +++ b/src/forge/Badge/Index.jsx @@ -29,7 +29,7 @@ function Badge(props) { } else { setProjectDetail(result.data); // seo优化设置 - let keyWords = `${owner},${projectsId},${result.data.author.name},`; + let keyWords = `${owner},${projectsId},${result.data.author.name}`; let title = `${owner}/${projectsId}${result.data.description ? ':' + result.data.description : ''}`; setSeoMeta(keyWords, title, result.data.description, `/${owner}/${projectsId}`, owner, projectsId); } diff --git a/src/forge/Information/Component/partner.jsx b/src/forge/Information/Component/partner.jsx index 03d1d3940..b07cb3590 100644 --- a/src/forge/Information/Component/partner.jsx +++ b/src/forge/Information/Component/partner.jsx @@ -1,5 +1,5 @@ import React , { useEffect } from 'react'; -import Slider from 'react-slick'; +// import Slider from 'react-slick'; import { httpUrl } from '../fetch'; import axios from 'axios'; import { useState } from 'react'; diff --git a/src/forge/Information/Pages/apply.jsx b/src/forge/Information/Pages/apply.jsx index 5f020e6eb..400f08649 100644 --- a/src/forge/Information/Pages/apply.jsx +++ b/src/forge/Information/Pages/apply.jsx @@ -1,8 +1,9 @@ import React, { useEffect } from 'react'; -import { Form , Input , Row , Col, Button } from 'antd'; +import { Form , Input , Row , Col, Button, message } from 'antd'; import '../index.scss'; import { postCreateZone } from '../api'; import axios from 'axios'; + const { TextArea } = Input; const phonereg = /^([1][3456789])\d{9}$/ @@ -25,10 +26,10 @@ function Apply(props){ const zoneApplication = {...values}; postCreateZone(zoneApplication).then(response=>{ if(response && response.data && response.data.code===200){ - props.showNotification("提交成功!"); + message.success("您的专区申请已提交,请耐心等待管理员与您联系!"); setTimeout(() => { window.location.href="/"; - }, 70); + }, 1000); } }).catch(error=>{}) } @@ -55,6 +56,7 @@ function Apply(props){ callback(); }):callback(); } + return( @@ -72,9 +74,12 @@ function Apply(props){ label="专区名称" > {getFieldDecorator("name",{ - rules:[{required:true,message:"请输入专区名称"}] + rules:[ + {required:true,message:"请输入专区名称"}, + {pattern: /^[a-zA-Z0-9\u4e00-\u9fa5\\_.-]{1,31}$/, message: "长度1-30,支持中文,英文,数字,可包含下划线(_),中划线(-),英文句号(.)"} + ] })( - + )}
{data.homepageCmsTitle}
申请说明