Skip to content

Commit

Permalink
can not modify material theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Javey committed Aug 6, 2019
1 parent db2010f commit 8244ca3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
15 changes: 11 additions & 4 deletions app/controllers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,20 @@ module.exports = Advanced.Controller.extend({
async _initTemplateById(id) {
const _id = id;

if (!id) id = shortId();
const isMaterial = id === 'material';
const shouldCopy = !id || isMaterial;
if (shouldCopy) id = shortId();
const path = Utils.c('theme') + '/' + id;

if (_id && !await fsExtra.pathExists(path)) {
if (shouldCopy) {
await fsExtra.copy(
isMaterial ?
Utils.c('theme') + '/material' :
Utils.c('stylusTemplate'),
path
);
} else if (!await fsExtra.pathExists(path)) {
throw `ID: ${id} does not exist.`;
} else if (!_id) {
await fsExtra.copy(Utils.c('stylusTemplate'), path);
}

return {path, id};
Expand Down
3 changes: 2 additions & 1 deletion data/themes/material/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ else
@require('./tip.variables.styl')
@require('./tooltip.variables.styl')
@require('./upload.variables.styl')
@require('./tree.variables.styl')
@require('./tree.variables.styl')
@require('./layout.variables.styl')
13 changes: 8 additions & 5 deletions src/pages/opera/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ export default class Index extends Intact {
req.keys().forEach(key => {
if (key.startsWith(`./components/${componentName}/`)) {
const Demo = req(key);
Demos.push({
Demo: Demo.default,
data: Demo.data.setting,
index: Demo.data.index,
});
// ignore iframe demo
if (Demo.data) {
Demos.push({
Demo: Demo.default,
data: Demo.data.setting,
index: Demo.data.index,
});
}
}
});
this.set({Demos: Demos.sort((a, b) => {
Expand Down

0 comments on commit 8244ca3

Please sign in to comment.