@axewo/cnsframework
Version:
一个免费开源的中后台管理系统基础解决方案,基于 Vue3、TypeScript、Element Plus、Pinia 和 Vite 等主流技术
1,431 lines (1,346 loc) • 92.2 kB
JavaScript
import { reactive, ref, watch, onBeforeMount, onMounted, onBeforeUnmount, defineComponent, openBlock, createElementBlock, createElementVNode, toDisplayString, unref, resolveComponent, createVNode, withCtx, Transition, createBlock, KeepAlive, resolveDynamicComponent, createCommentVNode, Fragment, renderList, withModifiers, renderSlot, computed, normalizeClass, createSlots, createTextVNode, normalizeStyle, useCssVars, watchEffect, pushScopeId, popScopeId, nextTick, getCurrentInstance, withDirectives, vShow } from 'vue';
import { d as defineStore, g as getSidebarStatus, s as setSidebarStatus, u as useRouteListener, a as useSettingsStore, b as storeToRefs, c as useTagsViewStore, e as useRoute, f as useRouter, r as removeConfigLayout, h as usePermissionStore, i as useNotityHook, j as useTheme, k as useUserStore, R as RouterLink } from './main-6226fbb9.js';
import { Fold, Expand, Bell, MagicStick, UserFilled, Refresh, ArrowLeft, ArrowRight, Close, Setting } from '@element-plus/icons-vue';
import 'dayjs';
import { ElMessage, ElScrollbar } from 'element-plus';
var DeviceEnum = /* @__PURE__ */ ((DeviceEnum2) => {
DeviceEnum2[DeviceEnum2["Mobile"] = 0] = "Mobile";
DeviceEnum2[DeviceEnum2["Desktop"] = 1] = "Desktop";
return DeviceEnum2;
})(DeviceEnum || {});
const SIDEBAR_OPENED = "opened";
const SIDEBAR_CLOSED = "closed";
function handleSidebarStatus(opened) {
opened ? setSidebarStatus(SIDEBAR_OPENED) : setSidebarStatus(SIDEBAR_CLOSED);
}
const useAppStore = defineStore("app", () => {
const sidebar = reactive({
opened: getSidebarStatus() !== SIDEBAR_CLOSED,
withoutAnimation: false
});
const device = ref(DeviceEnum.Desktop);
watch(
() => sidebar.opened,
(opened) => handleSidebarStatus(opened)
);
const toggleSidebar = (withoutAnimation) => {
sidebar.opened = !sidebar.opened;
sidebar.withoutAnimation = withoutAnimation;
};
const closeSidebar = (withoutAnimation) => {
sidebar.opened = false;
sidebar.withoutAnimation = withoutAnimation;
};
const toggleDevice = (value) => {
device.value = value;
};
return { device, sidebar, toggleSidebar, closeSidebar, toggleDevice };
});
const MAX_MOBILE_WIDTH = 992;
const useResize = () => {
const appStore = useAppStore();
const { listenerRouteChange } = useRouteListener();
const _isMobile = () => {
const rect = document.body.getBoundingClientRect();
return rect.width - 1 < MAX_MOBILE_WIDTH;
};
const _resizeHandler = () => {
if (!document.hidden) {
const isMobile = _isMobile();
appStore.toggleDevice(isMobile ? DeviceEnum.Mobile : DeviceEnum.Desktop);
isMobile && appStore.closeSidebar(true);
}
};
listenerRouteChange(() => {
if (appStore.device === DeviceEnum.Mobile && appStore.sidebar.opened) {
appStore.closeSidebar(false);
}
});
onBeforeMount(() => {
window.addEventListener("resize", _resizeHandler);
});
onMounted(() => {
if (_isMobile()) {
appStore.toggleDevice(DeviceEnum.Mobile);
appStore.closeSidebar(true);
}
});
onBeforeUnmount(() => {
window.removeEventListener("resize", _resizeHandler);
});
};
const _hoisted_1$e = { class: "layout-footer" };
const _sfc_main$l = /* @__PURE__ */ defineComponent({
__name: "index",
setup(__props) {
const settingsStore = useSettingsStore();
const { copyrightZh, copyrightEn } = storeToRefs(settingsStore);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("footer", _hoisted_1$e, [
createElementVNode("div", null, toDisplayString(unref(copyrightZh)), 1),
createElementVNode("div", null, toDisplayString(unref(copyrightEn)), 1)
]);
};
}
});
const index_vue_vue_type_style_index_0_scoped_365aeeb6_lang = '';
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const Footer = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__scopeId", "data-v-365aeeb6"]]);
const _hoisted_1$d = { class: "app-main" };
const _hoisted_2$8 = { class: "app-scrollbar" };
const _sfc_main$k = /* @__PURE__ */ defineComponent({
__name: "AppMain",
setup(__props) {
const tagsViewStore = useTagsViewStore();
const settingsStore = useSettingsStore();
return (_ctx, _cache) => {
const _component_router_view = resolveComponent("router-view");
const _component_el_backtop = resolveComponent("el-backtop");
return openBlock(), createElementBlock("section", _hoisted_1$d, [
createElementVNode("div", _hoisted_2$8, [
createVNode(_component_router_view, null, {
default: withCtx(({ Component, route }) => [
createVNode(Transition, {
name: "el-fade-in",
mode: "out-in"
}, {
default: withCtx(() => [
(openBlock(), createBlock(KeepAlive, {
include: unref(tagsViewStore).cachedViews
}, [
(openBlock(), createBlock(resolveDynamicComponent(Component), {
key: route.path,
class: "app-container-grow"
}))
], 1032, ["include"]))
]),
_: 2
}, 1024)
]),
_: 1
}),
unref(settingsStore).showFooter ? (openBlock(), createBlock(Footer, { key: 0 })) : createCommentVNode("", true)
]),
createVNode(_component_el_backtop),
createVNode(_component_el_backtop, { target: ".app-scrollbar" })
]);
};
}
});
const AppMain_vue_vue_type_style_index_0_scoped_849e13d2_lang = '';
const AppMain = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-849e13d2"]]);
const _sfc_main$j = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
isActive: { type: Boolean, default: false }
},
emits: ["toggleClick"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const toggleClick = () => {
emit("toggleClick");
};
return (_ctx, _cache) => {
const _component_el_icon = resolveComponent("el-icon");
return openBlock(), createElementBlock("div", { onClick: toggleClick }, [
createVNode(_component_el_icon, {
size: 20,
class: "icon"
}, {
default: withCtx(() => [
props.isActive ? (openBlock(), createBlock(unref(Fold), { key: 0 })) : (openBlock(), createBlock(unref(Expand), { key: 1 }))
]),
_: 1
})
]);
};
}
});
const index_vue_vue_type_style_index_0_scoped_9f145668_lang = '';
const Hamburger = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-9f145668"]]);
/**
* Tokenize input string.
*/
function lexer(str) {
var tokens = [];
var i = 0;
while (i < str.length) {
var char = str[i];
if (char === "*" || char === "+" || char === "?") {
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
continue;
}
if (char === "\\") {
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
continue;
}
if (char === "{") {
tokens.push({ type: "OPEN", index: i, value: str[i++] });
continue;
}
if (char === "}") {
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
continue;
}
if (char === ":") {
var name = "";
var j = i + 1;
while (j < str.length) {
var code = str.charCodeAt(j);
if (
// `0-9`
(code >= 48 && code <= 57) ||
// `A-Z`
(code >= 65 && code <= 90) ||
// `a-z`
(code >= 97 && code <= 122) ||
// `_`
code === 95) {
name += str[j++];
continue;
}
break;
}
if (!name)
throw new TypeError("Missing parameter name at ".concat(i));
tokens.push({ type: "NAME", index: i, value: name });
i = j;
continue;
}
if (char === "(") {
var count = 1;
var pattern = "";
var j = i + 1;
if (str[j] === "?") {
throw new TypeError("Pattern cannot start with \"?\" at ".concat(j));
}
while (j < str.length) {
if (str[j] === "\\") {
pattern += str[j++] + str[j++];
continue;
}
if (str[j] === ")") {
count--;
if (count === 0) {
j++;
break;
}
}
else if (str[j] === "(") {
count++;
if (str[j + 1] !== "?") {
throw new TypeError("Capturing groups are not allowed at ".concat(j));
}
}
pattern += str[j++];
}
if (count)
throw new TypeError("Unbalanced pattern at ".concat(i));
if (!pattern)
throw new TypeError("Missing pattern at ".concat(i));
tokens.push({ type: "PATTERN", index: i, value: pattern });
i = j;
continue;
}
tokens.push({ type: "CHAR", index: i, value: str[i++] });
}
tokens.push({ type: "END", index: i, value: "" });
return tokens;
}
/**
* Parse a string for the raw tokens.
*/
function parse(str, options) {
if (options === void 0) { options = {}; }
var tokens = lexer(str);
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
var defaultPattern = "[^".concat(escapeString(options.delimiter || "/#?"), "]+?");
var result = [];
var key = 0;
var i = 0;
var path = "";
var tryConsume = function (type) {
if (i < tokens.length && tokens[i].type === type)
return tokens[i++].value;
};
var mustConsume = function (type) {
var value = tryConsume(type);
if (value !== undefined)
return value;
var _a = tokens[i], nextType = _a.type, index = _a.index;
throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
};
var consumeText = function () {
var result = "";
var value;
while ((value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR"))) {
result += value;
}
return result;
};
while (i < tokens.length) {
var char = tryConsume("CHAR");
var name = tryConsume("NAME");
var pattern = tryConsume("PATTERN");
if (name || pattern) {
var prefix = char || "";
if (prefixes.indexOf(prefix) === -1) {
path += prefix;
prefix = "";
}
if (path) {
result.push(path);
path = "";
}
result.push({
name: name || key++,
prefix: prefix,
suffix: "",
pattern: pattern || defaultPattern,
modifier: tryConsume("MODIFIER") || "",
});
continue;
}
var value = char || tryConsume("ESCAPED_CHAR");
if (value) {
path += value;
continue;
}
if (path) {
result.push(path);
path = "";
}
var open = tryConsume("OPEN");
if (open) {
var prefix = consumeText();
var name_1 = tryConsume("NAME") || "";
var pattern_1 = tryConsume("PATTERN") || "";
var suffix = consumeText();
mustConsume("CLOSE");
result.push({
name: name_1 || (pattern_1 ? key++ : ""),
pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
prefix: prefix,
suffix: suffix,
modifier: tryConsume("MODIFIER") || "",
});
continue;
}
mustConsume("END");
}
return result;
}
/**
* Compile a string to a template function for the path.
*/
function compile(str, options) {
return tokensToFunction(parse(str, options), options);
}
/**
* Expose a method for transforming tokens into the path function.
*/
function tokensToFunction(tokens, options) {
if (options === void 0) { options = {}; }
var reFlags = flags(options);
var _a = options.encode, encode = _a === void 0 ? function (x) { return x; } : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
// Compile all the tokens into regexps.
var matches = tokens.map(function (token) {
if (typeof token === "object") {
return new RegExp("^(?:".concat(token.pattern, ")$"), reFlags);
}
});
return function (data) {
var path = "";
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (typeof token === "string") {
path += token;
continue;
}
var value = data ? data[token.name] : undefined;
var optional = token.modifier === "?" || token.modifier === "*";
var repeat = token.modifier === "*" || token.modifier === "+";
if (Array.isArray(value)) {
if (!repeat) {
throw new TypeError("Expected \"".concat(token.name, "\" to not repeat, but got an array"));
}
if (value.length === 0) {
if (optional)
continue;
throw new TypeError("Expected \"".concat(token.name, "\" to not be empty"));
}
for (var j = 0; j < value.length; j++) {
var segment = encode(value[j], token);
if (validate && !matches[i].test(segment)) {
throw new TypeError("Expected all \"".concat(token.name, "\" to match \"").concat(token.pattern, "\", but got \"").concat(segment, "\""));
}
path += token.prefix + segment + token.suffix;
}
continue;
}
if (typeof value === "string" || typeof value === "number") {
var segment = encode(String(value), token);
if (validate && !matches[i].test(segment)) {
throw new TypeError("Expected \"".concat(token.name, "\" to match \"").concat(token.pattern, "\", but got \"").concat(segment, "\""));
}
path += token.prefix + segment + token.suffix;
continue;
}
if (optional)
continue;
var typeOfMessage = repeat ? "an array" : "a string";
throw new TypeError("Expected \"".concat(token.name, "\" to be ").concat(typeOfMessage));
}
return path;
};
}
/**
* Escape a regular expression string.
*/
function escapeString(str) {
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
}
/**
* Get the flags for a regexp from the options.
*/
function flags(options) {
return options && options.sensitive ? "" : "i";
}
const _hoisted_1$c = {
key: 0,
class: "no-redirect"
};
const _hoisted_2$7 = ["onClick"];
const _sfc_main$i = /* @__PURE__ */ defineComponent({
__name: "index",
setup(__props) {
const route = useRoute();
const router = useRouter();
const { listenerRouteChange } = useRouteListener();
const breadcrumbs = ref([]);
const getBreadcrumb = () => {
breadcrumbs.value = route.matched.filter((item) => item.meta?.title && item.meta?.breadcrumb !== false);
};
const pathCompile = (path) => {
const toPath = compile(path);
return toPath(route.params);
};
const handleLink = (item) => {
const { redirect, path } = item;
if (redirect) {
router.push(redirect);
return;
}
router.push(pathCompile(path));
};
listenerRouteChange((route2) => {
if (route2.path.startsWith("/redirect/"))
return;
getBreadcrumb();
}, true);
return (_ctx, _cache) => {
const _component_el_breadcrumb_item = resolveComponent("el-breadcrumb-item");
const _component_el_breadcrumb = resolveComponent("el-breadcrumb");
return openBlock(), createBlock(_component_el_breadcrumb, { class: "app-breadcrumb" }, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(breadcrumbs.value, (item, index) => {
return openBlock(), createBlock(_component_el_breadcrumb_item, {
key: item.path
}, {
default: withCtx(() => [
item.redirect === "noRedirect" || index === breadcrumbs.value.length - 1 ? (openBlock(), createElementBlock("span", _hoisted_1$c, toDisplayString(item.meta.title), 1)) : (openBlock(), createElementBlock("a", {
key: 1,
onClick: withModifiers(($event) => handleLink(item), ["prevent"])
}, toDisplayString(item.meta.title), 9, _hoisted_2$7))
]),
_: 2
}, 1024);
}), 128))
]),
_: 1
});
};
}
});
const index_vue_vue_type_style_index_0_scoped_3a94d4c6_lang = '';
const Breadcrumb = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-3a94d4c6"]]);
const isExternal = (path) => {
const reg = /^(https?:|mailto:|tel:)/;
return reg.test(path);
};
const _hoisted_1$b = ["href"];
const _sfc_main$h = /* @__PURE__ */ defineComponent({
__name: "SidebarItemLink",
props: {
to: {}
},
setup(__props) {
const props = __props;
return (_ctx, _cache) => {
const _component_router_link = resolveComponent("router-link");
return unref(isExternal)(props.to) ? (openBlock(), createElementBlock("a", {
key: 0,
href: props.to,
target: "_blank",
rel: "noopener"
}, [
renderSlot(_ctx.$slots, "default")
], 8, _hoisted_1$b)) : (openBlock(), createBlock(_component_router_link, {
key: 1,
to: props.to
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["to"]));
};
}
});
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function assertPath(path) {
if (typeof path !== 'string') {
throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
}
}
// Resolves . and .. elements in a path with directory names
function normalizeStringPosix(path, allowAboveRoot) {
var res = '';
var lastSegmentLength = 0;
var lastSlash = -1;
var dots = 0;
var code;
for (var i = 0; i <= path.length; ++i) {
if (i < path.length)
code = path.charCodeAt(i);
else if (code === 47 /*/*/)
break;
else
code = 47 /*/*/;
if (code === 47 /*/*/) {
if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
if (res.length > 2) {
var lastSlashIndex = res.lastIndexOf('/');
if (lastSlashIndex !== res.length - 1) {
if (lastSlashIndex === -1) {
res = '';
lastSegmentLength = 0;
} else {
res = res.slice(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
}
lastSlash = i;
dots = 0;
continue;
}
} else if (res.length === 2 || res.length === 1) {
res = '';
lastSegmentLength = 0;
lastSlash = i;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
if (res.length > 0)
res += '/..';
else
res = '..';
lastSegmentLength = 2;
}
} else {
if (res.length > 0)
res += '/' + path.slice(lastSlash + 1, i);
else
res = path.slice(lastSlash + 1, i);
lastSegmentLength = i - lastSlash - 1;
}
lastSlash = i;
dots = 0;
} else if (code === 46 /*.*/ && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
}
function _format(sep, pathObject) {
var dir = pathObject.dir || pathObject.root;
var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
if (!dir) {
return base;
}
if (dir === pathObject.root) {
return dir + base;
}
return dir + sep + base;
}
var posix = {
// path.resolve([from ...], to)
resolve: function resolve() {
var resolvedPath = '';
var resolvedAbsolute = false;
var cwd;
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path;
if (i >= 0)
path = arguments[i];
else {
if (cwd === undefined)
cwd = process.cwd();
path = cwd;
}
assertPath(path);
// Skip empty entries
if (path.length === 0) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
if (resolvedAbsolute) {
if (resolvedPath.length > 0)
return '/' + resolvedPath;
else
return '/';
} else if (resolvedPath.length > 0) {
return resolvedPath;
} else {
return '.';
}
},
normalize: function normalize(path) {
assertPath(path);
if (path.length === 0) return '.';
var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
// Normalize the path
path = normalizeStringPosix(path, !isAbsolute);
if (path.length === 0 && !isAbsolute) path = '.';
if (path.length > 0 && trailingSeparator) path += '/';
if (isAbsolute) return '/' + path;
return path;
},
isAbsolute: function isAbsolute(path) {
assertPath(path);
return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
},
join: function join() {
if (arguments.length === 0)
return '.';
var joined;
for (var i = 0; i < arguments.length; ++i) {
var arg = arguments[i];
assertPath(arg);
if (arg.length > 0) {
if (joined === undefined)
joined = arg;
else
joined += '/' + arg;
}
}
if (joined === undefined)
return '.';
return posix.normalize(joined);
},
relative: function relative(from, to) {
assertPath(from);
assertPath(to);
if (from === to) return '';
from = posix.resolve(from);
to = posix.resolve(to);
if (from === to) return '';
// Trim any leading backslashes
var fromStart = 1;
for (; fromStart < from.length; ++fromStart) {
if (from.charCodeAt(fromStart) !== 47 /*/*/)
break;
}
var fromEnd = from.length;
var fromLen = fromEnd - fromStart;
// Trim any leading backslashes
var toStart = 1;
for (; toStart < to.length; ++toStart) {
if (to.charCodeAt(toStart) !== 47 /*/*/)
break;
}
var toEnd = to.length;
var toLen = toEnd - toStart;
// Compare paths to find the longest common path from root
var length = fromLen < toLen ? fromLen : toLen;
var lastCommonSep = -1;
var i = 0;
for (; i <= length; ++i) {
if (i === length) {
if (toLen > length) {
if (to.charCodeAt(toStart + i) === 47 /*/*/) {
// We get here if `from` is the exact base path for `to`.
// For example: from='/foo/bar'; to='/foo/bar/baz'
return to.slice(toStart + i + 1);
} else if (i === 0) {
// We get here if `from` is the root
// For example: from='/'; to='/foo'
return to.slice(toStart + i);
}
} else if (fromLen > length) {
if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
} else if (i === 0) {
// We get here if `to` is the root.
// For example: from='/foo'; to='/'
lastCommonSep = 0;
}
}
break;
}
var fromCode = from.charCodeAt(fromStart + i);
var toCode = to.charCodeAt(toStart + i);
if (fromCode !== toCode)
break;
else if (fromCode === 47 /*/*/)
lastCommonSep = i;
}
var out = '';
// Generate the relative path based on the path difference between `to`
// and `from`
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
if (out.length === 0)
out += '..';
else
out += '/..';
}
}
// Lastly, append the rest of the destination (`to`) path that comes after
// the common path parts
if (out.length > 0)
return out + to.slice(toStart + lastCommonSep);
else {
toStart += lastCommonSep;
if (to.charCodeAt(toStart) === 47 /*/*/)
++toStart;
return to.slice(toStart);
}
},
_makeLong: function _makeLong(path) {
return path;
},
dirname: function dirname(path) {
assertPath(path);
if (path.length === 0) return '.';
var code = path.charCodeAt(0);
var hasRoot = code === 47 /*/*/;
var end = -1;
var matchedSlash = true;
for (var i = path.length - 1; i >= 1; --i) {
code = path.charCodeAt(i);
if (code === 47 /*/*/) {
if (!matchedSlash) {
end = i;
break;
}
} else {
// We saw the first non-path separator
matchedSlash = false;
}
}
if (end === -1) return hasRoot ? '/' : '.';
if (hasRoot && end === 1) return '//';
return path.slice(0, end);
},
basename: function basename(path, ext) {
if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
assertPath(path);
var start = 0;
var end = -1;
var matchedSlash = true;
var i;
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
if (ext.length === path.length && ext === path) return '';
var extIdx = ext.length - 1;
var firstNonSlashEnd = -1;
for (i = path.length - 1; i >= 0; --i) {
var code = path.charCodeAt(i);
if (code === 47 /*/*/) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
start = i + 1;
break;
}
} else {
if (firstNonSlashEnd === -1) {
// We saw the first non-path separator, remember this index in case
// we need it if the extension ends up not matching
matchedSlash = false;
firstNonSlashEnd = i + 1;
}
if (extIdx >= 0) {
// Try to match the explicit extension
if (code === ext.charCodeAt(extIdx)) {
if (--extIdx === -1) {
// We matched the extension, so mark this as the end of our path
// component
end = i;
}
} else {
// Extension does not match, so our result is the entire path
// component
extIdx = -1;
end = firstNonSlashEnd;
}
}
}
}
if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
return path.slice(start, end);
} else {
for (i = path.length - 1; i >= 0; --i) {
if (path.charCodeAt(i) === 47 /*/*/) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
start = i + 1;
break;
}
} else if (end === -1) {
// We saw the first non-path separator, mark this as the end of our
// path component
matchedSlash = false;
end = i + 1;
}
}
if (end === -1) return '';
return path.slice(start, end);
}
},
extname: function extname(path) {
assertPath(path);
var startDot = -1;
var startPart = 0;
var end = -1;
var matchedSlash = true;
// Track the state of characters (if any) we see before our first dot and
// after any path separator we find
var preDotState = 0;
for (var i = path.length - 1; i >= 0; --i) {
var code = path.charCodeAt(i);
if (code === 47 /*/*/) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
startPart = i + 1;
break;
}
continue;
}
if (end === -1) {
// We saw the first non-path separator, mark this as the end of our
// extension
matchedSlash = false;
end = i + 1;
}
if (code === 46 /*.*/) {
// If this is our first dot, mark it as the start of our extension
if (startDot === -1)
startDot = i;
else if (preDotState !== 1)
preDotState = 1;
} else if (startDot !== -1) {
// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension
preDotState = -1;
}
}
if (startDot === -1 || end === -1 ||
// We saw a non-dot character immediately before the dot
preDotState === 0 ||
// The (right-most) trimmed path component is exactly '..'
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
return '';
}
return path.slice(startDot, end);
},
format: function format(pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
}
return _format('/', pathObject);
},
parse: function parse(path) {
assertPath(path);
var ret = { root: '', dir: '', base: '', ext: '', name: '' };
if (path.length === 0) return ret;
var code = path.charCodeAt(0);
var isAbsolute = code === 47 /*/*/;
var start;
if (isAbsolute) {
ret.root = '/';
start = 1;
} else {
start = 0;
}
var startDot = -1;
var startPart = 0;
var end = -1;
var matchedSlash = true;
var i = path.length - 1;
// Track the state of characters (if any) we see before our first dot and
// after any path separator we find
var preDotState = 0;
// Get non-dir info
for (; i >= start; --i) {
code = path.charCodeAt(i);
if (code === 47 /*/*/) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
startPart = i + 1;
break;
}
continue;
}
if (end === -1) {
// We saw the first non-path separator, mark this as the end of our
// extension
matchedSlash = false;
end = i + 1;
}
if (code === 46 /*.*/) {
// If this is our first dot, mark it as the start of our extension
if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
} else if (startDot !== -1) {
// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension
preDotState = -1;
}
}
if (startDot === -1 || end === -1 ||
// We saw a non-dot character immediately before the dot
preDotState === 0 ||
// The (right-most) trimmed path component is exactly '..'
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
if (end !== -1) {
if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
}
} else {
if (startPart === 0 && isAbsolute) {
ret.name = path.slice(1, startDot);
ret.base = path.slice(1, end);
} else {
ret.name = path.slice(startPart, startDot);
ret.base = path.slice(startPart, end);
}
ret.ext = path.slice(startDot, end);
}
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
return ret;
},
sep: '/',
delimiter: ':',
win32: null,
posix: null
};
posix.posix = posix;
var pathBrowserify = posix;
const path = /*@__PURE__*/getDefaultExportFromCjs(pathBrowserify);
const _hoisted_1$a = { key: 2 };
const _sfc_main$g = /* @__PURE__ */ defineComponent({
__name: "SidebarItem",
props: {
item: {},
isCollapse: { type: Boolean, default: false },
isTop: { type: Boolean, default: false },
isFirstLevel: { type: Boolean, default: true },
basePath: { default: "" }
},
setup(__props) {
const props = __props;
const alwaysShowRootMenu = computed(() => props.item.meta?.alwaysShow);
const showingChildren = computed(() => {
return props.item.children?.filter((child) => !child.meta?.hidden) ?? [];
});
const showingChildNumber = computed(() => {
return showingChildren.value.length;
});
const theOnlyOneChild = computed(() => {
const number = showingChildNumber.value;
switch (true) {
case number > 1:
return null;
case number === 1:
return showingChildren.value[0];
default:
return { ...props.item, path: "" };
}
});
const resolvePath = (routePath) => {
switch (true) {
case isExternal(routePath):
return routePath;
case isExternal(props.basePath):
return props.basePath;
default:
return path.resolve(props.basePath, routePath);
}
};
return (_ctx, _cache) => {
const _component_SvgIcon = resolveComponent("SvgIcon");
const _component_el_menu_item = resolveComponent("el-menu-item");
const _component_sidebar_item = resolveComponent("sidebar-item", true);
const _component_el_sub_menu = resolveComponent("el-sub-menu");
return !props.item.meta?.hidden ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass({ "simple-mode": props.isCollapse && !_ctx.isTop, "first-level": props.isFirstLevel })
}, [
!alwaysShowRootMenu.value && theOnlyOneChild.value && !theOnlyOneChild.value.children ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
theOnlyOneChild.value.meta ? (openBlock(), createBlock(_sfc_main$h, {
key: 0,
to: resolvePath(theOnlyOneChild.value.path)
}, {
default: withCtx(() => [
createVNode(_component_el_menu_item, {
index: resolvePath(theOnlyOneChild.value.path)
}, createSlots({
default: withCtx(() => [
theOnlyOneChild.value.meta.svgIcon ? (openBlock(), createBlock(_component_SvgIcon, {
key: 0,
name: theOnlyOneChild.value.meta.svgIcon
}, null, 8, ["name"])) : theOnlyOneChild.value.meta.elIcon ? (openBlock(), createBlock(resolveDynamicComponent(theOnlyOneChild.value.meta.elIcon), {
key: 1,
class: "el-icon"
})) : createCommentVNode("", true)
]),
_: 2
}, [
theOnlyOneChild.value.meta.title ? {
name: "title",
fn: withCtx(() => [
createTextVNode(toDisplayString(theOnlyOneChild.value.meta.title), 1)
]),
key: "0"
} : void 0
]), 1032, ["index"])
]),
_: 1
}, 8, ["to"])) : createCommentVNode("", true)
], 64)) : (openBlock(), createBlock(_component_el_sub_menu, {
key: 1,
index: resolvePath(props.item.path),
teleported: ""
}, {
title: withCtx(() => [
props.item.meta?.svgIcon ? (openBlock(), createBlock(_component_SvgIcon, {
key: 0,
name: props.item.meta.svgIcon
}, null, 8, ["name"])) : props.item.meta?.elIcon ? (openBlock(), createBlock(resolveDynamicComponent(props.item.meta.elIcon), {
key: 1,
class: "el-icon"
})) : createCommentVNode("", true),
props.item.meta?.title ? (openBlock(), createElementBlock("span", _hoisted_1$a, toDisplayString(props.item.meta.title), 1)) : createCommentVNode("", true)
]),
default: withCtx(() => [
props.item.children && props.item.children.length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(props.item.children, (child) => {
return openBlock(), createBlock(_component_sidebar_item, {
key: child.path,
item: child,
"is-collapse": props.isCollapse,
"is-first-level": false,
"base-path": resolvePath(child.path)
}, null, 8, ["item", "is-collapse", "base-path"]);
}), 128)) : createCommentVNode("", true)
]),
_: 1
}, 8, ["index"]))
], 2)) : createCommentVNode("", true);
};
}
});
const SidebarItem_vue_vue_type_style_index_0_scoped_2227fea7_lang = '';
const SidebarItem = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-2227fea7"]]);
const _hoisted_1$9 = ["src"];
const _hoisted_2$6 = ["src"];
const _sfc_main$f = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
collapse: { type: Boolean, default: true }
},
setup(__props) {
const props = __props;
const settingsStore = useSettingsStore();
const { layoutMode, sideLogo, title } = storeToRefs(settingsStore);
return (_ctx, _cache) => {
const _component_router_link = resolveComponent("router-link");
return openBlock(), createElementBlock("div", {
class: normalizeClass(["layout-logo-container", { collapse: props.collapse, "layout-mode-top": unref(layoutMode) === "top" }])
}, [
createVNode(Transition, { name: "layout-logo-fade" }, {
default: withCtx(() => [
props.collapse ? (openBlock(), createBlock(_component_router_link, {
key: "collapse",
to: "/"
}, {
default: withCtx(() => [
createElementVNode("img", {
src: unref(sideLogo),
class: "layout-logo"
}, null, 8, _hoisted_1$9)
]),
_: 1
})) : (openBlock(), createBlock(_component_router_link, {
key: "expand",
to: "/",
class: "layout-logo-text"
}, {
default: withCtx(() => [
createElementVNode("img", {
src: unref(sideLogo),
style: { "flex": "32px 0 0", "width": "32px", "margin-left": "10px" }
}, null, 8, _hoisted_2$6),
createElementVNode("div", {
class: "layout-title",
style: normalizeStyle({ color: unref(layoutMode) !== "left" ? "#000" : "#fff" })
}, toDisplayString(unref(title)), 5)
]),
_: 1
}))
]),
_: 1
})
], 2);
};
}
});
const index_vue_vue_type_style_index_0_scoped_fa229ec7_lang = '';
const Logo = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-fa229ec7"]]);
const getCssVariableValue = (cssVariableName) => {
let cssVariableValue = "";
try {
cssVariableValue = getComputedStyle(document.documentElement).getPropertyValue(cssVariableName);
} catch (error) {
console.error(error);
}
return cssVariableValue;
};
const setCssVariableValue = (cssVariableName, cssVariableValue) => {
try {
document.documentElement.style.setProperty(cssVariableName, cssVariableValue);
} catch (error) {
console.error(error);
}
};
const resetConfigLayout = () => {
removeConfigLayout();
location.reload();
};
const _sfc_main$e = /* @__PURE__ */ defineComponent({
__name: "index",
setup(__props) {
useCssVars((_ctx) => ({
"56bea8c8": tipLineWidth.value,
"107712b2": hiddenScrollbarVerticalBar.value,
"75d0f4f8": sidebarMenuItemHeight.value,
"4df57e2c": sidebarMenuHoverBgColor.value,
"38d5ff3f": activeTextColor.value
}));
const v3SidebarMenuBgColor = getCssVariableValue("--v3-sidebar-menu-bg-color");
const v3SidebarMenuTextColor = getCssVariableValue("--v3-sidebar-menu-text-color");
const v3SidebarMenuActiveTextColor = getCssVariableValue("--v3-sidebar-menu-active-text-color");
const route = useRoute();
const appStore = useAppStore();
const permissionStore = usePermissionStore();
const settingsStore = useSettingsStore();
const { sidebar, device } = storeToRefs(appStore);
const { layoutMode, showLogo } = storeToRefs(settingsStore);
const activeMenu = computed(() => {
const {
meta: { activeMenu: activeMenu2 },
path
} = route;
return activeMenu2 ? activeMenu2 : path;
});
const isCollapse = computed(() => !sidebar.value.opened);
const isLeft = computed(() => layoutMode.value === "left");
const isTop = computed(() => layoutMode.value === "top");
const isMobile = computed(() => device.value === DeviceEnum.Mobile);
const isLogo = computed(() => isLeft.value && showLogo.value);
const backgroundColor = computed(() => isLeft.value ? v3SidebarMenuBgColor : void 0);
const textColor = computed(() => isLeft.value ? v3SidebarMenuTextColor : void 0);
const activeTextColor = computed(() => isLeft.value ? v3SidebarMenuActiveTextColor : void 0);
const sidebarMenuItemHeight = computed(() => {
return layoutMode.value !== "top" ? "var(--v3-sidebar-menu-item-height)" : "var(--v3-navigationbar-height)";
});
const sidebarMenuHoverBgColor = computed(() => {
return layoutMode.value !== "top" ? "var(--v3-sidebar-menu-hover-bg-color)" : "transparent";
});
const tipLineWidth = computed(() => {
return layoutMode.value !== "top" ? "2px" : "0px";
});
const hiddenScrollbarVerticalBar = computed(() => {
return layoutMode.value === "top" ? "none" : "block";
});
return (_ctx, _cache) => {
const _component_el_menu = resolveComponent("el-menu");
const _component_el_scrollbar = resolveComponent("el-scrollbar");
return openBlock(), createElementBlock("div", {
class: normalizeClass({ "has-logo": isLogo.value })
}, [
isLogo.value ? (openBlock(), createBlock(Logo, {
key: 0,
collapse: isCollapse.value
}, null, 8, ["collapse"])) : createCommentVNode("", true),
createVNode(_component_el_scrollbar, { "wrap-class": "scrollbar-wrapper" }, {
default: withCtx(() => [
createVNode(_component_el_menu, {
"default-active": activeMenu.value,
collapse: isCollapse.value && !isTop.value,
"background-color": backgroundColor.value,
"text-color": textColor.value,
"active-text-color": activeTextColor.value,
"unique-opened": true,
"collapse-transition": false,
mode: isTop.value && !isMobile.value ? "horizontal" : "vertical"
}, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(permissionStore).routes, (route2) => {
return openBlock(), createBlock(SidebarItem, {
key: route2.path,
item: route2,
"base-path": route2.path,
"is-collapse": isCollapse.value,
"is-top": isTop.value
}, null, 8, ["item", "base-path", "is-collapse", "is-top"]);
}), 128))
]),
_: 1
}, 8, ["default-active", "collapse", "background-color", "text-color", "active-text-color", "mode"])
]),
_: 1
})
], 2);
};
}
});
const index_vue_vue_type_style_index_0_scoped_1b00bae0_lang = '';
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-1b00bae0"]]);
const _hoisted_1$8 = { class: "card-header" };
const _hoisted_2$5 = { class: "card-title" };
const _hoisted_3$3 = { class: "card-time" };
const _hoisted_4$2 = {
key: 0,
class: "card-avatar"
};
const _hoisted_5$1 = ["src"];
const _hoisted_6$1 = { class: "card-body" };
const _sfc_main$d = /* @__PURE__ */ defineComponent({
__name: "NotifyList",
props: {
list: {},
prop: {}
},
setup(__props) {
return (_ctx, _cache) => {
const _component_el_empty = resolveComponent("el-empty");
const _component_el_tag = resolveComponent("el-tag");
const _component_el_card = resolveComponent("el-card");
return _ctx.list.length === 0 ? (openBlock(), createBlock(_component_el_empty, { key: 0 })) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.list, (_list, index) => {
return openBlock(), createBlock(_component_el_card, {
key: index,
shadow: "never",
class: "card-container"
}, {
header: withCtx(() => [
createElementVNode("div", _hoisted_1$8, [
createElementVNode("div", null, [
createElementVNode("span", null, [
createElementVNode("span", _hoisted_2$5, toDisplayString(_list[_ctx.prop.title]), 1),
_list[_ctx.prop.extra] ? (openBlock(), createBlock(_component_el_tag, {
key: 0,
type: _list[_ctx.prop.status],
effect: "plain",
size: "small"
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(_list[_ctx.prop.extra]), 1)
]),
_: 2
}, 1032, ["type"])) : createCommentVNode("", true)
]),
createElementVNode("div", _hoisted_3$3, toDisplayString(_list[_ctx.prop.datetime]), 1)
]),
_list[_ctx.prop.avatar] ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
createElementVNode("img", {
src: _list[_ctx.prop.avatar],
width: "34"
}, null, 8, _hoisted_5$1)
])) : createCommentVNode("", true)
])
]),
default: withCtx(() => [
createElementVNode("div", _hoisted_6$1, toDisplayString(_list[_ctx.prop.description] ?? "No Data"), 1)
]),
_: 2
}, 1024);
}), 128));
};
}
});
const NotifyList_vue_vue_type_style_index_0_scoped_7cda7a8f_lang = '';
const NotifyList = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-7cda7a8f"]]);
const _hoisted_1$7 = { class: "notify" };
const _hoisted_2$4 = { class: "notify-history" };
const badgeMax = 99;
const popoverWidth = 350;
const _sfc_main$c = /* @__PURE__ */ defineComponent({
__name: "index",
setup(__props) {
const router = useRouter();
const { notityProps } = useNotityHook();
const { column, jumpUrl, props } = notityProps;
const badgeValue = computed(() => {
return column.reduce((sum, item) => sum + item.badge, 0);
});
const activeName = ref(column[0].name || "通知");
const handleHistory = () => {
if (!jumpUrl) {
ElMessage.error(`您还没有配置跳转到${activeName.value}历史页面`);
}
router.push(jumpUrl);
};
return (_ctx, _cache) => {
const _component_el_icon = resolveComponent("el-icon");
const _component_el_tooltip = resolveComponent("el-tooltip");
const _component_el_badge = resolveComponent("el-badge");
const _component_el_scrollbar = resolveComponent("el-scrollbar");
const _component_el_tab_pane = resolveComponent("el-tab-pane");
const _component_el_tabs = resolveComponent("el-tabs");
const _component_el_button = resolveComponent("el-button");
const _component_el_popover = resolveComponent("el-popover");
return openBlock(), createElementBlock("div", _hoisted_1$7, [
createVNode(_component_el_popover, {
placement: "bottom",
width: popoverWidth,
trigger: "click"
}, {
reference: withCtx(() => [
createVNode(_component_el_badge, {
value: badgeValue.value,
max: badgeMax,
hidden: badgeValue.value === 0