1 Star 0 Fork 0

nopast/tools-page

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.babel.js 4.35 KB
一键复制 编辑 原始数据 按行查看 历史
nopast 提交于 2022-01-29 21:09 . feat: 新增工具
"use strict";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
window.addEventListener("beforeunload", function (event) {
if (document.querySelectorAll('#preview iframe').length > 1) {
event.returnValue = "确定离开当前页面吗?";
}
});
new Vue({
el: '#app',
data: {
defaultIframeUrl: 'https://bing.com/?ensearch=1',
openInPreview: true,
innerMenu: WEB_INIT_DATA.menu,
activePreview: '',
iframeList: []
},
mounted: function mounted() {},
methods: {
openLinkToPreview: function openLinkToPreview(e, item) {
var aspectRatio = window.innerWidth / window.innerHeight;
if (this.openInPreview && aspectRatio >= 0.8) {
e.preventDefault();
if (!this.iframeList.find(function (each) {
return each.path === item.path;
})) {
this.iframeList = [].concat(_toConsumableArray(this.iframeList.map(function (each) {
return _objectSpread(_objectSpread({}, each), {}, {
active: false
});
})), [_objectSpread(_objectSpread({}, item), {}, {
key: item.path + String(Date.now())
})]);
}
}
this.activePreview = item.path;
},
refreshIframe: function refreshIframe() {
var _this = this;
this.iframeList = this.iframeList.map(function (item) {
if (item.path === _this.activePreview) {
return _objectSpread(_objectSpread({}, item), {}, {
key: item.path + String(Date.now())
});
} else {
return item;
}
});
},
closeIframe: function closeIframe() {
var _this2 = this,
_this$iframeList$Math;
var iframeIndex = this.iframeList.findIndex(function (item) {
return item.path === _this2.activePreview;
});
this.iframeList = this.iframeList.filter(function (item) {
return item.path != _this2.activePreview;
});
console.log(iframeIndex, this.iframeList.length - 1);
this.activePreview = (_this$iframeList$Math = this.iframeList[Math.min(iframeIndex, this.iframeList.length - 1)]) === null || _this$iframeList$Math === void 0 ? void 0 : _this$iframeList$Math.path;
}
}
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nopast/tools-page.git
[email protected]:nopast/tools-page.git
nopast
tools-page
tools-page
master

搜索帮助