mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: client: sort: migrate to ESM
This commit is contained in:
parent
e27ef51d43
commit
6e778a35ba
2 changed files with 20 additions and 12 deletions
|
|
@ -7,6 +7,7 @@ const wraptile = require('wraptile');
|
||||||
const load = require('load.js');
|
const load = require('load.js');
|
||||||
|
|
||||||
const {registerSW, listenSW} = require('./sw/register');
|
const {registerSW, listenSW} = require('./sw/register');
|
||||||
|
const {initSortPanel, sortPanel} = require('./sort.mjs');
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development';
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
|
|
||||||
|
|
@ -21,11 +22,12 @@ module.exports = async (config) => {
|
||||||
|
|
||||||
require('./listeners');
|
require('./listeners');
|
||||||
require('./key');
|
require('./key');
|
||||||
require('./sort');
|
|
||||||
|
|
||||||
|
initSortPanel();
|
||||||
|
globalThis.CloudCmd.sortPanel = sortPanel;
|
||||||
const prefix = getPrefix(config.prefix);
|
const prefix = getPrefix(config.prefix);
|
||||||
|
|
||||||
window.CloudCmd.init(prefix, config);
|
globalThis.CloudCmd.init(prefix, config);
|
||||||
|
|
||||||
if (window.CloudCmd.config('menu') === 'aleman')
|
if (window.CloudCmd.config('menu') === 'aleman')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,31 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/* global CloudCmd */
|
/* global CloudCmd */
|
||||||
const DOM = require('./dom');
|
import {fullstore} from 'fullstore';
|
||||||
|
import DOM from './dom/index.js';
|
||||||
|
|
||||||
const Info = DOM.CurrentInfo;
|
const sortPrevious = fullstore();
|
||||||
const {sort, order} = CloudCmd;
|
|
||||||
const position = DOM.getPanelPosition();
|
|
||||||
let sortPrevious = sort[position];
|
|
||||||
|
|
||||||
const {getPanel} = DOM;
|
const {getPanel} = DOM;
|
||||||
|
|
||||||
CloudCmd.sortPanel = (name, panel = getPanel()) => {
|
export const initSortPanel = () => {
|
||||||
|
const {sort, order} = CloudCmd;
|
||||||
|
const position = DOM.getPanelPosition();
|
||||||
|
|
||||||
|
sortPrevious(sort[position]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const sortPanel = (name, panel = getPanel()) => {
|
||||||
|
const {sort, order} = CloudCmd;
|
||||||
|
const Info = DOM.CurrentInfo;
|
||||||
const position = panel.dataset.name.replace('js-', '');
|
const position = panel.dataset.name.replace('js-', '');
|
||||||
|
|
||||||
if (name !== sortPrevious)
|
if (name !== sortPrevious())
|
||||||
order[position] = 'asc';
|
order[position] = 'asc';
|
||||||
else if (order[position] === 'asc')
|
else if (order[position] === 'asc')
|
||||||
order[position] = 'desc';
|
order[position] = 'desc';
|
||||||
else
|
else
|
||||||
order[position] = 'asc';
|
order[position] = 'asc';
|
||||||
|
|
||||||
sortPrevious = name;
|
sortPrevious(name);
|
||||||
sort[position] = name;
|
sort[position] = name;
|
||||||
const noCurrent = position !== Info.panelPosition;
|
const noCurrent = position !== Info.panelPosition;
|
||||||
|
|
||||||
|
|
@ -29,3 +34,4 @@ CloudCmd.sortPanel = (name, panel = getPanel()) => {
|
||||||
noCurrent,
|
noCurrent,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue