mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-08-13 08:44:03 +02:00
Refactor.
This commit is contained in:
@@ -1,51 +1,21 @@
|
||||
// const {jq} = require('./globals');
|
||||
// const config = require('./config');
|
||||
//
|
||||
// const name = jq('script[data-module]').data('module');
|
||||
// const query = {
|
||||
// action: 'get',
|
||||
// setup: true,
|
||||
// options: true,
|
||||
// types: true
|
||||
// };
|
||||
//
|
||||
// if (name === 'index') {
|
||||
// query.theme = true;
|
||||
// query.langs = true;
|
||||
// } else if (name === 'info') {
|
||||
// query.refresh = true;
|
||||
// } else {
|
||||
// throw new Error(`no-main-module: '${name}'`);
|
||||
// }
|
||||
//
|
||||
// config._update(query).then(() => {
|
||||
// jq(() => require(`./main/${name}`));
|
||||
// });
|
||||
const {jq} = require('./globals');
|
||||
const config = require('./config');
|
||||
|
||||
module.exports = (deps = {}) => {
|
||||
const {
|
||||
jq = require('./globals').jq,
|
||||
config = require('./config')
|
||||
} = deps;
|
||||
|
||||
const name = jq('script[data-module]').data('module');
|
||||
const query = {
|
||||
action: 'get',
|
||||
setup: true,
|
||||
options: true,
|
||||
types: true
|
||||
};
|
||||
|
||||
if (name === 'index') {
|
||||
query.theme = true;
|
||||
query.langs = true;
|
||||
} else if (name === 'info') {
|
||||
query.refresh = true;
|
||||
} else {
|
||||
throw new Error(`no-main-module: '${name}'`);
|
||||
}
|
||||
|
||||
config._update(query).then(() => {
|
||||
jq(() => require(`./main/${name}`));
|
||||
});
|
||||
const name = jq('script[data-module]').data('module');
|
||||
const query = {
|
||||
action: 'get',
|
||||
setup: true,
|
||||
options: true,
|
||||
types: true
|
||||
};
|
||||
|
||||
if (name === 'index') {
|
||||
query.theme = true;
|
||||
query.langs = true;
|
||||
} else if (name === 'info') {
|
||||
query.refresh = true;
|
||||
} else {
|
||||
throw new Error(`no-main-module: '${name}'`);
|
||||
}
|
||||
|
||||
config._update(query).then(() => jq(() => require(`./main/${name}`)));
|
||||
|
@@ -1,2 +1 @@
|
||||
const init = require('./lib/init');
|
||||
init();
|
||||
require('./lib/init');
|
||||
|
Reference in New Issue
Block a user