// ==UserScript==
// @name View UI
// @version 1.0.1
// @description (原iView)隐藏文档中菜单项:Pro、物料
// @author sakura-flutter
// @namespace https://github.com/sakura-flutter/tampermonkey-scripts
// @license GPL-3.0
// @compatible chrome >= Latest
// @compatible firefox >= Latest
// @match https://www.iviewui.com/*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addValueChangeListener
// @grant GM_removeValueChangeListener
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.runtime.global.prod.js
// ==/UserScript==
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 5482:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => __WEBPACK_DEFAULT_EXPORT__
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3645);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, ".skr-button{line-height:1.5715;border:1px solid;border-radius:2px;cursor:pointer;box-shadow:var(--skr-button-box-shadow);transition:var(--skr-button-transition)}.skr-button:focus:not(:focus-visible){outline:0}.skr-button:hover{filter:brightness(1.15)}.skr-button--primary{color:var(--skr-text-inverse-color);background-color:var(--skr-primary-color);border-color:var(--skr-primary-color)}.skr-button--default{color:var(--skr-text-primary-color);background-color:var(--skr-white-color);border-color:var(--skr-border-color)}.skr-button--default:hover{filter:brightness(1);color:var(--skr-primary-color);border-color:currentColor}.skr-button--round{border-radius:50%}.skr-button--shadow{box-shadow:var(--skr-box-shadow-normal)}.skr-button--mini{padding:2px 7px;font-size:12px}.skr-button--small{padding:4px 8px;font-size:12px}.skr-button--normal{padding:4px 15px;font-size:14px}.skr-button--large{padding:10px 20px;font-size:15px}", ""]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 9261:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => __WEBPACK_DEFAULT_EXPORT__
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3645);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, ".skr-input{margin-top:5px;width:100%;padding-left:8px;padding-right:8px;border:1px solid #d9d9d9;transition:all .3s}.skr-input:hover,.skr-input:focus{border-color:var(--skr-primary-color)}.skr-input:focus{box-shadow:0 0 0 2px var(--skr-primary-lighten-color)}.skr-input--small{padding-top:2px;padding-bottom:2px}.skr-input--small.skr-input--scale:focus{padding-top:6px;padding-bottom:6px;font-size:14px}.skr-input--normal{padding-top:6px;padding-bottom:6px}.skr-input--large{padding-top:10px;padding-bottom:10px}", ""]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 8443:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => __WEBPACK_DEFAULT_EXPORT__
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3645);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, ".skr-ripple-container{contain:strict;position:absolute;top:0;right:0;bottom:0;left:0;overflow:hidden;padding:0 !important;margin:0 !important;pointer-events:none !important;border-radius:inherit !important}.skr-ripple{contain:layout;position:absolute;padding:0 !important;margin:0 !important;border-radius:100%;transform:scale(0);pointer-events:none;background:var(--skr-ripple-color);transition:opacity 2s cubic-bezier(0.23, 1, 0.32, 1);animation:skr-ripple forwards cubic-bezier(0.23, 1, 0.32, 1)}@keyframes skr-ripple{to{transform:scale(3)}}", ""]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 8850:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => __WEBPACK_DEFAULT_EXPORT__
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3645);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, ".app-left .ivu-menu .ivu-menu-item[data-visible=hidden]{display:none}", ""]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 848:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Z": () => __WEBPACK_DEFAULT_EXPORT__
/* harmony export */ });
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3645);
/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
// Imports
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, ":root{--skr-primary-color: #2878ff;--skr-primary-lighten-color: rgba(24, 144, 255, 0.2);--skr-white-color: #fff;--skr-transition-duration-fast: 0.1s;--skr-transition-duration-normal: 0.3s;--skr-box-shadow-lighten: 0 1px 6px rgba(0, 0, 0, 0.15);--skr-box-shadow-normal: 0 1px 6px rgba(0, 0, 0, 0.2);--skr-border-color: #d9d9d9;--skr-text-primary-color: #303133;--skr-text-regular-color: #666;--skr-text-secondary-color: #909399;--skr-text-inverse-color: var(--skr-white-color);--skr-button-transition: all var(--skr-transition-duration-normal);--skr-button-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);--skr-ripple-color: rgb(138 218 255 / 20%)}#hide-menu-control-js{contain:content;position:fixed;bottom:40px;left:0;z-index:50;padding:10px 0}#hide-menu-control-js p{writing-mode:vertical-lr}", ""]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 3645:
/***/ ((module) => {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
// eslint-disable-next-line func-names
module.exports = function (cssWithMappingToString) {
var list = []; // return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item);
if (item[2]) {
return "@media ".concat(item[2], " {").concat(content, "}");
}
return content;
}).join('');
}; // import a list of modules into the list
// eslint-disable-next-line func-names
list.i = function (modules, mediaQuery, dedupe) {
if (typeof modules === 'string') {
// eslint-disable-next-line no-param-reassign
modules = [[null, modules, '']];
}
var alreadyImportedModules = {};
if (dedupe) {
for (var i = 0; i < this.length; i++) {
// eslint-disable-next-line prefer-destructuring
var id = this[i][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
}
for (var _i = 0; _i < modules.length; _i++) {
var item = [].concat(modules[_i]);
if (dedupe && alreadyImportedModules[item[0]]) {
// eslint-disable-next-line no-continue
continue;
}
if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery;
} else {
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
}
}
list.push(item);
}
};
return list;
};
/***/ }),
/***/ 3379:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var isOldIE = function isOldIE() {
var memo;
return function memorize() {
if (typeof memo === 'undefined') {
// Test for IE <= 9 as proposed by Browserhacks
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
// Tests for existence of standard globals is to allow style-loader
// to operate correctly into non-standard environments
// @see https://github.com/webpack-contrib/style-loader/issues/177
memo = Boolean(window && document && document.all && !window.atob);
}
return memo;
};
}();
var getTarget = function getTarget() {
var memo = {};
return function memorize(target) {
if (typeof memo[target] === 'undefined') {
var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch (e) {
// istanbul ignore next
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target];
};
}();
var stylesInDom = [];
function getIndexByIdentifier(identifier) {
var result = -1;
for (var i = 0; i < stylesInDom.length; i++) {
if (stylesInDom[i].identifier === identifier) {
result = i;
break;
}
}
return result;
}
function modulesToDom(list, options) {
var idCountMap = {};
var identifiers = [];
for (var i = 0; i < list.length; i++) {
var item = list[i];
var id = options.base ? item[0] + options.base : item[0];
var count = idCountMap[id] || 0;
var identifier = "".concat(id, " ").concat(count);
idCountMap[id] = count + 1;
var index = getIndexByIdentifier(identifier);
var obj = {
css: item[1],
media: item[2],
sourceMap: item[3]
};
if (index !== -1) {
stylesInDom[index].references++;
stylesInDom[index].updater(obj);
} else {
stylesInDom.push({
identifier: identifier,
updater: addStyle(obj, options),
references: 1
});
}
identifiers.push(identifier);
}
return identifiers;
}
function insertStyleElement(options) {
var style = document.createElement('style');
var attributes = options.attributes || {};
if (typeof attributes.nonce === 'undefined') {
var nonce = true ? __webpack_require__.nc : 0;
if (nonce) {
attributes.nonce = nonce;
}
}
Object.keys(attributes).forEach(function (key) {
style.setAttribute(key, attributes[key]);
});
if (typeof options.insert === 'function') {
options.insert(style);
} else {
var target = getTarget(options.insert || 'head');
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
}
target.appendChild(style);
}
return style;
}
function removeStyleElement(style) {
// istanbul ignore if
if (style.parentNode === null) {
return false;
}
style.parentNode.removeChild(style);
}
/* istanbul ignore next */
var replaceText = function replaceText() {
var textStore = [];
return function replace(index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
}();
function applyToSingletonTag(style, index, remove, obj) {
var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
/* istanbul ignore if */
if (style.styleSheet) {
style.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = style.childNodes;
if (childNodes[index]) {
style.removeChild(childNodes[index]);
}
if (childNodes.length) {
style.insertBefore(cssNode, childNodes[index]);
} else {
style.appendChild(cssNode);
}
}
}
function applyToTag(style, options, obj) {
var css = obj.css;
var media = obj.media;
var sourceMap = obj.sourceMap;
if (media) {
style.setAttribute('media', media);
} else {
style.removeAttribute('media');
}
if (sourceMap && typeof btoa !== 'undefined') {
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
} // For old IE
/* istanbul ignore if */
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
while (style.firstChild) {
style.removeChild(style.firstChild);
}
style.appendChild(document.createTextNode(css));
}
}
var singleton = null;
var singletonCounter = 0;
function addStyle(obj, options) {
var style;
var update;
var remove;
if (options.singleton) {
var styleIndex = singletonCounter++;
style = singleton || (singleton = insertStyleElement(options));
update = applyToSingletonTag.bind(null, style, styleIndex, false);
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
} else {
style = insertStyleElement(options);
update = applyToTag.bind(null, style, options);
remove = function remove() {
removeStyleElement(style);
};
}
update(obj);
return function updateStyle(newObj) {
if (newObj) {
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
return;
}
update(obj = newObj);
} else {
remove();
}
};
}
module.exports = function (list, options) {
options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (!options.singleton && typeof options.singleton !== 'boolean') {
options.singleton = isOldIE();
}
list = list || [];
var lastIdentifiers = modulesToDom(list, options);
return function update(newList) {
newList = newList || [];
if (Object.prototype.toString.call(newList) !== '[object Array]') {
return;
}
for (var i = 0; i < lastIdentifiers.length; i++) {
var identifier = lastIdentifiers[i];
var index = getIndexByIdentifier(identifier);
stylesInDom[index].references--;
}
var newLastIdentifiers = modulesToDom(newList, options);
for (var _i = 0; _i < lastIdentifiers.length; _i++) {
var _identifier = lastIdentifiers[_i];
var _index = getIndexByIdentifier(_identifier);
if (stylesInDom[_index].references === 0) {
stylesInDom[_index].updater();
stylesInDom.splice(_index, 1);
}
}
lastIdentifiers = newLastIdentifiers;
};
};
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => module['default'] :
/******/ () => module;
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
/******/ })();
/******/
/************************************************************************/
(() => {
;// CONCATENATED MODULE: ./src/utils/log.js
const isDebug = "production" !== 'production';
function warn(...args) {
isDebug && console.warn(...args);
}
function table(...args) {
isDebug && console.table(...args);
}
;// CONCATENATED MODULE: ./src/utils/selector.js
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
;// CONCATENATED MODULE: external "Vue"
const external_Vue_namespaceObject = Vue;
;// CONCATENATED MODULE: ./src/composition/use-gm-value.js
/**
* 同GM_getValue且在生命周期内自动GM_addValueChangeListener与GM_removeValueChangeListener,亦提供GM_setValue
* 暂不提供GM_deleteValue
* @param {string} name
* @param {any} defaultValue
*/
function useGMvalue(name, defaultValue) {
const state = (0,external_Vue_namespaceObject.reactive)({
value: GM_getValue(name, defaultValue),
old: undefined,
name
});
(0,external_Vue_namespaceObject.onUnmounted)(() => {
GM_removeValueChangeListener(id);
});
const id = GM_addValueChangeListener(name, (name, oldVal, newVal) => {
state.value = newVal;
state.old = oldVal;
});
function setValue(val) {
GM_setValue(name, val);
}
return { ...(0,external_Vue_namespaceObject.toRefs)(state),
setValue
};
}
// EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
var injectStylesIntoStyleTag = __webpack_require__(3379);
var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
// EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/input/index.scss
var input = __webpack_require__(9261);
;// CONCATENATED MODULE: ./src/components/input/index.scss
var options = {};
options.insert = "head";
options.singleton = false;
var update = injectStylesIntoStyleTag_default()(input/* default */.Z, options);
/* harmony default export */ const components_input = (input/* default.locals */.Z.locals || {});
;// CONCATENATED MODULE: ./src/components/input/index.js
const prefixCls = 'skr-input';
const Input = (0,external_Vue_namespaceObject.defineComponent)({
name: 'SkrInput',
props: {
modelValue: {
type: [String, Number],
default: ''
},
size: {
type: String,
validator: value => ['small', 'normal', 'large'].includes(value),
default: 'normal'
},
scale: {
type: Boolean,
default: false
}
},
emits: ['update:modelValue'],
setup(props, {
emit
}) {
return () => (0,external_Vue_namespaceObject.createVNode)("input", {
"class": [prefixCls, `${prefixCls}--${props.size}`, {
[`${prefixCls}--scale`]: props.scale
}],
"value": props.modelValue,
"type": "text",
"onInput": event => emit('update:modelValue', event.target.value)
}, null);
}
});
/* harmony default export */ const src_components_input = ((/* unused pure expression or super */ null && (Input)));
;// CONCATENATED MODULE: ./src/directives/v-ripple/utils.js
/**
* 计算一个点离矩形中心点的距离
* @param {number} width 矩形宽
* @param {number} height 矩形高
* @return {function} function(left top 在矩形内点的坐标) @return {number} 距离
*/
function calcDiagInRect(width, height) {
const halfWidth = width / 2;
const halfHeight = height / 2;
return function (left, top) {
const a = left <= halfWidth ? halfWidth - left : left - halfWidth;
const b = top <= halfHeight ? halfHeight - top : top - halfHeight;
const c = Math.sqrt(a * a + b * b);
return c;
};
}
/**
* 计算当前值离总值中心的位置 越靠近中心值为1,远离中心值为0
* 例如:value:50 extent:100 则计算50在0-100中的位置返回1
* value:0或100 extent:100 返回0
* @param {number} value 当前值
* @param {number} extent 总值
* @return {number} 取值0-1
*/
function closeness(value, extent) {
if (!value || !extent) return 0;
const half = extent / 2;
return value <= half ? value / half : 1 - value / extent;
}
// EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/directives/v-ripple/index.scss
var v_ripple = __webpack_require__(8443);
;// CONCATENATED MODULE: ./src/directives/v-ripple/index.scss
var v_ripple_options = {};
v_ripple_options.insert = "head";
v_ripple_options.singleton = false;
var v_ripple_update = injectStylesIntoStyleTag_default()(v_ripple/* default */.Z, v_ripple_options);
/* harmony default export */ const directives_v_ripple = (v_ripple/* default.locals */.Z.locals || {});
;// CONCATENATED MODULE: ./src/directives/v-ripple/index.js
const containerClassname = 'skr-ripple-container';
const rippleClassname = 'skr-ripple';
const vmap = new WeakMap();
/**
* 创建容器元素
*/
function createRippleContainer() {
const div = document.createElement('div');
div.classList.add(containerClassname);
return div;
}
/**
* 创建涟漪元素
*/
function createRippleEl() {
const span = document.createElement('div');
span.classList.add(rippleClassname);
return span;
}
function checkOptions(options = {}) {
if (typeof options === 'boolean') {
return {
disabled: !options
};
}
return options;
}
/**
* 添加涟漪效果
* @param {object} options color颜色 disabled禁用 布尔值时false为禁用
*/
const addRippleEffect = function (options = {}) {
options = checkOptions(options); // 涟漪个数
let count = 0;
function listener(event) {
if (options.disabled) return;
const {
currentTarget
} = event; // 优化: 处理过后不再调用getComputedStyle
if (vmap.get(currentTarget).position === false) {
vmap.get(currentTarget).position = true; // 注意:会改变当前元素定位方式
if (getComputedStyle(currentTarget).position === 'static') {
currentTarget.style.position = 'relative';
}
}
const rect = currentTarget.getBoundingClientRect();
const rippleEl = createRippleEl(); // 取元素长的一边作为涟漪的周长
const side = Math.max(rect.width, rect.height);
const radius = side / 2; // 鼠标在元素中的坐标
const left = event.pageX - rect.left - window.scrollX;
const top = event.pageY - rect.top - window.scrollY; // 选项加入到元素中
rippleEl.style.background = options.color;
rippleEl.style.width = side + 'px';
rippleEl.style.height = side + 'px'; // 元素定位再各减自身的宽高一半
rippleEl.style.top = top - radius + 'px';
rippleEl.style.left = left - radius + 'px'; // 动画在元素中间扩散时基础时长1.5s,当点击范围处于元素边缘时,动画扩散比在元素中间位置要长,所以要加快动画进行
const base = 1.5;
const diagonal = calcDiagInRect(rect.width, rect.height)(left, top);
rippleEl.style.animationDuration = base - base * diagonal / side + 's';
let container = currentTarget.querySelector(`.${containerClassname}`);
if (!container) {
container = createRippleContainer();
currentTarget.appendChild(container);
}
container.appendChild(rippleEl);
count++;
const unlisten = (() => {
const leaveEvents = ['mouseup', 'mouseleave'];
const listener = () => {
// 为了尽量能看清动画效果,延时一下再进行透明
setTimeout(() => {
rippleEl.style.opacity = 0;
}, 100);
};
leaveEvents.forEach(eventname => currentTarget.addEventListener(eventname, listener));
return () => {
leaveEvents.forEach(eventname => currentTarget.removeEventListener(eventname, listener));
};
})(); // 移除涟漪元素
rippleEl.addEventListener('transitionend', transEvent => {
if (transEvent.propertyName === 'opacity') {
unlisten();
rippleEl.remove(); // 没有涟漪元素时移除容器
if (--count <= 0) {
container.remove();
}
}
});
} // 更新配置项
function update(newOpts) {
options = Object.assign({}, options, checkOptions(newOpts));
}
return {
listener,
update
};
};
const vRipple = {
mounted(el, binding) {
const {
listener,
update
} = addRippleEffect(binding.value);
vmap.set(el, {
listener,
update,
// 更新配置项函数
position: false // 是否已经改变了el的定位方式
});
el.addEventListener('mousedown', listener, false);
},
updated(el, binding) {
const val = vmap.get(el);
val.update(binding.value);
}
};
/* harmony default export */ const src_directives_v_ripple = (vRipple);
;// CONCATENATED MODULE: ./src/directives/index.js
// EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/button/index.scss
var components_button = __webpack_require__(5482);
;// CONCATENATED MODULE: ./src/components/button/index.scss
var button_options = {};
button_options.insert = "head";
button_options.singleton = false;
var button_update = injectStylesIntoStyleTag_default()(components_button/* default */.Z, button_options);
/* harmony default export */ const src_components_button = (components_button/* default.locals */.Z.locals || {});
;// CONCATENATED MODULE: ./src/components/button/index.js
const button_prefixCls = 'skr-button'; // button type非default时覆盖一层白色
const rippleColor = 'rgb(255 255 255 / 15%)';
const Button = (0,external_Vue_namespaceObject.defineComponent)({
name: 'SkrButton',
directives: {
ripple: src_directives_v_ripple
},
props: {
type: {
type: String,
validator: value => ['primary', 'info', 'warning', 'danger', 'default'].includes(value),
default: 'default'
},
plain: {
type: Boolean,
default: false
},
round: {
type: Boolean,
default: false
},
shadow: {
type: Boolean,
default: false
},
size: {
type: String,
validator: value => ['mini', 'small', 'normal', 'large'].includes(value),
default: 'normal'
},
// 涟漪效果 object时参数会透传给ripple
ripple: {
type: [Boolean, Object],
default: true
}
},
setup(props, {
slots
}) {
const rippleOptions = (0,external_Vue_namespaceObject.computed)(() => {
return Object.assign({}, {
color: props.type === 'default' ? undefined : rippleColor
}, typeof props.ripple === 'boolean' ? {
disabled: !props.ripple
} : props.ripple);
});
return () => (0,external_Vue_namespaceObject.withDirectives)((0,external_Vue_namespaceObject.createVNode)("button", {
"class": [button_prefixCls, `${button_prefixCls}--${props.type}`, {
[`${button_prefixCls}--round`]: props.round,
[`${button_prefixCls}--shadow`]: props.shadow
}, `${button_prefixCls}--${props.size}`]
}, [slots.default()]), [[(0,external_Vue_namespaceObject.resolveDirective)("ripple"), rippleOptions.value]]);
}
});
/* harmony default export */ const src_components_button_0 = (Button);
;// CONCATENATED MODULE: ./src/components/index.js
// EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/scripts/view-ui/hide.lazy.scss
var hide_lazy = __webpack_require__(8850);
;// CONCATENATED MODULE: ./src/scripts/view-ui/hide.lazy.scss
var refs = 0;
var hide_lazy_update;
var hide_lazy_options = {"injectType":"lazyStyleTag"};
hide_lazy_options.insert = "head";
hide_lazy_options.singleton = false;
var exported = {};
exported.locals = hide_lazy/* default.locals */.Z.locals || {};
exported.use = function() {
if (!(refs++)) {
hide_lazy_update = injectStylesIntoStyleTag_default()(hide_lazy/* default */.Z, hide_lazy_options);
}
return exported;
};
exported.unuse = function() {
if (refs > 0 && !--refs) {
hide_lazy_update();
hide_lazy_update = null;
}
};
;
/* harmony default export */ const view_ui_hide_lazy = (exported);
// EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/scripts/view-ui/ui.scss
var ui = __webpack_require__(848);
;// CONCATENATED MODULE: ./src/scripts/view-ui/ui.scss
var ui_options = {};
ui_options.insert = "head";
ui_options.singleton = false;
var ui_update = injectStylesIntoStyleTag_default()(ui/* default */.Z, ui_options);
/* harmony default export */ const view_ui_ui = (ui/* default.locals */.Z.locals || {});
;// CONCATENATED MODULE: ./src/scripts/view-ui/ui.js
const app = (0,external_Vue_namespaceObject.createApp)({
setup() {
const {
value: hidden,
setValue: setHidden
} = useGMvalue('menu_hidden', false);
(0,external_Vue_namespaceObject.watchEffect)(() => {
hidden.value ? view_ui_hide_lazy.use() : view_ui_hide_lazy.unuse();
});
function toggle() {
setHidden(!hidden.value);
}
return () => (0,external_Vue_namespaceObject.createVNode)(src_components_button_0, {
"id": "hide-menu-control-js",
"size": "mini",
"shadow": true,
"onClick": toggle
}, {
default: () => [(0,external_Vue_namespaceObject.createVNode)("p", null, [(0,external_Vue_namespaceObject.createTextVNode)("\u5207\u6362")])]
});
}
});
const rootContainer = document.createElement('div');
app.mount(rootContainer);
document.body.appendChild(rootContainer);
;// CONCATENATED MODULE: ./src/scripts/view-ui/index.js
function main() {
// 物料
const storeBadge = '.navigate-item-badge-store'; // pro
const proBadge = '.navigate-item-badge-pro';
const prefixSelector = '.app-left .ivu-menu ';
const selector = Array.from([storeBadge, proBadge], item => prefixSelector + item).join();
const badgeEls = $$(selector);
warn(selector, badgeEls);
badgeEls.forEach(el => {
let {
parentNode
} = el;
while (parentNode) {
const {
tagName
} = parentNode;
if (tagName === 'A' && parentNode.classList.contains('ivu-menu-item')) {
// 添加标记
parentNode.dataset.visible = 'hidden';
break;
}
if (tagName === 'BODY') break;
parentNode = parentNode.parentNode;
}
});
}
setTimeout(main, 500);
})();
/******/ })()
;