Skip to content

Commit

Permalink
chore: refactor preset
Browse files Browse the repository at this point in the history
  • Loading branch information
ilimei committed Dec 10, 2023
1 parent 5d4b2b8 commit a0e3030
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
26 changes: 15 additions & 11 deletions scripts/preset-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@ const { distFolder, sleep } = require('./common');

const LAKE_EDITOR_VERSION = '1.11.0';

const lakeIconURL = 'https://mdn.alipayobjects.com/design_kitchencore/afts/file/HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr';

const remoteAssetsUrls = {
lakejs: {
src: `https://gw.alipayobjects.com/render/p/yuyan_npm/@alipay_lakex-doc/${LAKE_EDITOR_VERSION}/umd/doc.umd.js`,
after: (content) => {
return content.replace(`https://mdn.alipayobjects.com/design_kitchencore/afts/file/HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr`, './HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr');
return content.replace(lakeIconURL, './lake-editor-icon.js');
},
},
lakecss: `https://gw.alipayobjects.com/render/p/yuyan_npm/@alipay_lakex-doc/${LAKE_EDITOR_VERSION}/umd/doc.css`,
antdcss: 'https://gw.alipayobjects.com/os/lib/antd/4.24.13/dist/antd.css',
lakeIcon: 'https://mdn.alipayobjects.com/design_kitchencore/afts/file/HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr',
antdcss: {
src: 'https://gw.alipayobjects.com/os/lib/antd/4.24.13/dist/antd.css',
name: 'antd.4.24.13.css',
},
lakeIcon: {
src: lakeIconURL,
name: 'lake-editor-icon.js',
},
codemirror: 'https://gw.alipayobjects.com/render/p/yuyan_v/180020010000005484/7.1.4/CodeMirror.js',
tracert_a385: 'https://ur.alipay.com/tracert_a385.js',
};
Expand Down Expand Up @@ -65,14 +73,10 @@ module.exports.presetEditor = async function main() {

const urls = Object.values(remoteAssetsUrls);
for (let i = 0; i < urls.length; i++) {
let url = urls[i];
let afterLoad = null;
if(typeof url !== 'string') {
afterLoad = url.after;
url = url.src;
}
console.info('url', url);
const fileName = url.split('/').pop();
const asset = urls[i];
const url = typeof asset === 'string' ? asset : asset.src;
const afterLoad = typeof asset === 'string' ? null : asset.after;
const fileName = asset.name || url.split('/').pop();
const localFilename = path.resolve(distFolder, fileName);
mkdirSync(distFolder, { recursive: true });
await downloadFile(url, localFilename, afterLoad);
Expand Down
4 changes: 2 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"CodeMirror.js",
"katex.min.js",
"tracert_a385.js",
"antd.css",
"HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr",
"antd.4.24.13.css",
"lake-editor-icon.js",
"react.production.min.js",
"react-dom.production.min.js",
"yuque-transform-script.js"
Expand Down

0 comments on commit a0e3030

Please sign in to comment.