diff --git a/README.md b/README.md index 8dad944..5d75f15 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ yarn yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass ``` -## 安装扩展组件的依赖 +## 安装 cool/modules 模块的依赖 安装 `cl-admin-cli` 脚手架: @@ -44,7 +44,7 @@ yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass npm install cl-admin-cli -g ``` -安装扩展组件依赖: +安装模块依赖: ```shell cl install diff --git a/cool/components/base/service/index.js b/cool/components/base/service/index.js deleted file mode 100644 index b076d8f..0000000 --- a/cool/components/base/service/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import Common from "./common"; -import Open from "./open"; -import SysUser from "./user"; -import SysMenu from "./menu"; -import SysRole from "./role"; -import SysDept from "./dept"; -import PluginInfo from "./plugin"; - -export default { - common: new Common(), - open: new Open(), - system: { - user: new SysUser(), - menu: new SysMenu(), - role: new SysRole(), - dept: new SysDept() - }, - plugin: { - info: new PluginInfo() - } -}; diff --git a/cool/components/base/store/component.js b/cool/components/base/store/component.js deleted file mode 100644 index 59d8f72..0000000 --- a/cool/components/base/store/component.js +++ /dev/null @@ -1,33 +0,0 @@ -export default { - state: { - info: {}, - list: [], - modules: [] - }, - - getters: { - // 组件信息 - components: (state) => state.info, - // 组件列表 - componentList: (state) => state.list, - // 组件模块 - componentModules: (state) => state.modules - }, - - mutations: { - SET_COMPONENT(state, list) { - let d = {}; - - list.forEach((e) => { - d[e.name] = e; - }); - - state.list = list; - state.info = d; - }, - - SET_COMPONENT_MODULES(state, list) { - state.modules = list; - } - } -}; diff --git a/cool/components/codemirror/index.js b/cool/components/codemirror/index.js deleted file mode 100644 index 0878c4e..0000000 --- a/cool/components/codemirror/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import Codemirror from "./components"; - -export default { - components: { - Codemirror - } -}; diff --git a/cool/components/codemirror/package.json b/cool/components/codemirror/package.json deleted file mode 100644 index 7cb4639..0000000 --- a/cool/components/codemirror/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "codemirror", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "codemirror": "^5.59.2", - "js-beautify": "^1.13.5", - "vue-codemirror": "^4.0.6" - } -} diff --git a/cool/components/copy/package.json b/cool/components/copy/package.json deleted file mode 100644 index 818daa5..0000000 --- a/cool/components/copy/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "copy", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "clipboard": "^2.0.6", - "tape": "^5.1.1" - } -} diff --git a/cool/components/editor-quill/index.js b/cool/components/editor-quill/index.js deleted file mode 100644 index 90bbfd1..0000000 --- a/cool/components/editor-quill/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import EditorQuill from "./components"; - -export default { - components: { - EditorQuill - } -}; diff --git a/cool/components/editor-quill/package.json b/cool/components/editor-quill/package.json deleted file mode 100644 index 30b5cc1..0000000 --- a/cool/components/editor-quill/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "editor-quill", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "quill": "^1.3.7" - } -} diff --git a/cool/components/log/index.js b/cool/components/log/index.js deleted file mode 100644 index ae50073..0000000 --- a/cool/components/log/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import service from "./service"; -import views from "./views"; - -export default { service, views }; diff --git a/cool/components/log/service/index.js b/cool/components/log/service/index.js deleted file mode 100644 index afe78ea..0000000 --- a/cool/components/log/service/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import SysLog from "./log"; - -export default { - system: { - log: new SysLog() - } -}; diff --git a/cool/components/log/views/index.js b/cool/components/log/views/index.js deleted file mode 100644 index b84bd84..0000000 --- a/cool/components/log/views/index.js +++ /dev/null @@ -1,8 +0,0 @@ -export default [ - { - moduleName: "sys.log", - label: "请求日志", - path: "/sys/log", - component: () => import("./log") - } -]; diff --git a/cool/components/param/index.js b/cool/components/param/index.js deleted file mode 100644 index 743cb9d..0000000 --- a/cool/components/param/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import service from "./service"; -import views from './views' - -export default { service, views }; diff --git a/cool/components/param/service/index.js b/cool/components/param/service/index.js deleted file mode 100644 index 8c27eca..0000000 --- a/cool/components/param/service/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import SysParam from "./param"; - -export default { - system: { - param: new SysParam() - } -}; diff --git a/cool/components/param/views/index.js b/cool/components/param/views/index.js deleted file mode 100644 index ecdaa4c..0000000 --- a/cool/components/param/views/index.js +++ /dev/null @@ -1,8 +0,0 @@ -export default [ - { - moduleName: "sys.param", - label: "参数列表", - path: "/sys/param", - component: () => import("./param") - } -]; diff --git a/cool/components/perf/index.js b/cool/components/perf/index.js deleted file mode 100644 index 743cb9d..0000000 --- a/cool/components/perf/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import service from "./service"; -import views from './views' - -export default { service, views }; diff --git a/cool/components/perf/service/index.js b/cool/components/perf/service/index.js deleted file mode 100644 index d2fef22..0000000 --- a/cool/components/perf/service/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import SysInfo from "./info"; - -export default { - system: { - info: new SysInfo() - } -}; diff --git a/cool/components/perf/views/index.js b/cool/components/perf/views/index.js deleted file mode 100644 index 7bb72a8..0000000 --- a/cool/components/perf/views/index.js +++ /dev/null @@ -1,8 +0,0 @@ -export default [ - { - moduleName: "sys.perf", - label: "状态监控", - path: "/sys/perf", - component: () => import("./perf") - } -]; diff --git a/cool/components/task/index.js b/cool/components/task/index.js deleted file mode 100644 index 0683c4e..0000000 --- a/cool/components/task/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import service from "./service"; -import views from './views' - -export default { - service, - views -}; diff --git a/cool/components/task/package.json b/cool/components/task/package.json deleted file mode 100644 index 50af67e..0000000 --- a/cool/components/task/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "task", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "dependencies": { - "vuedraggable": "^2.24.3" - } -} diff --git a/cool/components/task/service/index.js b/cool/components/task/service/index.js deleted file mode 100644 index e256a3d..0000000 --- a/cool/components/task/service/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import SysTask from "./task"; - -export default { - system: { - task: new SysTask() - } -}; diff --git a/cool/components/task/views/index.js b/cool/components/task/views/index.js deleted file mode 100644 index c4f4ad4..0000000 --- a/cool/components/task/views/index.js +++ /dev/null @@ -1,8 +0,0 @@ -export default [ - { - moduleName: "sys.task", - label: "任务列表", - path: "/sys/task", - component: () => import("./task") - } -]; diff --git a/cool/core/common/index.js b/cool/core/common/index.js deleted file mode 100644 index fc56843..0000000 --- a/cool/core/common/index.js +++ /dev/null @@ -1,11 +0,0 @@ -Promise.prototype.done = function (cb) { - let P = this.constructor; - - return this.then( - (value) => P.resolve(cb()).then(() => value), - (reason) => - P.resolve(cb()).then(() => { - throw reason; - }) - ); -}; diff --git a/cool/core/index.js b/cool/core/index.js deleted file mode 100644 index 9a476e7..0000000 --- a/cool/core/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { BaseService, Service, Permission } from "./service"; -import { SET_SERVICE, SET_ROUTER, SET_COMPONENT } from "./set"; -import "./common"; - -async function bootstrap(options = {}) { - const { components } = options; - - SET_ROUTER(); - SET_SERVICE(); - SET_COMPONENT({ events: components }); -} -export { Service, Permission, BaseService, bootstrap }; diff --git a/cool/core/service/base.js b/cool/core/service/base.js deleted file mode 100644 index cb47aeb..0000000 --- a/cool/core/service/base.js +++ /dev/null @@ -1,118 +0,0 @@ -import request from "@/service/request"; -import { baseUrl } from "@/config/env"; - -export default class BaseService { - constructor() { - const crud = { - page: "page", - list: "list", - info: "info", - add: "add", - delete: "delete", - update: "update" - }; - - if (!this.permission) { - this.permission = {}; - } - - for (let i in crud) { - if (this.namespace) { - this.permission[i] = this.namespace.replace(/\//g, ":") + ":" + crud[i]; - } else { - this.permission[i] = crud[i]; - } - } - } - - request(options = {}) { - if (!options.params) { - options.params = {}; - } - - let path = ""; - - if (process.env.NODE_ENV == "development") { - path = this.proxy || baseUrl; - } else { - if (this.proxy) { - path = this.url; - } else { - path = baseUrl; - } - } - - if (this.namespace) { - path += "/" + this.namespace; - } - - if (options.url.indexOf("http") !== 0) { - if (options.url[0] === "@") { - options.url = options.url.replace("@", ""); - } else { - options.url = path + options.url; - } - } - - return request(options); - } - - list(params) { - return this.request({ - url: "/list", - method: "POST", - data: { - ...params - } - }); - } - - page(params) { - return this.request({ - url: "/page", - method: "POST", - data: { - ...params - } - }); - } - - info(params) { - return this.request({ - url: "/info", - params: { - ...params - } - }); - } - - update(params) { - return this.request({ - url: "/update", - method: "POST", - data: { - ...params - } - }); - } - - delete(params) { - return this.request({ - url: "/delete", - method: "POST", - data: { - ...params - } - }); - } - - add(params) { - return this.request({ - url: "/add", - method: "POST", - data: { - ...params - } - }); - } -} diff --git a/cool/core/service/desorator.js b/cool/core/service/desorator.js deleted file mode 100644 index 4d60563..0000000 --- a/cool/core/service/desorator.js +++ /dev/null @@ -1,40 +0,0 @@ -import { isObject } from "../utils"; - -export function Permission(value) { - return function (target, key, descriptor) { - if (!target.permission) { - target.permission = {}; - } - - setTimeout(() => { - target.permission[key] = ( - (target.namespace ? target.namespace + "/" : "") + value - ).replace(/\//g, ":"); - }, 0); - - return descriptor; - }; -} - -export function Service(value) { - const { devServer } = require("@/../vue.config.js"); - - return function (target) { - // 命名 - if (typeof value == "string") { - target.prototype.namespace = value; - } - - // 复杂项 - if (isObject(value)) { - let { proxy, namespace, url } = value; - - target.prototype.namespace = namespace; - - if (proxy) { - target.prototype.proxy = proxy; - target.prototype.url = url || devServer.proxy[proxy].target; - } - } - }; -} diff --git a/cool/core/service/index.js b/cool/core/service/index.js deleted file mode 100644 index f96b8cd..0000000 --- a/cool/core/service/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import BaseService from "./base"; -import { Service, Permission } from "./desorator"; - -export { BaseService, Service, Permission }; diff --git a/cool/core/set/component.js b/cool/core/set/component.js deleted file mode 100644 index a9139be..0000000 --- a/cool/core/set/component.js +++ /dev/null @@ -1,150 +0,0 @@ -import Vue from "vue"; -import Cool from "cool"; -import store from '@/store' -import router from '@/router' -import { deepMerge, isFunction, isObject } from "../utils"; - -export default function (options = {}) { - if (!options.events) { - options.events = {}; - } - - // 组件模块 - let componentModules = []; - - // 组件列表 - let components = []; - - // 安装组件 - function install(comp) { - let { store: _store, components, service, directives, filters, pages, views, name } = comp; - let { onInstall, onSuccess, onFail } = options.events[name] || {}; - - try { - const next = () => { - // 注册vuex模块 - if (_store) { - for (let i in _store) { - store.registerModule(`${name}-${i}`, _store[i]); - } - } - - // 注册组件 - if (components) { - for (let i in components) { - Vue.component(components[i].name, components[i]); - } - } - - // 注册请求服务 - if (service) { - deepMerge(store.$service, service); - } - - // 注册指令 - if (directives) { - for (let i in directives) { - Vue.directive(i, directives[i]); - } - } - - // 注册过滤器 - if (filters) { - for (let i in filters) { - Vue.filter(i, filters[i]); - } - } - - // 注册页面 - if (pages) { - pages.forEach((e) => { - router.addRoute(e); - }); - } - - // 注册视图 - if (views) { - views.forEach((e) => { - if (!e.meta) { - e.meta = {}; - } - - if (e.moduleName) { - componentModules.push(e); - } else { - e.meta.label = e.label; - - if (e.path) { - router.$plugin.addViews([e], { - ignore404: true - }); - } else { - console.error(`[${name}-views]:path in null`); - } - } - }); - } - - // 包安装成功 - if (onSuccess) onSuccess(comp); - }; - - // 安装前 - if (onInstall) { - onInstall(comp, { next }); - } else { - next(); - } - } catch (e) { - console.error(e); - - // 安装失败 - if (onFail) onFail(comp, e); - } - } - - // 解析组件 - Cool.components.map((e) => { - if (!e) { - return null; - } - - let comp = null; - - if (isObject(e)) { - comp = e; - } else { - comp = { - name: e[0], - value: e[1], - options: e[2] - }; - } - - if (comp.value) { - if (isFunction(comp.value.install)) { - comp.value = comp.value.install(Vue, comp.options); - } - } - - // 是否开启 - if (comp.options && comp.options.enable === false) { - return null; - } - - if (comp) { - comp = { - name: comp.name, - options: comp.options, - ...comp.value - }; - - components.push(comp); - install(comp); - } - }); - - // 设置缓存 - store.commit("SET_COMPONENT_MODULES", componentModules); - store.commit("SET_COMPONENT", components); -} diff --git a/cool/core/set/index.js b/cool/core/set/index.js deleted file mode 100644 index 6029c5d..0000000 --- a/cool/core/set/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import SET_SERVICE from "./service"; -import SET_ROUTER from "./router"; -import SET_COMPONENT from "./component"; - -export { SET_SERVICE, SET_ROUTER, SET_COMPONENT }; diff --git a/cool/core/set/router.js b/cool/core/set/router.js deleted file mode 100644 index 4d10f12..0000000 --- a/cool/core/set/router.js +++ /dev/null @@ -1,116 +0,0 @@ -import VueRouter from 'vue-router' -import { Message } from "element-ui"; -import store from "@/store"; -import router, { ignore } from '@/router' -import storage from '../utils/storage' - -// Remove Navigating to current location (XXX) is not allowed -const routerPush = VueRouter.prototype.push; -VueRouter.prototype.push = function push(location) { - return routerPush.call(this, location).catch((error) => error); -}; - -export default function () { - router.$plugin = { - addViews: (list, options) => { - if (!options) { - options = {}; - } - - // Parse route config - list.map((e) => { - if (!e.component) { - let url = e.viewPath; - - if (url) { - if ( - /^(http[s]?:\/\/)([0-9a-z.]+)(:[0-9]+)?([/0-9a-z.]+)?(\?[0-9a-z&=]+)?(#[0-9-a-z]+)?/i.test( - url - ) - ) { - e.meta.iframeUrl = url; - e.component = () => import(`cool/components/base/pages/iframe/index.vue`); - } else { - if (url.indexOf("views/") === 0) { - e.component = () => import(`@/${url}`); - } else { - console.error(url, "异常"); - } - } - } else { - e.redirect = "/404"; - } - } - }); - - // Batch add route - list.forEach((e) => { - router.addRoute("index", e); - }); - - // Add 404 rule - if (!options.ignore404) { - router.addRoute({ - path: "*", - redirect: "/404" - }); - } - }, - - to: (url) => { - if (router.path != url) { - router.push(url); - } - } - }; - - router.beforeEach((to, from, next) => { - const { token, browser } = store.getters - - if (token) { - if (to.path.indexOf('/login') === 0) { - // 登录成功且 token 未过期,回到首页 - if (!storage.isExpired('token')) { - return next('/') - } - } else { - // 添加路由进程 - store.commit("ADD_PROCESS", { - label: (to.meta && to.meta.label) || to.name, - value: to.fullPath - }); - } - } else { - if (!ignore.token.some((e) => to.path.indexOf(e) === 0)) { - return next("/login"); - } - } - - // H5 下关闭左侧菜单 - if (browser.isMobile) { - store.commit("COLLAPSE_MENU", true); - } - - next() - }) - - let lock = false; - - router.onError((err) => { - if (!lock) { - lock = true; - - if (err.code == "MODULE_NOT_FOUND") { - console.error(err.message.replace("Cannot find module ", ""), "路由组件不存在"); - - Message.error(`路由组件路径错误`); - } else { - console.error(err); - } - - setTimeout(() => { - lock = false; - }, 0); - } - }); -} diff --git a/cool/core/set/service.js b/cool/core/set/service.js deleted file mode 100644 index c91bac0..0000000 --- a/cool/core/set/service.js +++ /dev/null @@ -1,53 +0,0 @@ -import Vue from "vue"; -import path from "path"; -import store from '@/store' - -export default function () { - const files = require.context("@/service/", true, /\.js$/); - const ignore = ["./request.js"]; - - let modules = {}; - - files - .keys() - .filter((e) => !ignore.includes(e)) - .map((e) => { - if (e.includes("--ignore")) { - return false; - } - - let list = e.substr(2).split("/"); - let parents = list.slice(0, list.length - 1); - let name = path.basename(e, ".js"); - - let curr = modules; - let prev = null; - let key = null; - - parents.forEach((k) => { - if (!curr[k]) { - curr[k] = {}; - } - - prev = curr; - curr = curr[k]; - key = k; - }); - - let ep = files(e); - - if (ep.default) { - let service = new ep.default(); - - if (name == "index") { - prev[key] = service; - } else { - curr[name] = service; - } - } else { - console.error(`Service must export default [${e}]`); - } - }); - - Vue.prototype.$service = store.$service = modules; -} diff --git a/cool/core/utils/index.js b/cool/core/utils/index.js deleted file mode 100644 index 8d5553b..0000000 --- a/cool/core/utils/index.js +++ /dev/null @@ -1,256 +0,0 @@ -import { routerMode } from "@/config/env"; - -export function getUrlParam(name) { - let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); - let r = window.location.search.substr(1).match(reg); - if (r != null) return decodeURIComponent(r[2]); - return null; -} - -export function isPc() { - const userAgentInfo = navigator.userAgent; - const Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; - let flag = true; - for (let v = 0; v < Agents.length; v++) { - if (userAgentInfo.indexOf(Agents[v]) > 0) { - flag = false; - break; - } - } - return flag; -} - -export const isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); - -export function getBrowser() { - let ua = navigator.userAgent.toLowerCase(); - let btypeInfo = (ua.match(/firefox|chrome|safari|opera/g) || "other")[0]; - if ((ua.match(/msie|trident/g) || [])[0]) { - btypeInfo = "msie"; - } - let pc = ""; - let prefix = ""; - let plat = ""; - - let isTocuh = - "ontouchstart" in window || ua.indexOf("touch") !== -1 || ua.indexOf("mobile") !== -1; - if (isTocuh) { - if (ua.indexOf("ipad") !== -1) { - pc = "pad"; - } else if (ua.indexOf("mobile") !== -1) { - pc = "mobile"; - } else if (ua.indexOf("android") !== -1) { - pc = "androidPad"; - } else { - pc = "pc"; - } - } else { - pc = "pc"; - } - switch (btypeInfo) { - case "chrome": - case "safari": - case "mobile": - prefix = "webkit"; - break; - case "msie": - prefix = "ms"; - break; - case "firefox": - prefix = "Moz"; - break; - case "opera": - prefix = "O"; - break; - default: - prefix = "webkit"; - break; - } - plat = ua.indexOf("android") > 0 ? "android" : navigator.platform.toLowerCase(); - return { - version: (ua.match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], - plat: plat, - type: btypeInfo, - pc: pc, - prefix: prefix, - isMobile: pc == "pc" ? false : true - }; -} - -export function href(path, newWindow) { - let { search, origin } = window.location; - - let url = ""; - - if (routerMode == "history") { - url = origin + path; - } else { - url = origin + search + "#" + path; - } - - if (newWindow) { - window.open(url); - } else { - window.location.href = url; - } -} - -export function orderBy(list, key) { - return list.sort((a, b) => a[key] - b[key]); -} - -export function deepTree(list) { - let newList = []; - let map = {}; - - list.forEach((e) => (map[e.id] = e)); - - list.forEach((e) => { - let parent = map[e.parentId]; - - if (parent) { - (parent.children || (parent.children = [])).push(e); - } else { - newList.push(e); - } - }); - - const fn = (list) => { - list.map((e) => { - if (e.children instanceof Array) { - e.children = orderBy(e.children, "orderNum"); - - fn(e.children); - } - }); - }; - - fn(newList); - - return orderBy(newList, "orderNum"); -} - -export function revDeepTree(list = []) { - let d = []; - let id = 0; - - const deep = (list, parentId) => { - list.forEach((e) => { - e.id = id++; - e.parentId = parentId; - - d.push(e); - - if (e.children && isArray(e.children)) { - deep(e.children, e.id); - } - }); - }; - - deep(list || [], null); - - return d; -} - -export function debounce(fn, delay) { - let timer = null; - - return function () { - let args = arguments; - let context = this; - - if (timer) { - clearTimeout(timer); - - timer = setTimeout(function () { - fn.apply(context, args); - }, delay); - } else { - timer = setTimeout(function () { - fn.apply(context, args); - }, delay); - } - }; -} - -export function isArray(value) { - if (typeof Array.isArray === "function") { - return Array.isArray(value); - } else { - return Object.prototype.toString.call(value) === "[object Array]"; - } -} - -export function isObject(value) { - return Object.prototype.toString.call(value) === "[object Object]"; -} - -export function isNumber(value) { - return !isNaN(Number(value)); -} - -export function isFunction(value) { - return typeof value == "function"; -} - -export function isString(value) { - return typeof value == "string"; -} - -export function isEmpty(value) { - if (isArray(value)) { - return value.length === 0; - } - - if (isObject(value)) { - return Object.keys(value).length === 0; - } - - return value === "" || value === undefined || value === null; -} - -export function last(data) { - if (isArray(data) || isString(data)) { - return data[data.length - 1]; - } -} - -export function cloneDeep(obj) { - let d = isArray(obj) ? obj : {}; - - if (isObject(obj)) { - for (let key in obj) { - if (obj.hasOwnProperty && obj.hasOwnProperty(key)) { - if (obj[key] && typeof obj[key] === "object") { - d[key] = cloneDeep(obj[key]); - } else { - d[key] = obj[key]; - } - } - } - } - - return d; -} - -export function clone(obj) { - return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj)); -} - -export function deepMerge(a, b) { - let k; - for (k in b) { - a[k] = - a[k] && a[k].toString() === "[object Object]" ? deepMerge(a[k], b[k]) : (a[k] = b[k]); - } - return a; -} - -export function contains(parent, node) { - if (document.documentElement.contains) { - return parent !== node && parent.contains(node); - } else { - while (node && (node = node.parentNode)) if (node === parent) return true; - return false; - } -} diff --git a/cool/core/utils/storage.js b/cool/core/utils/storage.js deleted file mode 100644 index e350abb..0000000 --- a/cool/core/utils/storage.js +++ /dev/null @@ -1,81 +0,0 @@ -import store from 'store' - -export default { - // 后缀标识 - suffix: "_deadtime", - - /** - * 获取 - * @param {string} key 关键字 - */ - get(key) { - return store.get(key) - }, - - /** - * 获取全部 - */ - info() { - let d = {} - - store.each(function (value, key) { - d[key] = value - }) - - return d - }, - - /** - * 设置 - * @param {string} key 关键字 - * @param {*} value 值 - * @param {number} expires 过期时间 - */ - set(key, value, expires) { - store.set(key, value); - - if (expires) { - store.set(`${key}${this.suffix}`, Date.parse(new Date()) + expires * 1000); - } - }, - - /** - * 是否过期 - * @param {string} key 关键字 - */ - isExpired(key) { - return (this.getExpiration(key) || 0) - Date.parse(new Date()) <= 2000; - }, - - /** - * 获取到期时间 - * @param {string} key 关键字 - */ - getExpiration(key) { - return this.get(key + this.suffix) - }, - - /** - * 移除 - * @param {string} key 关键字 - */ - remove(key) { - store.remove(key) - this.removeExpiration(key) - }, - - /** - * 移除到期时间 - * @param {string} key 关键字 - */ - removeExpiration(key) { - store.remove(key + this.suffix) - }, - - /** - * 清理 - */ - clearAll() { - store.clearAll() - } -}; diff --git a/cool/index.js b/cool/index.js index e4ea4c8..62d43c8 100644 --- a/cool/index.js +++ b/cool/index.js @@ -1,20 +1,13 @@ -import Base from "./components/base"; -import Upload from "./components/upload"; -import Chat from "./components/chat"; -import Codemirror from "./components/codemirror"; -import Copy from "./components/copy"; -import Demo from "./components/demo"; -import Distpicker from "./components/distpicker"; -import EditorQuill from "./components/editor-quill"; -import Log from "./components/log"; -import Param from "./components/param"; -import Perf from "./components/perf"; -import Task from "./components/task"; +import Base from "./modules/base"; +import Upload from "./modules/upload"; +import Copy from "./modules/copy"; +import Demo from "./modules/demo"; +import Distpicker from "./modules/distpicker"; import Crud from "cl-admin-crud"; import Export from "cl-admin-export"; export default { - components: [ + modules: [ ["base", Base], [ "upload", @@ -41,15 +34,8 @@ export default { } ], ["export", Export], - // ["chat", Chat], - ["codemirror", Codemirror], ["copy", Copy], - ["demo", Demo], ["distpicker", Distpicker], - ["editor-quill", EditorQuill], - ["log", Log], - ["param", Param], - ["perf", Perf], - ["task", Task] + ["demo", Demo] ] }; diff --git a/cool/components/base/common/index.js b/cool/modules/base/common/index.js similarity index 100% rename from cool/components/base/common/index.js rename to cool/modules/base/common/index.js diff --git a/cool/components/base/components/avatar/index.vue b/cool/modules/base/components/avatar/index.vue similarity index 100% rename from cool/components/base/components/avatar/index.vue rename to cool/modules/base/components/avatar/index.vue diff --git a/cool/components/codemirror/components/index.vue b/cool/modules/base/components/codemirror/index.vue similarity index 100% rename from cool/components/codemirror/components/index.vue rename to cool/modules/base/components/codemirror/index.vue diff --git a/cool/components/base/components/dept/check.vue b/cool/modules/base/components/dept/check.vue similarity index 100% rename from cool/components/base/components/dept/check.vue rename to cool/modules/base/components/dept/check.vue diff --git a/cool/components/base/components/dept/move.vue b/cool/modules/base/components/dept/move.vue similarity index 100% rename from cool/components/base/components/dept/move.vue rename to cool/modules/base/components/dept/move.vue diff --git a/cool/components/base/components/dept/tree.vue b/cool/modules/base/components/dept/tree.vue similarity index 100% rename from cool/components/base/components/dept/tree.vue rename to cool/modules/base/components/dept/tree.vue diff --git a/cool/components/editor-quill/components/index.vue b/cool/modules/base/components/editor-quill/index.vue similarity index 100% rename from cool/components/editor-quill/components/index.vue rename to cool/modules/base/components/editor-quill/index.vue diff --git a/cool/components/base/components/icon-svg/index.vue b/cool/modules/base/components/icon-svg/index.vue similarity index 100% rename from cool/components/base/components/icon-svg/index.vue rename to cool/modules/base/components/icon-svg/index.vue diff --git a/cool/components/base/components/index.js b/cool/modules/base/components/index.js similarity index 86% rename from cool/components/base/components/index.js rename to cool/modules/base/components/index.js index 1172189..1554de2 100644 --- a/cool/components/base/components/index.js +++ b/cool/modules/base/components/index.js @@ -14,6 +14,8 @@ import MenuPerms from "./menu/perms"; import MenuTree from "./menu/tree"; import RoleSelect from "./role/select"; import RolePerms from "./role/perms"; +import EditorQuill from "./editor-quill"; +import Codemirror from "./codemirror"; export default { Avatar, @@ -31,5 +33,7 @@ export default { MenuPerms, MenuTree, RoleSelect, - RolePerms + RolePerms, + EditorQuill, + Codemirror }; diff --git a/cool/components/base/components/menu/file.vue b/cool/modules/base/components/menu/file.vue similarity index 92% rename from cool/components/base/components/menu/file.vue rename to cool/modules/base/components/menu/file.vue index 197adc8..31dacc7 100644 --- a/cool/components/base/components/menu/file.vue +++ b/cool/modules/base/components/menu/file.vue @@ -25,7 +25,7 @@ @change="onModuleChange" > e.moduleName == val ); diff --git a/cool/components/base/components/menu/icons.vue b/cool/modules/base/components/menu/icons.vue similarity index 96% rename from cool/components/base/components/menu/icons.vue rename to cool/modules/base/components/menu/icons.vue index af0820e..377437e 100644 --- a/cool/components/base/components/menu/icons.vue +++ b/cool/modules/base/components/menu/icons.vue @@ -29,7 +29,7 @@