Skip to content
Prev Previous commit
Next Next commit
mod:tag标签固定颜色
  • Loading branch information
zhenbushidashen committed Jun 11, 2020
commit e97404a3c72317afa355b5d7c6842aed82b1a68c
4 changes: 3 additions & 1 deletion scripts/generateleetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ const genertateLeetcodeToJson = () => {

preKnowledge.push({
text: $1,
link: null,
color:'red'
})
})

markdown.replace(Utils.getSatelliteDataReg().keyPoints, (noUseMatch, $1) => {
keyPoints = $1.replace(/\s/g, '').split('-').filter(s => (s && s !== '解析')).map(s => ({ text: s, link: null }))
keyPoints = $1.replace(/\s/g, '').split('-').filter(s => (s && s !== '解析')).map(s => ({ text: s, link: null, color:'blue' }))

})

Expand Down
19 changes: 10 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import "./App.css";

const { TabPane } = Tabs;
const { Panel } = Collapse;
const { problems, tags: tagMapper } = db;
const dataSource = Object.values(problems);

const formatCodeToMarkDown = (code,lang) => `\`\`\`${lang}\n${code}\`\`\`\n`

function TagOrLink({ link, text }) {
const { problems } = db;
const dataSource = Object.values(problems);

function TagOrLink({ link, text, style, color }) {
return link !== null ? (
<a className="link" href={link} rel="noopener noreferrer" target="_blank">
<Button type="link">{text}</Button>
Expand Down Expand Up @@ -95,13 +96,13 @@ function App() {
{show ? (
<Tabs defaultActiveKey="0">
<TabPane tab="前置知识" key="0">
{problems[problemId].pre.map(({ id, link, text, tag }) => (
<TagOrLink key={id} text={text} link={link} color={tag.color} />
{problems[problemId].pre.map(({ id, link, text, color }) => (
<TagOrLink key={id} text={text} link={link} color={color} />
))}
</TabPane>
<TabPane tab="关键点" key="1">
{problems[problemId].keyPoints.map(({ id, link, text, tag }) => (
<TagOrLink key={text} text={text} link={link} color={tag.color} />
{problems[problemId].keyPoints.map(({ id, link, text, color }) => (
<TagOrLink key={text} text={text} link={link} color={color} />
))}
</TabPane>
<TabPane tab="题解" key="2">
Expand All @@ -118,8 +119,8 @@ function App() {
<div className="code-block">
<Collapse>
{problems[problemId].code.map((c) => (
<Panel header={
<div className="row" style={{ marginTop: "10px" }}>
<Panel>
<div key={c.text} className="row" style={{ marginTop: "10px" }}>
<span className="language language-js">{c.language}</span>
<Button
type="primary"
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.