mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-17 16:38:18 +00:00
client: config: migrate to ESM
This commit is contained in:
parent
6b049d954b
commit
54c89e52f8
3 changed files with 30 additions and 39 deletions
|
|
@ -124,7 +124,7 @@ export default {
|
|||
[`${modules}/view`]: `${dirModules}/view/index.js`,
|
||||
[`${modules}/help`]: `${dirModules}/help.js`,
|
||||
[`${modules}/markdown`]: `${dirModules}/markdown.js`,
|
||||
[`${modules}/config`]: `${dirModules}/config/index.js`,
|
||||
[`${modules}/config`]: `${dirModules}/config/index.mjs`,
|
||||
[`${modules}/contact`]: `${dirModules}/contact.js`,
|
||||
[`${modules}/upload`]: `${dirModules}/upload.js`,
|
||||
[`${modules}/operation`]: `${dirModules}/operation/index.mjs`,
|
||||
|
|
|
|||
|
|
@ -1,29 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
/* global CloudCmd, DOM, io */
|
||||
require('../../../css/config.css');
|
||||
import rendy from 'rendy';
|
||||
import currify from 'currify';
|
||||
import wraptile from 'wraptile';
|
||||
import squad from 'squad';
|
||||
import {promisify} from 'es6-promisify';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import load from 'load.js';
|
||||
import createElement from '@cloudcmd/create-element';
|
||||
import * as Events from '#dom/events';
|
||||
import '../../../css/config.css';
|
||||
import * as input from './input.mjs';
|
||||
import * as Images from '../../dom/images.mjs';
|
||||
import Files from '../../dom/files.js';
|
||||
import {getTitle} from '../../../common/cloudfunc.mjs';
|
||||
|
||||
const rendy = require('rendy');
|
||||
const currify = require('currify');
|
||||
const wraptile = require('wraptile');
|
||||
const squad = require('squad');
|
||||
const {promisify} = require('es6-promisify');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const load = require('load.js');
|
||||
const createElement = require('@cloudcmd/create-element');
|
||||
|
||||
const input = require('./input');
|
||||
const Images = require('../../dom/images.mjs');
|
||||
const Events = require('#dom/events');
|
||||
const Files = require('../../dom/files');
|
||||
|
||||
const {getTitle} = require('../../../common/cloudfunc.mjs');
|
||||
const {Dialog, setTitle} = DOM;
|
||||
|
||||
const Name = 'Config';
|
||||
|
||||
CloudCmd[Name] = module.exports;
|
||||
|
||||
const loadSocket = promisify(DOM.loadSocket);
|
||||
|
||||
const showLoad = () => {
|
||||
|
|
@ -46,7 +40,7 @@ let Template;
|
|||
|
||||
const loadCSS = load.css;
|
||||
|
||||
module.exports.init = async () => {
|
||||
export const init = async () => {
|
||||
if (!CloudCmd.config('configDialog'))
|
||||
return;
|
||||
|
||||
|
|
@ -118,9 +112,7 @@ function authCheck(socket) {
|
|||
|
||||
Config.save = saveHttp;
|
||||
|
||||
module.exports.show = show;
|
||||
|
||||
async function show() {
|
||||
export async function show() {
|
||||
if (!CloudCmd.config('configDialog'))
|
||||
return;
|
||||
|
||||
|
|
@ -183,9 +175,7 @@ async function fillTemplate() {
|
|||
});
|
||||
}
|
||||
|
||||
module.exports.hide = hide;
|
||||
|
||||
function hide() {
|
||||
export function hide() {
|
||||
CloudCmd.View.hide();
|
||||
}
|
||||
|
||||
|
|
@ -246,3 +236,9 @@ async function onKey({keyCode, target}) {
|
|||
return await onChange(target);
|
||||
}
|
||||
}
|
||||
|
||||
CloudCmd[Name] = {
|
||||
init,
|
||||
show,
|
||||
hide,
|
||||
};
|
||||
|
|
@ -1,20 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
const currify = require('currify');
|
||||
import currify from 'currify';
|
||||
|
||||
const isType = currify((type, object, name) => type === typeof object[name]);
|
||||
|
||||
const isBool = isType('boolean');
|
||||
|
||||
module.exports.getElementByName = getElementByName;
|
||||
|
||||
function getElementByName(selector, element) {
|
||||
export function getElementByName(selector, element) {
|
||||
const str = `[data-name="js-${selector}"]`;
|
||||
|
||||
return element.querySelector(str);
|
||||
}
|
||||
|
||||
module.exports.getName = (element) => {
|
||||
export const getName = (element) => {
|
||||
const name = element
|
||||
.getAttribute('data-name')
|
||||
.replace(/^js-/, '');
|
||||
|
|
@ -22,7 +17,7 @@ module.exports.getName = (element) => {
|
|||
return name;
|
||||
};
|
||||
|
||||
module.exports.convert = (config) => {
|
||||
export const convert = (config) => {
|
||||
const result = config;
|
||||
const array = Object.keys(config);
|
||||
|
||||
|
|
@ -43,7 +38,7 @@ function setState(state) {
|
|||
return '';
|
||||
}
|
||||
|
||||
module.exports.getValue = (name, element) => {
|
||||
export const getValue = (name, element) => {
|
||||
const el = getElementByName(name, element);
|
||||
const {type} = el;
|
||||
|
||||
|
|
@ -59,7 +54,7 @@ module.exports.getValue = (name, element) => {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports.setValue = (name, value, element) => {
|
||||
export const setValue = (name, value, element) => {
|
||||
const el = getElementByName(name, element);
|
||||
const {type} = el;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue