Skip to content

Commit

Permalink
feat: fix frontend ci (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
yehong-z authored Aug 12, 2023
1 parent cb1f8b8 commit 9c1b187
Show file tree
Hide file tree
Showing 27 changed files with 12,902 additions and 14,158 deletions.
21 changes: 21 additions & 0 deletions web/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,25 @@ module.exports = {
},
},
],
module: {
rules: [
{
test: /\.less$/,
use: [
"style-loader",
"css-loader",
"less-loader",
],
},
],
},
webpack: {
configure: {
resolve: {
fallback: {
"path": false,
},
},
},
},
};
7 changes: 5 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"braft-editor": "^2.3.9",
"browser-image-size": "^1.1.0",
"casdoor-js-sdk": "^0.5.1",
"classnames": "^2.3.2",
"codemirror": "^5.54.0",
"craco-less": "^2.0.0",
"i18next": "^19.6.0",
Expand Down Expand Up @@ -49,7 +50,7 @@
"crowdin:sync": "crowdin upload && crowdin download",
"preinstall": "node -e \"if (process.env.npm_execpath.indexOf('yarn') === -1) throw new Error('Use yarn for installing: https://yarnpkg.com/en/docs/install')\"",
"fix": "eslint --fix src/**/*.{js,jsx,ts,tsx}",
"lint:css": "stylelint src/**/*.{css,less} --fix"
"lintcss": "stylelint src/**/*.{css,scss} --fix --custom-syntax postcss-scss"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -69,12 +70,14 @@
"devDependencies": {
"@babel/core": "^7.18.13",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-react": "^7.18.6",
"eslint": "8.22.0",
"eslint": "^8.47.0",
"eslint-plugin-react": "^7.31.1",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^4.3.8",
"lint-staged": "^13.0.3",
"postcss-scss": "^4.0.6",
"stylelint": "^14.11.0",
"stylelint-config-recommended-less": "^1.0.4",
"stylelint-config-standard": "^28.0.0"
Expand Down
2 changes: 1 addition & 1 deletion web/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import React, {Component} from "react";
import classNames from "classnames";
import "./App.less";
import "codemirror/lib/codemirror.css";
import {BackTop, Spin} from "antd";
import "./App.less";
import * as Setting from "./Setting";
import {Route, Switch} from "react-router-dom";
import TopicPage from "./TopicPage";
Expand Down
2 changes: 1 addition & 1 deletion web/src/App.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*@import "~antd/lib/back-top/style/index.css";*/
@import "~antd/dist/antd.less";
@import "~antd/dist/reset.css";

#logo {
width: 94px;
Expand Down
24 changes: 12 additions & 12 deletions web/src/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ class Avatar extends React.Component {
render() {
let style;
switch (this.props.size) {
case "small":
style = {width: "24px", height: "24px"};
break;
case "middle":
style = {width: "36px", height: "36px"};
break;
case "large":
style = {width: "73px", height: "73px"};
break;
default:
style = {width: "48px", height: "48px"};
break;
case "small":
style = {width: "24px", height: "24px"};
break;
case "middle":
style = {width: "36px", height: "36px"};
break;
case "large":
style = {width: "73px", height: "73px"};
break;
default:
style = {width: "48px", height: "48px"};
break;
}

let src;
Expand Down
28 changes: 14 additions & 14 deletions web/src/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,20 @@ class Header extends React.Component {
renderSearchEngine() {
let searchUrl;
switch (Conf.DefaultSearchSite) {
case "google":
case "Google":
searchUrl = `https://www.google.com/search?q=site:${Conf.Domain}/t ${this.state.searchValue}`;
break;
case "bing":
case "Bing":
searchUrl = `https://cn.bing.com/search?q=site:${Conf.Domain}/t ${this.state.searchValue}`;
break;
case "baidu":
case "Baidu":
searchUrl = `https://www.baidu.com/s?q6=${Conf.Domain}&q3=${this.state.searchValue}`;
break;
default:
searchUrl = "/search?keyword=" + this.state.searchValue;
case "google":
case "Google":
searchUrl = `https://www.google.com/search?q=site:${Conf.Domain}/t ${this.state.searchValue}`;
break;
case "bing":
case "Bing":
searchUrl = `https://cn.bing.com/search?q=site:${Conf.Domain}/t ${this.state.searchValue}`;
break;
case "baidu":
case "Baidu":
searchUrl = `https://www.baidu.com/s?q6=${Conf.Domain}&q3=${this.state.searchValue}`;
break;
default:
searchUrl = "/search?keyword=" + this.state.searchValue;
}

return (
Expand Down
2 changes: 1 addition & 1 deletion web/src/admin/AdminFooterEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class AdminFrontConf extends React.Component {

getContent(id) {
ConfBackend.getFrontConfById(id).then((res) => {
console.log(res.data.value);
this.setState({
content: res.data.value,
});
Expand All @@ -77,6 +76,7 @@ class AdminFrontConf extends React.Component {

getFrontConf(id) {
ConfBackend.getFrontConfById(id).then((res) => {
// eslint-disable-next-line no-console
console.log(res.data[0]);
});
}
Expand Down
48 changes: 24 additions & 24 deletions web/src/admin/AdminFrontConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,30 @@ class AdminFrontConf extends React.Component {
convert(s) {
let str;
switch (s) {
case "forumName":
str = i18next.t("frontConf:Forum name");
break;
case "logoImage":
str = i18next.t("frontConf:Logo image");
break;
case "footerLogoImage":
str = i18next.t("frontConf:Footer Logo image");
break;
case "footerLogoUrl":
str = i18next.t("frontConf:Footer Logo URL");
break;
case "signinBoxStrong":
str = i18next.t("frontConf:Right title");
break;
case "signinBoxSpan":
str = i18next.t("frontConf:Right subtitle");
break;
case "footerDeclaration":
str = i18next.t("frontConf:Footer title");
break;
case "footerAdvise":
str = i18next.t("frontConf:Footer subtitle");
break;
case "forumName":
str = i18next.t("frontConf:Forum name");
break;
case "logoImage":
str = i18next.t("frontConf:Logo image");
break;
case "footerLogoImage":
str = i18next.t("frontConf:Footer Logo image");
break;
case "footerLogoUrl":
str = i18next.t("frontConf:Footer Logo URL");
break;
case "signinBoxStrong":
str = i18next.t("frontConf:Right title");
break;
case "signinBoxSpan":
str = i18next.t("frontConf:Right subtitle");
break;
case "footerDeclaration":
str = i18next.t("frontConf:Footer title");
break;
case "footerAdvise":
str = i18next.t("frontConf:Footer subtitle");
break;
}
return str;
}
Expand Down
68 changes: 34 additions & 34 deletions web/src/admin/AdminNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,26 +441,26 @@ class AdminNode extends React.Component {

let value, data;
switch (item) {
case "node":
value = this.getIndexFromNodeId(this.state.form.parentNode);
data = this.state.nodes.map((node, i) => {
return {text: `${node.nodeInfo.name} / ${node.nodeInfo.id}`, id: i};
});
break;
case "tab":
value = this.getIndexFromTabId(this.state.form.tab);
data = this.state.tabs.map((tab, i) => {
return {text: `${tab.name} / ${tab.id}`, id: i};
});
break;
case "plane":
value = this.getIndexFromPlaneId(this.state.form.planeId);
data = this.state.planes.map((plane, i) => {
return {text: `${plane.name} / ${plane.id}`, id: i};
});
break;
default:
break;
case "node":
value = this.getIndexFromNodeId(this.state.form.parentNode);
data = this.state.nodes.map((node, i) => {
return {text: `${node.nodeInfo.name} / ${node.nodeInfo.id}`, id: i};
});
break;
case "tab":
value = this.getIndexFromTabId(this.state.form.tab);
data = this.state.tabs.map((tab, i) => {
return {text: `${tab.name} / ${tab.id}`, id: i};
});
break;
case "plane":
value = this.getIndexFromPlaneId(this.state.form.planeId);
data = this.state.planes.map((plane, i) => {
return {text: `${plane.name} / ${plane.id}`, id: i};
});
break;
default:
break;
}

return (
Expand All @@ -479,20 +479,20 @@ class AdminNode extends React.Component {

const index = parseInt(s);
switch (item) {
case "node":
const nodeId = this.state.nodes[index].nodeInfo.id;
this.updateFormField("parentNode", nodeId);
break;
case "tab":
const tab = this.state.tabs[index].id;
this.updateFormField("tab", tab);
break;
case "plane":
const planeId = this.state.planes[index].id;
this.updateFormField("planeId", planeId);
break;
default:
break;
case "node":
const nodeId = this.state.nodes[index].nodeInfo.id;
this.updateFormField("parentNode", nodeId);
break;
case "tab":
const tab = this.state.tabs[index].id;
this.updateFormField("tab", tab);
break;
case "plane":
const planeId = this.state.planes[index].id;
this.updateFormField("planeId", planeId);
break;
default:
break;
}
}}
options={{
Expand Down
Loading

0 comments on commit 9c1b187

Please sign in to comment.