mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-04-06 03:58:05 +08:00
feat: 更新valine方案
This commit is contained in:
parent
69316d469d
commit
9aa504c325
@ -1,42 +0,0 @@
|
|||||||
import { IApi } from 'dumi';
|
|
||||||
|
|
||||||
export default (api: IApi) => {
|
|
||||||
api.describe({
|
|
||||||
key: 'valine',
|
|
||||||
config: {
|
|
||||||
schema(joi) {
|
|
||||||
return joi.object();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { valine = {} } = api.userConfig;
|
|
||||||
const { appId, appKey, el = '#vcomments' } = valine || {};
|
|
||||||
api.logger.log('insert Valine');
|
|
||||||
|
|
||||||
const valineScript = () => {
|
|
||||||
return `
|
|
||||||
(function(){
|
|
||||||
var script = document.createElement('script');
|
|
||||||
var m = document.getElementsByTagName('script')[0];
|
|
||||||
script.src = '//unpkg.com/valine/dist/Valine.min.js';
|
|
||||||
script.async = 'async';
|
|
||||||
|
|
||||||
script.addEventListener('load', function () {
|
|
||||||
new Valine({
|
|
||||||
el: '${el}',
|
|
||||||
appId: '${appId}',
|
|
||||||
appKey: '${appKey}'
|
|
||||||
})
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
m.parentNode.insertBefore(script, m)
|
|
||||||
})();
|
|
||||||
`;
|
|
||||||
};
|
|
||||||
|
|
||||||
api.addHTMLScripts(() => [
|
|
||||||
{
|
|
||||||
content: valineScript(),
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
};
|
|
@ -5,6 +5,7 @@ import Navbar from 'dumi-theme-default/src/components/Navbar';
|
|||||||
import SideMenu from 'dumi-theme-default/src/components/SideMenu';
|
import SideMenu from 'dumi-theme-default/src/components/SideMenu';
|
||||||
import SlugList from 'dumi-theme-default/src/components/SlugList';
|
import SlugList from 'dumi-theme-default/src/components/SlugList';
|
||||||
import SearchBar from 'dumi-theme-default/src/components/SearchBar';
|
import SearchBar from 'dumi-theme-default/src/components/SearchBar';
|
||||||
|
import { ValineComment } from 'dumi';
|
||||||
import Notice from './Notice';
|
import Notice from './Notice';
|
||||||
import './style/layout.less';
|
import './style/layout.less';
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ const Layout: React.FC<IRouteComponentProps> = ({ children, location }) => {
|
|||||||
{updatedTime}
|
{updatedTime}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="vcomments"></div>
|
<ValineComment location={location} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{(showHero || showFeatures) && meta.footer && (
|
{(showHero || showFeatures) && meta.footer && (
|
||||||
|
21
.dumi/theme/plugin-valine/Comment.tpl
Normal file
21
.dumi/theme/plugin-valine/Comment.tpl
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import Valine from 'valine';
|
||||||
|
|
||||||
|
export function ValineComment({ location }) {
|
||||||
|
const { pathname } = location;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
import('valine').then(Valine => {
|
||||||
|
console.log(Valine)
|
||||||
|
new Valine.default({
|
||||||
|
el: '{{{ el }}}',
|
||||||
|
appId: '{{{ appId }}}',
|
||||||
|
appKey: '{{{ appKey }}}'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}, [pathname])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div id="vcomments"/>
|
||||||
|
)
|
||||||
|
}
|
52
.dumi/theme/plugin-valine/index.ts
Normal file
52
.dumi/theme/plugin-valine/index.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { IApi } from 'dumi';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
export default (api: IApi) => {
|
||||||
|
const {
|
||||||
|
paths,
|
||||||
|
utils: { Mustache, winPath, lodash },
|
||||||
|
} = api;
|
||||||
|
|
||||||
|
api.describe({
|
||||||
|
key: 'valine',
|
||||||
|
config: {
|
||||||
|
default: {
|
||||||
|
el: '#vcomments',
|
||||||
|
appId: '',
|
||||||
|
appKey: '',
|
||||||
|
},
|
||||||
|
schema(joi) {
|
||||||
|
return joi.object({
|
||||||
|
el: joi.string(),
|
||||||
|
appId: joi.string(),
|
||||||
|
appKey: joi.string(),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 生成临时文件
|
||||||
|
api.onGenerateFiles(async () => {
|
||||||
|
// Comment.tsx
|
||||||
|
const selectLang = readFileSync(join(__dirname, 'Comment.tpl'), 'utf-8');
|
||||||
|
|
||||||
|
const { appId, appKey, el = '#vcomments' } = api.userConfig.valine;
|
||||||
|
|
||||||
|
api.writeTmpFile({
|
||||||
|
path: 'plugin-valine/Comment.tsx',
|
||||||
|
content: Mustache.render(selectLang, {
|
||||||
|
el: el,
|
||||||
|
appId: appId,
|
||||||
|
appKey: appKey,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
api.addUmiExports(() => {
|
||||||
|
return {
|
||||||
|
exportAll: true,
|
||||||
|
source: `../plugin-valine/Comment`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
@ -91,7 +91,7 @@ export default defineConfig({
|
|||||||
appId: 'Ke6Uq74Gi6sdTxcDu4nJ6sdw-MdYXbMMI',
|
appId: 'Ke6Uq74Gi6sdTxcDu4nJ6sdw-MdYXbMMI',
|
||||||
appKey: 'VtFD26towQ1JQxB9tLHd8odg',
|
appKey: 'VtFD26towQ1JQxB9tLHd8odg',
|
||||||
},
|
},
|
||||||
plugins: ['./.dumi/theme/comment.ts'],
|
plugins: ['./.dumi/theme/plugin-valine/index.ts'],
|
||||||
exportStatic: {},
|
exportStatic: {},
|
||||||
// more config: https://d.umijs.org/config
|
// more config: https://d.umijs.org/config
|
||||||
});
|
});
|
||||||
|
@ -8,8 +8,8 @@ order: 4
|
|||||||
|
|
||||||
遇到解决不了的问题,先删除`homebrew`目录再重新运行脚本安装。
|
遇到解决不了的问题,先删除`homebrew`目录再重新运行脚本安装。
|
||||||
|
|
||||||
- x86 上安装目录: /usr/local/Homebrew/
|
- x86 上安装目录: `/usr/local/Homebrew/`
|
||||||
- arm 上安装目录: /opt/homebrew
|
- arm 上安装目录: `/opt/homebrew`
|
||||||
|
|
||||||
## M1 芯片 Mac 如何安装
|
## M1 芯片 Mac 如何安装
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "^4.5.0",
|
"@ant-design/icons": "^4.5.0",
|
||||||
"antd": "^4.13.1"
|
"antd": "^4.13.1",
|
||||||
|
"valine": "^1.4.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user