Skip to content

Commit

Permalink
add google indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
fesiong committed Mar 10, 2024
1 parent 4fb7bd5 commit c110ece
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 76 deletions.
4 changes: 2 additions & 2 deletions src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ const Dashboard: React.FC = () => {
<Col
flex={1}
onClick={() => {
handleJump('/content/page');
handleJump('/archive/page');
}}
>
<Statistic className="link" title="单页管理" value={data.page_count} />
</Col>
<Col
flex={1}
onClick={() => {
handleJump('/content/attachment');
handleJump('/archive/attachment');
}}
>
<Statistic className="link" title="图片管理" value={data.attachment_count} />
Expand Down
149 changes: 90 additions & 59 deletions src/pages/plugin/guestbook/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, message, Modal, Space } from 'antd';
import React, { useState, useRef } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import type { ProColumns, ActionType } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
Expand All @@ -8,6 +8,7 @@ import {
pluginDeleteGuestbook,
pluginExportGuestbook,
pluginGetGuestbooks,
pluginGetGuestbookSetting,
} from '@/services/plugin/guestbook';
import GuestbookForm from './components/guestbookForm';
import { exportFile } from '@/utils';
Expand All @@ -18,6 +19,94 @@ const PluginGuestbook: React.FC = () => {
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>([]);
const [currentGuestbook, setCurrentGuestbook] = useState<any>({});
const [editVisible, setEditVisible] = useState<boolean>(false);
const [setting, setSetting] = useState<any>({ fields: [] });
const [columns, setColumns] = useState<ProColumns<any>[]>([]);

useEffect(() => {
getSetting();
}, []);

const getSetting = async () => {
const res = await pluginGetGuestbookSetting();
let setting = res.data || { fields: [] };
setSetting(setting);
initColumns(setting.fields || []);
};

const initColumns = (fields: any[]) => {
let tmpColumns: ProColumns<any>[] = [
{
title: '时间',
width: 160,
dataIndex: 'created_time',
render: (text, record) => moment(record.created_time * 1000).format('YYYY-MM-DD HH:mm'),
},
];
if (fields.length == 0) {
tmpColumns.push(
{
title: '用户名',
width: 100,
dataIndex: 'user_name',
},
{
title: '联系方式',
width: 160,
dataIndex: 'contact',
},
{
title: '留言内容',
dataIndex: 'content',
render: (text, record) => <div style={{ wordBreak: 'break-all' }}>{text}</div>,
},
);
} else {
for (let i in fields) {
tmpColumns.push({
title: fields[i].name,
dataIndex: fields[i].field_name,
});
}
}
tmpColumns.push(
{
title: 'IP',
dataIndex: 'ip',
width: 100,
},
{
title: '操作',
width: 150,
dataIndex: 'option',
valueType: 'option',
render: (_, record) => (
<Space size={20}>
<a
key="check"
onClick={() => {
handlePreview(record);
}}
>
查看
</a>
<a
className="text-red"
key="delete"
onClick={async () => {
await handleRemove([record.id]);
setSelectedRowKeys([]);
actionRef.current?.reloadAndRest?.();
}}
>
删除
</a>
</Space>
),
},
);

setColumns(tmpColumns);
};

const handleRemove = async (selectedRowKeys: any[]) => {
Modal.confirm({
Expand Down Expand Up @@ -57,64 +146,6 @@ const PluginGuestbook: React.FC = () => {
exportFile(res.data?.header, res.data?.content, 'xls');
};

const columns: ProColumns<any>[] = [
{
title: '时间',
width: 160,
dataIndex: 'created_time',
render: (text, record) => moment(record.created_time * 1000).format('YYYY-MM-DD HH:mm'),
},
{
title: '用户名',
width: 100,
dataIndex: 'user_name',
},
{
title: '联系方式',
width: 160,
dataIndex: 'contact',
},
{
title: '留言内容',
dataIndex: 'content',
render: (text, record) => <div style={{ wordBreak: 'break-all' }}>{text}</div>,
},
{
title: 'IP',
dataIndex: 'ip',
width: 100,
},
{
title: '操作',
width: 150,
dataIndex: 'option',
valueType: 'option',
render: (_, record) => (
<Space size={20}>
<a
key="check"
onClick={() => {
handlePreview(record);
}}
>
查看
</a>
<a
className="text-red"
key="delete"
onClick={async () => {
await handleRemove([record.id]);
setSelectedRowKeys([]);
actionRef.current?.reloadAndRest?.();
}}
>
删除
</a>
</Space>
),
},
];

return (
<PageContainer>
<ProTable<any>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/plugin/htmlcache/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ const PluginHtmlCache: React.FC<any> = () => {
如果需要启用静态网站,则需要模板类型为自适应模板才行。开启静态网站需要填写静态网站服务器信息,通信成功后系统会自动传输静态页面到静态网站服务器。
</p>
<p>
启用静态网站前,需要开启静态页面缓存。启用静态网站后,搜索、留言、评论、301跳转等需要提交数据到后台的功能,均会失效,网站仅有展示效果。
启用静态网站前,<span className="text-red">需要先开启静态页面缓存</span>
。启用静态网站后,搜索、留言、评论、301跳转等需要提交数据到后台的功能,均会失效,网站仅有展示效果。
</p>
<div>
启用静态网站后,以下的操作不会自动重新生成,需要手动执行静态页面生成操作:
Expand Down
10 changes: 10 additions & 0 deletions src/pages/plugin/push/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ const PluginPush: React.FC<any> = (props) => {
extra="如:https://ssl.bing.com/webmaster/api.svc/json/SubmitUrlbatch?apikey=sampleapikeyEDECC1EA4AE341CC8B6(注意该APIkey在必应工具右上角的设置中设置)"
/>
</Card>
<Card size="small" title="谷歌账号密钥JSON" bordered={false}>
<ProFormTextArea
name="google_json"
label="JSON内容"
fieldProps={{
rows: 5,
}}
extra="国内无法使用。JSON获取请参考文档:https://www.anqicms.com/google-indexing-help.html"
/>
</Card>
<Card size="small" title="360/头条等JS自动提交" bordered={false}>
<ProTable<any>
actionRef={actionRef}
Expand Down
54 changes: 42 additions & 12 deletions src/pages/plugin/robots/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { pluginGetRobots, pluginSaveRobots } from '@/services/plugin/robots';
import { useModel } from 'umi';

const PluginRobots: React.FC<any> = (props) => {
const { initialState } = useModel('@@initialState');
const { initialState, setInitialState } = useModel('@@initialState');
const [pushSetting, setPushSetting] = useState<any>({});
const [fetched, setFetched] = useState<boolean>(false);

Expand All @@ -29,14 +29,43 @@ const PluginRobots: React.FC<any> = (props) => {
})
.catch((err) => {
console.log(err);
}).finally(() => {
})
.finally(() => {
hide();
});
};

const getFrontUrl = async (link: string) => {
let baseUrl = '';
if (!initialState.system) {
const system = await initialState?.fetchSystemSetting?.();
if (system) {
await setInitialState((s) => ({
...s,
system: system,
}));
}
baseUrl = system?.base_url || '';
} else {
baseUrl = initialState.system?.base_url || '';
}

return baseUrl + link;
};

return (
<PageHeaderWrapper>
<Card>
<Alert message="Robots是网站告诉搜索引擎蜘蛛哪些页面可以抓取,哪些页面不能抓取的配置" />
<Alert
message={
<div>
Robots是网站告诉搜索引擎蜘蛛哪些页面可以抓取,哪些页面不能抓取的配置。Q:{' '}
<a href="https://baike.baidu.com/item/robots%E5%8D%8F%E8%AE%AE/2483797">
robots.txt文件的格式
</a>
</div>
}
/>
<div className="mt-normal">
{fetched && (
<ProForm onFinish={onSubmit} initialValues={pushSetting}>
Expand All @@ -58,15 +87,16 @@ const PluginRobots: React.FC<any> = (props) => {
</ProForm>
)}
</div>
<div className='mt-normal'>
<Button
onClick={() => {
window.open(initialState.system?.base_url+'/robots.txt')
}}
>
查看Robots
</Button>
</div>
<div className="mt-normal">
<Button
onClick={async () => {
let url = await getFrontUrl('/robots.txt');
window.open(url);
}}
>
查看Robots
</Button>
</div>
</Card>
</PageHeaderWrapper>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/setting/safe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const SettingSafeFrom: React.FC<any> = (props) => {
/>
<ProFormRadio.Group
name="captcha"
label="留言评论验证码"
label="登陆/留言/评论验证码"
options={[
{
value: 0,
Expand All @@ -68,7 +68,7 @@ const SettingSafeFrom: React.FC<any> = (props) => {
label: '开启',
},
]}
extra="如需开启验证码,请参考验证码标签使用js调用刷新验证码和提交验证数据"
extra="如需开启验证码,请参考验证码标签使用js调用刷新验证码和提交验证数据。开启后,前台用户登录、留言、评论都需要验证码"
/>
<ProFormText
name="daily_limit"
Expand Down

0 comments on commit c110ece

Please sign in to comment.