";
-const main = "./out/main/index.js";
-const homepage = "https://github.com/algerkong/AlgerMusicPlayer";
-const scripts = {
- format: "prettier --write .",
- lint: "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts,.vue --fix",
- "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
- "typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false",
- typecheck: "npm run typecheck:node && npm run typecheck:web",
- start: "electron-vite preview",
- dev: "electron-vite dev",
- build: "npm run typecheck && electron-vite build",
- postinstall: "electron-builder install-app-deps",
- "build:unpack": "npm run build && electron-builder --dir",
- "build:win": "npm run build && electron-builder --win",
- "build:mac": "npm run build && electron-builder --mac",
- "build:linux": "npm run build && electron-builder --linux"
-};
-const dependencies = {
- "@electron-toolkit/preload": "^3.0.0",
- "@electron-toolkit/utils": "^3.0.0",
- "@unblockneteasemusic/server": "^0.27.8-patch.1",
- "electron-store": "^8.1.0",
- "electron-updater": "^6.1.7",
- "netease-cloud-music-api-alger": "^4.25.0"
-};
-const devDependencies = {
- marked: "^15.0.4",
- "@electron-toolkit/eslint-config": "^1.0.2",
- "@electron-toolkit/eslint-config-ts": "^2.0.0",
- "@electron-toolkit/tsconfig": "^1.0.1",
- "@rushstack/eslint-patch": "^1.10.3",
- "@tailwindcss/postcss7-compat": "^2.2.4",
- "@types/howler": "^2.2.12",
- "@types/node": "^20.14.8",
- "@typescript-eslint/eslint-plugin": "^7.0.0",
- "@typescript-eslint/parser": "^7.0.0",
- "@vitejs/plugin-vue": "^5.0.5",
- "@vue/compiler-sfc": "^3.5.0",
- "@vue/eslint-config-prettier": "^9.0.0",
- "@vue/eslint-config-typescript": "^13.0.0",
- "@vue/runtime-core": "^3.5.0",
- "@vueuse/core": "^11.0.3",
- "@vueuse/electron": "^11.0.3",
- autoprefixer: "^10.4.20",
- axios: "^1.7.7",
- "cross-env": "^7.0.3",
- electron: "^31.0.2",
- "electron-builder": "^24.13.3",
- "electron-vite": "^2.3.0",
- eslint: "^8.57.0",
- "eslint-config-airbnb-base": "^15.0.0",
- "eslint-config-prettier": "^9.0.0",
- "eslint-plugin-import": "^2.29.1",
- "eslint-plugin-prettier": "^5.1.3",
- "eslint-plugin-simple-import-sort": "^12.0.0",
- "eslint-plugin-vue": "^9.26.0",
- "eslint-plugin-vue-scoped-css": "^2.7.2",
- howler: "^2.2.4",
- lodash: "^4.17.21",
- "naive-ui": "^2.39.0",
- postcss: "^8.4.49",
- prettier: "^3.3.2",
- remixicon: "^4.2.0",
- sass: "^1.82.0",
- tailwindcss: "^3.4.15",
- typescript: "^5.5.2",
- "unplugin-auto-import": "^0.18.2",
- "unplugin-vue-components": "^0.27.4",
- vfonts: "^0.1.0",
- vite: "^5.3.1",
- "vite-plugin-compression": "^0.5.1",
- "vite-plugin-vue-devtools": "7.4.0",
- vue: "^3.4.30",
- "vue-router": "^4.4.3",
- "vue-tsc": "^2.0.22",
- vuex: "^4.1.0"
-};
-const build = {
- appId: "com.alger.music",
- productName: "AlgerMusicPlayer",
- mac: {
- icon: "resources/icon.icns",
- target: [
- {
- target: "dmg",
- arch: [
- "x64",
- "arm64"
- ]
- },
- {
- target: "zip",
- arch: [
- "x64",
- "arm64"
- ]
- }
- ]
- },
- win: {
- icon: "resources/favicon.ico",
- target: [
- "nsis",
- "zip"
- ]
- },
- linux: {
- icon: "resources/icon.png",
- target: [
- "AppImage",
- "deb"
- ]
- },
- nsis: {
- oneClick: false,
- allowToChangeInstallationDirectory: true,
- installerIcon: "resources/favicon.ico",
- uninstallerIcon: "resources/favicon.ico"
- }
-};
-const config = {
- name,
- version,
- description,
- author,
- main,
- homepage,
- scripts,
- dependencies,
- devDependencies,
- build
-};
-var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
-var howler = {};
-/*!
- * howler.js v2.2.4
- * howlerjs.com
- *
- * (c) 2013-2020, James Simpson of GoldFire Studios
- * goldfirestudios.com
- *
- * MIT License
- */
-(function(exports2) {
- (function() {
- var HowlerGlobal2 = function() {
- this.init();
- };
- HowlerGlobal2.prototype = {
- /**
- * Initialize the global Howler object.
- * @return {Howler}
- */
- init: function() {
- var self2 = this || Howler2;
- self2._counter = 1e3;
- self2._html5AudioPool = [];
- self2.html5PoolSize = 10;
- self2._codecs = {};
- self2._howls = [];
- self2._muted = false;
- self2._volume = 1;
- self2._canPlayEvent = "canplaythrough";
- self2._navigator = typeof window !== "undefined" && window.navigator ? window.navigator : null;
- self2.masterGain = null;
- self2.noAudio = false;
- self2.usingWebAudio = true;
- self2.autoSuspend = true;
- self2.ctx = null;
- self2.autoUnlock = true;
- self2._setup();
- return self2;
- },
- /**
- * Get/set the global volume for all sounds.
- * @param {Float} vol Volume from 0.0 to 1.0.
- * @return {Howler/Float} Returns self or current volume.
- */
- volume: function(vol) {
- var self2 = this || Howler2;
- vol = parseFloat(vol);
- if (!self2.ctx) {
- setupAudioContext();
- }
- if (typeof vol !== "undefined" && vol >= 0 && vol <= 1) {
- self2._volume = vol;
- if (self2._muted) {
- return self2;
- }
- if (self2.usingWebAudio) {
- self2.masterGain.gain.setValueAtTime(vol, Howler2.ctx.currentTime);
- }
- for (var i = 0; i < self2._howls.length; i++) {
- if (!self2._howls[i]._webAudio) {
- var ids = self2._howls[i]._getSoundIds();
- for (var j = 0; j < ids.length; j++) {
- var sound = self2._howls[i]._soundById(ids[j]);
- if (sound && sound._node) {
- sound._node.volume = sound._volume * vol;
- }
- }
- }
- }
- return self2;
- }
- return self2._volume;
- },
- /**
- * Handle muting and unmuting globally.
- * @param {Boolean} muted Is muted or not.
- */
- mute: function(muted) {
- var self2 = this || Howler2;
- if (!self2.ctx) {
- setupAudioContext();
- }
- self2._muted = muted;
- if (self2.usingWebAudio) {
- self2.masterGain.gain.setValueAtTime(muted ? 0 : self2._volume, Howler2.ctx.currentTime);
- }
- for (var i = 0; i < self2._howls.length; i++) {
- if (!self2._howls[i]._webAudio) {
- var ids = self2._howls[i]._getSoundIds();
- for (var j = 0; j < ids.length; j++) {
- var sound = self2._howls[i]._soundById(ids[j]);
- if (sound && sound._node) {
- sound._node.muted = muted ? true : sound._muted;
- }
- }
- }
- }
- return self2;
- },
- /**
- * Handle stopping all sounds globally.
- */
- stop: function() {
- var self2 = this || Howler2;
- for (var i = 0; i < self2._howls.length; i++) {
- self2._howls[i].stop();
- }
- return self2;
- },
- /**
- * Unload and destroy all currently loaded Howl objects.
- * @return {Howler}
- */
- unload: function() {
- var self2 = this || Howler2;
- for (var i = self2._howls.length - 1; i >= 0; i--) {
- self2._howls[i].unload();
- }
- if (self2.usingWebAudio && self2.ctx && typeof self2.ctx.close !== "undefined") {
- self2.ctx.close();
- self2.ctx = null;
- setupAudioContext();
- }
- return self2;
- },
- /**
- * Check for codec support of specific extension.
- * @param {String} ext Audio file extention.
- * @return {Boolean}
- */
- codecs: function(ext) {
- return (this || Howler2)._codecs[ext.replace(/^x-/, "")];
- },
- /**
- * Setup various state values for global tracking.
- * @return {Howler}
- */
- _setup: function() {
- var self2 = this || Howler2;
- self2.state = self2.ctx ? self2.ctx.state || "suspended" : "suspended";
- self2._autoSuspend();
- if (!self2.usingWebAudio) {
- if (typeof Audio !== "undefined") {
- try {
- var test2 = new Audio();
- if (typeof test2.oncanplaythrough === "undefined") {
- self2._canPlayEvent = "canplay";
- }
- } catch (e) {
- self2.noAudio = true;
- }
- } else {
- self2.noAudio = true;
- }
- }
- try {
- var test2 = new Audio();
- if (test2.muted) {
- self2.noAudio = true;
- }
- } catch (e) {
- }
- if (!self2.noAudio) {
- self2._setupCodecs();
- }
- return self2;
- },
- /**
- * Check for browser support for various codecs and cache the results.
- * @return {Howler}
- */
- _setupCodecs: function() {
- var self2 = this || Howler2;
- var audioTest = null;
- try {
- audioTest = typeof Audio !== "undefined" ? new Audio() : null;
- } catch (err) {
- return self2;
- }
- if (!audioTest || typeof audioTest.canPlayType !== "function") {
- return self2;
- }
- var mpegTest = audioTest.canPlayType("audio/mpeg;").replace(/^no$/, "");
- var ua = self2._navigator ? self2._navigator.userAgent : "";
- var checkOpera = ua.match(/OPR\/(\d+)/g);
- var isOldOpera = checkOpera && parseInt(checkOpera[0].split("/")[1], 10) < 33;
- var checkSafari = ua.indexOf("Safari") !== -1 && ua.indexOf("Chrome") === -1;
- var safariVersion = ua.match(/Version\/(.*?) /);
- var isOldSafari = checkSafari && safariVersion && parseInt(safariVersion[1], 10) < 15;
- self2._codecs = {
- mp3: !!(!isOldOpera && (mpegTest || audioTest.canPlayType("audio/mp3;").replace(/^no$/, ""))),
- mpeg: !!mpegTest,
- opus: !!audioTest.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ""),
- ogg: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
- oga: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
- wav: !!(audioTest.canPlayType('audio/wav; codecs="1"') || audioTest.canPlayType("audio/wav")).replace(/^no$/, ""),
- aac: !!audioTest.canPlayType("audio/aac;").replace(/^no$/, ""),
- caf: !!audioTest.canPlayType("audio/x-caf;").replace(/^no$/, ""),
- m4a: !!(audioTest.canPlayType("audio/x-m4a;") || audioTest.canPlayType("audio/m4a;") || audioTest.canPlayType("audio/aac;")).replace(/^no$/, ""),
- m4b: !!(audioTest.canPlayType("audio/x-m4b;") || audioTest.canPlayType("audio/m4b;") || audioTest.canPlayType("audio/aac;")).replace(/^no$/, ""),
- mp4: !!(audioTest.canPlayType("audio/x-mp4;") || audioTest.canPlayType("audio/mp4;") || audioTest.canPlayType("audio/aac;")).replace(/^no$/, ""),
- weba: !!(!isOldSafari && audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
- webm: !!(!isOldSafari && audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
- dolby: !!audioTest.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ""),
- flac: !!(audioTest.canPlayType("audio/x-flac;") || audioTest.canPlayType("audio/flac;")).replace(/^no$/, "")
- };
- return self2;
- },
- /**
- * Some browsers/devices will only allow audio to be played after a user interaction.
- * Attempt to automatically unlock audio on the first user interaction.
- * Concept from: http://paulbakaus.com/tutorials/html5/web-audio-on-ios/
- * @return {Howler}
- */
- _unlockAudio: function() {
- var self2 = this || Howler2;
- if (self2._audioUnlocked || !self2.ctx) {
- return;
- }
- self2._audioUnlocked = false;
- self2.autoUnlock = false;
- if (!self2._mobileUnloaded && self2.ctx.sampleRate !== 44100) {
- self2._mobileUnloaded = true;
- self2.unload();
- }
- self2._scratchBuffer = self2.ctx.createBuffer(1, 1, 22050);
- var unlock = function(e) {
- while (self2._html5AudioPool.length < self2.html5PoolSize) {
- try {
- var audioNode = new Audio();
- audioNode._unlocked = true;
- self2._releaseHtml5Audio(audioNode);
- } catch (e2) {
- self2.noAudio = true;
- break;
- }
- }
- for (var i = 0; i < self2._howls.length; i++) {
- if (!self2._howls[i]._webAudio) {
- var ids = self2._howls[i]._getSoundIds();
- for (var j = 0; j < ids.length; j++) {
- var sound = self2._howls[i]._soundById(ids[j]);
- if (sound && sound._node && !sound._node._unlocked) {
- sound._node._unlocked = true;
- sound._node.load();
- }
- }
- }
- }
- self2._autoResume();
- var source = self2.ctx.createBufferSource();
- source.buffer = self2._scratchBuffer;
- source.connect(self2.ctx.destination);
- if (typeof source.start === "undefined") {
- source.noteOn(0);
- } else {
- source.start(0);
- }
- if (typeof self2.ctx.resume === "function") {
- self2.ctx.resume();
- }
- source.onended = function() {
- source.disconnect(0);
- self2._audioUnlocked = true;
- document.removeEventListener("touchstart", unlock, true);
- document.removeEventListener("touchend", unlock, true);
- document.removeEventListener("click", unlock, true);
- document.removeEventListener("keydown", unlock, true);
- for (var i2 = 0; i2 < self2._howls.length; i2++) {
- self2._howls[i2]._emit("unlock");
- }
- };
- };
- document.addEventListener("touchstart", unlock, true);
- document.addEventListener("touchend", unlock, true);
- document.addEventListener("click", unlock, true);
- document.addEventListener("keydown", unlock, true);
- return self2;
- },
- /**
- * Get an unlocked HTML5 Audio object from the pool. If none are left,
- * return a new Audio object and throw a warning.
- * @return {Audio} HTML5 Audio object.
- */
- _obtainHtml5Audio: function() {
- var self2 = this || Howler2;
- if (self2._html5AudioPool.length) {
- return self2._html5AudioPool.pop();
- }
- var testPlay = new Audio().play();
- if (testPlay && typeof Promise !== "undefined" && (testPlay instanceof Promise || typeof testPlay.then === "function")) {
- testPlay.catch(function() {
- console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.");
- });
- }
- return new Audio();
- },
- /**
- * Return an activated HTML5 Audio object to the pool.
- * @return {Howler}
- */
- _releaseHtml5Audio: function(audio) {
- var self2 = this || Howler2;
- if (audio._unlocked) {
- self2._html5AudioPool.push(audio);
- }
- return self2;
- },
- /**
- * Automatically suspend the Web Audio AudioContext after no sound has played for 30 seconds.
- * This saves processing/energy and fixes various browser-specific bugs with audio getting stuck.
- * @return {Howler}
- */
- _autoSuspend: function() {
- var self2 = this;
- if (!self2.autoSuspend || !self2.ctx || typeof self2.ctx.suspend === "undefined" || !Howler2.usingWebAudio) {
- return;
- }
- for (var i = 0; i < self2._howls.length; i++) {
- if (self2._howls[i]._webAudio) {
- for (var j = 0; j < self2._howls[i]._sounds.length; j++) {
- if (!self2._howls[i]._sounds[j]._paused) {
- return self2;
- }
- }
- }
- }
- if (self2._suspendTimer) {
- clearTimeout(self2._suspendTimer);
- }
- self2._suspendTimer = setTimeout(function() {
- if (!self2.autoSuspend) {
- return;
- }
- self2._suspendTimer = null;
- self2.state = "suspending";
- var handleSuspension = function() {
- self2.state = "suspended";
- if (self2._resumeAfterSuspend) {
- delete self2._resumeAfterSuspend;
- self2._autoResume();
- }
- };
- self2.ctx.suspend().then(handleSuspension, handleSuspension);
- }, 3e4);
- return self2;
- },
- /**
- * Automatically resume the Web Audio AudioContext when a new sound is played.
- * @return {Howler}
- */
- _autoResume: function() {
- var self2 = this;
- if (!self2.ctx || typeof self2.ctx.resume === "undefined" || !Howler2.usingWebAudio) {
- return;
- }
- if (self2.state === "running" && self2.ctx.state !== "interrupted" && self2._suspendTimer) {
- clearTimeout(self2._suspendTimer);
- self2._suspendTimer = null;
- } else if (self2.state === "suspended" || self2.state === "running" && self2.ctx.state === "interrupted") {
- self2.ctx.resume().then(function() {
- self2.state = "running";
- for (var i = 0; i < self2._howls.length; i++) {
- self2._howls[i]._emit("resume");
- }
- });
- if (self2._suspendTimer) {
- clearTimeout(self2._suspendTimer);
- self2._suspendTimer = null;
- }
- } else if (self2.state === "suspending") {
- self2._resumeAfterSuspend = true;
- }
- return self2;
- }
- };
- var Howler2 = new HowlerGlobal2();
- var Howl2 = function(o) {
- var self2 = this;
- if (!o.src || o.src.length === 0) {
- console.error("An array of source files must be passed with any new Howl.");
- return;
- }
- self2.init(o);
- };
- Howl2.prototype = {
- /**
- * Initialize a new Howl group object.
- * @param {Object} o Passed in properties for this group.
- * @return {Howl}
- */
- init: function(o) {
- var self2 = this;
- if (!Howler2.ctx) {
- setupAudioContext();
- }
- self2._autoplay = o.autoplay || false;
- self2._format = typeof o.format !== "string" ? o.format : [o.format];
- self2._html5 = o.html5 || false;
- self2._muted = o.mute || false;
- self2._loop = o.loop || false;
- self2._pool = o.pool || 5;
- self2._preload = typeof o.preload === "boolean" || o.preload === "metadata" ? o.preload : true;
- self2._rate = o.rate || 1;
- self2._sprite = o.sprite || {};
- self2._src = typeof o.src !== "string" ? o.src : [o.src];
- self2._volume = o.volume !== void 0 ? o.volume : 1;
- self2._xhr = {
- method: o.xhr && o.xhr.method ? o.xhr.method : "GET",
- headers: o.xhr && o.xhr.headers ? o.xhr.headers : null,
- withCredentials: o.xhr && o.xhr.withCredentials ? o.xhr.withCredentials : false
- };
- self2._duration = 0;
- self2._state = "unloaded";
- self2._sounds = [];
- self2._endTimers = {};
- self2._queue = [];
- self2._playLock = false;
- self2._onend = o.onend ? [{ fn: o.onend }] : [];
- self2._onfade = o.onfade ? [{ fn: o.onfade }] : [];
- self2._onload = o.onload ? [{ fn: o.onload }] : [];
- self2._onloaderror = o.onloaderror ? [{ fn: o.onloaderror }] : [];
- self2._onplayerror = o.onplayerror ? [{ fn: o.onplayerror }] : [];
- self2._onpause = o.onpause ? [{ fn: o.onpause }] : [];
- self2._onplay = o.onplay ? [{ fn: o.onplay }] : [];
- self2._onstop = o.onstop ? [{ fn: o.onstop }] : [];
- self2._onmute = o.onmute ? [{ fn: o.onmute }] : [];
- self2._onvolume = o.onvolume ? [{ fn: o.onvolume }] : [];
- self2._onrate = o.onrate ? [{ fn: o.onrate }] : [];
- self2._onseek = o.onseek ? [{ fn: o.onseek }] : [];
- self2._onunlock = o.onunlock ? [{ fn: o.onunlock }] : [];
- self2._onresume = [];
- self2._webAudio = Howler2.usingWebAudio && !self2._html5;
- if (typeof Howler2.ctx !== "undefined" && Howler2.ctx && Howler2.autoUnlock) {
- Howler2._unlockAudio();
- }
- Howler2._howls.push(self2);
- if (self2._autoplay) {
- self2._queue.push({
- event: "play",
- action: function() {
- self2.play();
- }
- });
- }
- if (self2._preload && self2._preload !== "none") {
- self2.load();
- }
- return self2;
- },
- /**
- * Load the audio file.
- * @return {Howler}
- */
- load: function() {
- var self2 = this;
- var url = null;
- if (Howler2.noAudio) {
- self2._emit("loaderror", null, "No audio support.");
- return;
- }
- if (typeof self2._src === "string") {
- self2._src = [self2._src];
- }
- for (var i = 0; i < self2._src.length; i++) {
- var ext, str;
- if (self2._format && self2._format[i]) {
- ext = self2._format[i];
- } else {
- str = self2._src[i];
- if (typeof str !== "string") {
- self2._emit("loaderror", null, "Non-string found in selected audio sources - ignoring.");
- continue;
- }
- ext = /^data:audio\/([^;,]+);/i.exec(str);
- if (!ext) {
- ext = /\.([^.]+)$/.exec(str.split("?", 1)[0]);
- }
- if (ext) {
- ext = ext[1].toLowerCase();
- }
- }
- if (!ext) {
- console.warn('No file extension was found. Consider using the "format" property or specify an extension.');
- }
- if (ext && Howler2.codecs(ext)) {
- url = self2._src[i];
- break;
- }
- }
- if (!url) {
- self2._emit("loaderror", null, "No codec support for selected audio sources.");
- return;
- }
- self2._src = url;
- self2._state = "loading";
- if (window.location.protocol === "https:" && url.slice(0, 5) === "http:") {
- self2._html5 = true;
- self2._webAudio = false;
- }
- new Sound2(self2);
- if (self2._webAudio) {
- loadBuffer(self2);
- }
- return self2;
- },
- /**
- * Play a sound or resume previous playback.
- * @param {String/Number} sprite Sprite name for sprite playback or sound id to continue previous.
- * @param {Boolean} internal Internal Use: true prevents event firing.
- * @return {Number} Sound ID.
- */
- play: function(sprite, internal) {
- var self2 = this;
- var id = null;
- if (typeof sprite === "number") {
- id = sprite;
- sprite = null;
- } else if (typeof sprite === "string" && self2._state === "loaded" && !self2._sprite[sprite]) {
- return null;
- } else if (typeof sprite === "undefined") {
- sprite = "__default";
- if (!self2._playLock) {
- var num = 0;
- for (var i = 0; i < self2._sounds.length; i++) {
- if (self2._sounds[i]._paused && !self2._sounds[i]._ended) {
- num++;
- id = self2._sounds[i]._id;
- }
- }
- if (num === 1) {
- sprite = null;
- } else {
- id = null;
- }
- }
- }
- var sound = id ? self2._soundById(id) : self2._inactiveSound();
- if (!sound) {
- return null;
- }
- if (id && !sprite) {
- sprite = sound._sprite || "__default";
- }
- if (self2._state !== "loaded") {
- sound._sprite = sprite;
- sound._ended = false;
- var soundId = sound._id;
- self2._queue.push({
- event: "play",
- action: function() {
- self2.play(soundId);
- }
- });
- return soundId;
- }
- if (id && !sound._paused) {
- if (!internal) {
- self2._loadQueue("play");
- }
- return sound._id;
- }
- if (self2._webAudio) {
- Howler2._autoResume();
- }
- var seek = Math.max(0, sound._seek > 0 ? sound._seek : self2._sprite[sprite][0] / 1e3);
- var duration2 = Math.max(0, (self2._sprite[sprite][0] + self2._sprite[sprite][1]) / 1e3 - seek);
- var timeout = duration2 * 1e3 / Math.abs(sound._rate);
- var start = self2._sprite[sprite][0] / 1e3;
- var stop = (self2._sprite[sprite][0] + self2._sprite[sprite][1]) / 1e3;
- sound._sprite = sprite;
- sound._ended = false;
- var setParams = function() {
- sound._paused = false;
- sound._seek = seek;
- sound._start = start;
- sound._stop = stop;
- sound._loop = !!(sound._loop || self2._sprite[sprite][2]);
- };
- if (seek >= stop) {
- self2._ended(sound);
- return;
- }
- var node = sound._node;
- if (self2._webAudio) {
- var playWebAudio = function() {
- self2._playLock = false;
- setParams();
- self2._refreshBuffer(sound);
- var vol = sound._muted || self2._muted ? 0 : sound._volume;
- node.gain.setValueAtTime(vol, Howler2.ctx.currentTime);
- sound._playStart = Howler2.ctx.currentTime;
- if (typeof node.bufferSource.start === "undefined") {
- sound._loop ? node.bufferSource.noteGrainOn(0, seek, 86400) : node.bufferSource.noteGrainOn(0, seek, duration2);
- } else {
- sound._loop ? node.bufferSource.start(0, seek, 86400) : node.bufferSource.start(0, seek, duration2);
- }
- if (timeout !== Infinity) {
- self2._endTimers[sound._id] = setTimeout(self2._ended.bind(self2, sound), timeout);
- }
- if (!internal) {
- setTimeout(function() {
- self2._emit("play", sound._id);
- self2._loadQueue();
- }, 0);
- }
- };
- if (Howler2.state === "running" && Howler2.ctx.state !== "interrupted") {
- playWebAudio();
- } else {
- self2._playLock = true;
- self2.once("resume", playWebAudio);
- self2._clearTimer(sound._id);
- }
- } else {
- var playHtml5 = function() {
- node.currentTime = seek;
- node.muted = sound._muted || self2._muted || Howler2._muted || node.muted;
- node.volume = sound._volume * Howler2.volume();
- node.playbackRate = sound._rate;
- try {
- var play = node.play();
- if (play && typeof Promise !== "undefined" && (play instanceof Promise || typeof play.then === "function")) {
- self2._playLock = true;
- setParams();
- play.then(function() {
- self2._playLock = false;
- node._unlocked = true;
- if (!internal) {
- self2._emit("play", sound._id);
- } else {
- self2._loadQueue();
- }
- }).catch(function() {
- self2._playLock = false;
- self2._emit("playerror", sound._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");
- sound._ended = true;
- sound._paused = true;
- });
- } else if (!internal) {
- self2._playLock = false;
- setParams();
- self2._emit("play", sound._id);
- }
- node.playbackRate = sound._rate;
- if (node.paused) {
- self2._emit("playerror", sound._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");
- return;
- }
- if (sprite !== "__default" || sound._loop) {
- self2._endTimers[sound._id] = setTimeout(self2._ended.bind(self2, sound), timeout);
- } else {
- self2._endTimers[sound._id] = function() {
- self2._ended(sound);
- node.removeEventListener("ended", self2._endTimers[sound._id], false);
- };
- node.addEventListener("ended", self2._endTimers[sound._id], false);
- }
- } catch (err) {
- self2._emit("playerror", sound._id, err);
- }
- };
- if (node.src === "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA") {
- node.src = self2._src;
- node.load();
- }
- var loadedNoReadyState = window && window.ejecta || !node.readyState && Howler2._navigator.isCocoonJS;
- if (node.readyState >= 3 || loadedNoReadyState) {
- playHtml5();
- } else {
- self2._playLock = true;
- self2._state = "loading";
- var listener = function() {
- self2._state = "loaded";
- playHtml5();
- node.removeEventListener(Howler2._canPlayEvent, listener, false);
- };
- node.addEventListener(Howler2._canPlayEvent, listener, false);
- self2._clearTimer(sound._id);
- }
- }
- return sound._id;
- },
- /**
- * Pause playback and save current position.
- * @param {Number} id The sound ID (empty to pause all in group).
- * @return {Howl}
- */
- pause: function(id) {
- var self2 = this;
- if (self2._state !== "loaded" || self2._playLock) {
- self2._queue.push({
- event: "pause",
- action: function() {
- self2.pause(id);
- }
- });
- return self2;
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- self2._clearTimer(ids[i]);
- var sound = self2._soundById(ids[i]);
- if (sound && !sound._paused) {
- sound._seek = self2.seek(ids[i]);
- sound._rateSeek = 0;
- sound._paused = true;
- self2._stopFade(ids[i]);
- if (sound._node) {
- if (self2._webAudio) {
- if (!sound._node.bufferSource) {
- continue;
- }
- if (typeof sound._node.bufferSource.stop === "undefined") {
- sound._node.bufferSource.noteOff(0);
- } else {
- sound._node.bufferSource.stop(0);
- }
- self2._cleanBuffer(sound._node);
- } else if (!isNaN(sound._node.duration) || sound._node.duration === Infinity) {
- sound._node.pause();
- }
- }
- }
- if (!arguments[1]) {
- self2._emit("pause", sound ? sound._id : null);
- }
- }
- return self2;
- },
- /**
- * Stop playback and reset to start.
- * @param {Number} id The sound ID (empty to stop all in group).
- * @param {Boolean} internal Internal Use: true prevents event firing.
- * @return {Howl}
- */
- stop: function(id, internal) {
- var self2 = this;
- if (self2._state !== "loaded" || self2._playLock) {
- self2._queue.push({
- event: "stop",
- action: function() {
- self2.stop(id);
- }
- });
- return self2;
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- self2._clearTimer(ids[i]);
- var sound = self2._soundById(ids[i]);
- if (sound) {
- sound._seek = sound._start || 0;
- sound._rateSeek = 0;
- sound._paused = true;
- sound._ended = true;
- self2._stopFade(ids[i]);
- if (sound._node) {
- if (self2._webAudio) {
- if (sound._node.bufferSource) {
- if (typeof sound._node.bufferSource.stop === "undefined") {
- sound._node.bufferSource.noteOff(0);
- } else {
- sound._node.bufferSource.stop(0);
- }
- self2._cleanBuffer(sound._node);
- }
- } else if (!isNaN(sound._node.duration) || sound._node.duration === Infinity) {
- sound._node.currentTime = sound._start || 0;
- sound._node.pause();
- if (sound._node.duration === Infinity) {
- self2._clearSound(sound._node);
- }
- }
- }
- if (!internal) {
- self2._emit("stop", sound._id);
- }
- }
- }
- return self2;
- },
- /**
- * Mute/unmute a single sound or all sounds in this Howl group.
- * @param {Boolean} muted Set to true to mute and false to unmute.
- * @param {Number} id The sound ID to update (omit to mute/unmute all).
- * @return {Howl}
- */
- mute: function(muted, id) {
- var self2 = this;
- if (self2._state !== "loaded" || self2._playLock) {
- self2._queue.push({
- event: "mute",
- action: function() {
- self2.mute(muted, id);
- }
- });
- return self2;
- }
- if (typeof id === "undefined") {
- if (typeof muted === "boolean") {
- self2._muted = muted;
- } else {
- return self2._muted;
- }
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- var sound = self2._soundById(ids[i]);
- if (sound) {
- sound._muted = muted;
- if (sound._interval) {
- self2._stopFade(sound._id);
- }
- if (self2._webAudio && sound._node) {
- sound._node.gain.setValueAtTime(muted ? 0 : sound._volume, Howler2.ctx.currentTime);
- } else if (sound._node) {
- sound._node.muted = Howler2._muted ? true : muted;
- }
- self2._emit("mute", sound._id);
- }
- }
- return self2;
- },
- /**
- * Get/set the volume of this sound or of the Howl group. This method can optionally take 0, 1 or 2 arguments.
- * volume() -> Returns the group's volume value.
- * volume(id) -> Returns the sound id's current volume.
- * volume(vol) -> Sets the volume of all sounds in this Howl group.
- * volume(vol, id) -> Sets the volume of passed sound id.
- * @return {Howl/Number} Returns self or current volume.
- */
- volume: function() {
- var self2 = this;
- var args = arguments;
- var vol, id;
- if (args.length === 0) {
- return self2._volume;
- } else if (args.length === 1 || args.length === 2 && typeof args[1] === "undefined") {
- var ids = self2._getSoundIds();
- var index = ids.indexOf(args[0]);
- if (index >= 0) {
- id = parseInt(args[0], 10);
- } else {
- vol = parseFloat(args[0]);
- }
- } else if (args.length >= 2) {
- vol = parseFloat(args[0]);
- id = parseInt(args[1], 10);
- }
- var sound;
- if (typeof vol !== "undefined" && vol >= 0 && vol <= 1) {
- if (self2._state !== "loaded" || self2._playLock) {
- self2._queue.push({
- event: "volume",
- action: function() {
- self2.volume.apply(self2, args);
- }
- });
- return self2;
- }
- if (typeof id === "undefined") {
- self2._volume = vol;
- }
- id = self2._getSoundIds(id);
- for (var i = 0; i < id.length; i++) {
- sound = self2._soundById(id[i]);
- if (sound) {
- sound._volume = vol;
- if (!args[2]) {
- self2._stopFade(id[i]);
- }
- if (self2._webAudio && sound._node && !sound._muted) {
- sound._node.gain.setValueAtTime(vol, Howler2.ctx.currentTime);
- } else if (sound._node && !sound._muted) {
- sound._node.volume = vol * Howler2.volume();
- }
- self2._emit("volume", sound._id);
- }
- }
- } else {
- sound = id ? self2._soundById(id) : self2._sounds[0];
- return sound ? sound._volume : 0;
- }
- return self2;
- },
- /**
- * Fade a currently playing sound between two volumes (if no id is passed, all sounds will fade).
- * @param {Number} from The value to fade from (0.0 to 1.0).
- * @param {Number} to The volume to fade to (0.0 to 1.0).
- * @param {Number} len Time in milliseconds to fade.
- * @param {Number} id The sound id (omit to fade all sounds).
- * @return {Howl}
- */
- fade: function(from, to, len, id) {
- var self2 = this;
- if (self2._state !== "loaded" || self2._playLock) {
- self2._queue.push({
- event: "fade",
- action: function() {
- self2.fade(from, to, len, id);
- }
- });
- return self2;
- }
- from = Math.min(Math.max(0, parseFloat(from)), 1);
- to = Math.min(Math.max(0, parseFloat(to)), 1);
- len = parseFloat(len);
- self2.volume(from, id);
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- var sound = self2._soundById(ids[i]);
- if (sound) {
- if (!id) {
- self2._stopFade(ids[i]);
- }
- if (self2._webAudio && !sound._muted) {
- var currentTime = Howler2.ctx.currentTime;
- var end = currentTime + len / 1e3;
- sound._volume = from;
- sound._node.gain.setValueAtTime(from, currentTime);
- sound._node.gain.linearRampToValueAtTime(to, end);
- }
- self2._startFadeInterval(sound, from, to, len, ids[i], typeof id === "undefined");
- }
- }
- return self2;
- },
- /**
- * Starts the internal interval to fade a sound.
- * @param {Object} sound Reference to sound to fade.
- * @param {Number} from The value to fade from (0.0 to 1.0).
- * @param {Number} to The volume to fade to (0.0 to 1.0).
- * @param {Number} len Time in milliseconds to fade.
- * @param {Number} id The sound id to fade.
- * @param {Boolean} isGroup If true, set the volume on the group.
- */
- _startFadeInterval: function(sound, from, to, len, id, isGroup) {
- var self2 = this;
- var vol = from;
- var diff = to - from;
- var steps = Math.abs(diff / 0.01);
- var stepLen = Math.max(4, steps > 0 ? len / steps : len);
- var lastTick = Date.now();
- sound._fadeTo = to;
- sound._interval = setInterval(function() {
- var tick = (Date.now() - lastTick) / len;
- lastTick = Date.now();
- vol += diff * tick;
- vol = Math.round(vol * 100) / 100;
- if (diff < 0) {
- vol = Math.max(to, vol);
- } else {
- vol = Math.min(to, vol);
- }
- if (self2._webAudio) {
- sound._volume = vol;
- } else {
- self2.volume(vol, sound._id, true);
- }
- if (isGroup) {
- self2._volume = vol;
- }
- if (to < from && vol <= to || to > from && vol >= to) {
- clearInterval(sound._interval);
- sound._interval = null;
- sound._fadeTo = null;
- self2.volume(to, sound._id);
- self2._emit("fade", sound._id);
- }
- }, stepLen);
- },
- /**
- * Internal method that stops the currently playing fade when
- * a new fade starts, volume is changed or the sound is stopped.
- * @param {Number} id The sound id.
- * @return {Howl}
- */
- _stopFade: function(id) {
- var self2 = this;
- var sound = self2._soundById(id);
- if (sound && sound._interval) {
- if (self2._webAudio) {
- sound._node.gain.cancelScheduledValues(Howler2.ctx.currentTime);
- }
- clearInterval(sound._interval);
- sound._interval = null;
- self2.volume(sound._fadeTo, id);
- sound._fadeTo = null;
- self2._emit("fade", id);
- }
- return self2;
- },
- /**
- * Get/set the loop parameter on a sound. This method can optionally take 0, 1 or 2 arguments.
- * loop() -> Returns the group's loop value.
- * loop(id) -> Returns the sound id's loop value.
- * loop(loop) -> Sets the loop value for all sounds in this Howl group.
- * loop(loop, id) -> Sets the loop value of passed sound id.
- * @return {Howl/Boolean} Returns self or current loop value.
- */
- loop: function() {
- var self2 = this;
- var args = arguments;
- var loop, id, sound;
- if (args.length === 0) {
- return self2._loop;
- } else if (args.length === 1) {
- if (typeof args[0] === "boolean") {
- loop = args[0];
- self2._loop = loop;
- } else {
- sound = self2._soundById(parseInt(args[0], 10));
- return sound ? sound._loop : false;
- }
- } else if (args.length === 2) {
- loop = args[0];
- id = parseInt(args[1], 10);
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- sound = self2._soundById(ids[i]);
- if (sound) {
- sound._loop = loop;
- if (self2._webAudio && sound._node && sound._node.bufferSource) {
- sound._node.bufferSource.loop = loop;
- if (loop) {
- sound._node.bufferSource.loopStart = sound._start || 0;
- sound._node.bufferSource.loopEnd = sound._stop;
- if (self2.playing(ids[i])) {
- self2.pause(ids[i], true);
- self2.play(ids[i], true);
- }
- }
- }
- }
- }
- return self2;
- },
- /**
- * Get/set the playback rate of a sound. This method can optionally take 0, 1 or 2 arguments.
- * rate() -> Returns the first sound node's current playback rate.
- * rate(id) -> Returns the sound id's current playback rate.
- * rate(rate) -> Sets the playback rate of all sounds in this Howl group.
- * rate(rate, id) -> Sets the playback rate of passed sound id.
- * @return {Howl/Number} Returns self or the current playback rate.
- */
- rate: function() {
- var self2 = this;
- var args = arguments;
- var rate, id;
- if (args.length === 0) {
- id = self2._sounds[0]._id;
- } else if (args.length === 1) {
- var ids = self2._getSoundIds();
- var index = ids.indexOf(args[0]);
- if (index >= 0) {
- id = parseInt(args[0], 10);
- } else {
- rate = parseFloat(args[0]);
- }
- } else if (args.length === 2) {
- rate = parseFloat(args[0]);
- id = parseInt(args[1], 10);
- }
- var sound;
- if (typeof rate === "number") {
- if (self2._state !== "loaded" || self2._playLock) {
- self2._queue.push({
- event: "rate",
- action: function() {
- self2.rate.apply(self2, args);
- }
- });
- return self2;
- }
- if (typeof id === "undefined") {
- self2._rate = rate;
- }
- id = self2._getSoundIds(id);
- for (var i = 0; i < id.length; i++) {
- sound = self2._soundById(id[i]);
- if (sound) {
- if (self2.playing(id[i])) {
- sound._rateSeek = self2.seek(id[i]);
- sound._playStart = self2._webAudio ? Howler2.ctx.currentTime : sound._playStart;
- }
- sound._rate = rate;
- if (self2._webAudio && sound._node && sound._node.bufferSource) {
- sound._node.bufferSource.playbackRate.setValueAtTime(rate, Howler2.ctx.currentTime);
- } else if (sound._node) {
- sound._node.playbackRate = rate;
- }
- var seek = self2.seek(id[i]);
- var duration2 = (self2._sprite[sound._sprite][0] + self2._sprite[sound._sprite][1]) / 1e3 - seek;
- var timeout = duration2 * 1e3 / Math.abs(sound._rate);
- if (self2._endTimers[id[i]] || !sound._paused) {
- self2._clearTimer(id[i]);
- self2._endTimers[id[i]] = setTimeout(self2._ended.bind(self2, sound), timeout);
- }
- self2._emit("rate", sound._id);
- }
- }
- } else {
- sound = self2._soundById(id);
- return sound ? sound._rate : self2._rate;
- }
- return self2;
- },
- /**
- * Get/set the seek position of a sound. This method can optionally take 0, 1 or 2 arguments.
- * seek() -> Returns the first sound node's current seek position.
- * seek(id) -> Returns the sound id's current seek position.
- * seek(seek) -> Sets the seek position of the first sound node.
- * seek(seek, id) -> Sets the seek position of passed sound id.
- * @return {Howl/Number} Returns self or the current seek position.
- */
- seek: function() {
- var self2 = this;
- var args = arguments;
- var seek, id;
- if (args.length === 0) {
- if (self2._sounds.length) {
- id = self2._sounds[0]._id;
- }
- } else if (args.length === 1) {
- var ids = self2._getSoundIds();
- var index = ids.indexOf(args[0]);
- if (index >= 0) {
- id = parseInt(args[0], 10);
- } else if (self2._sounds.length) {
- id = self2._sounds[0]._id;
- seek = parseFloat(args[0]);
- }
- } else if (args.length === 2) {
- seek = parseFloat(args[0]);
- id = parseInt(args[1], 10);
- }
- if (typeof id === "undefined") {
- return 0;
- }
- if (typeof seek === "number" && (self2._state !== "loaded" || self2._playLock)) {
- self2._queue.push({
- event: "seek",
- action: function() {
- self2.seek.apply(self2, args);
- }
- });
- return self2;
- }
- var sound = self2._soundById(id);
- if (sound) {
- if (typeof seek === "number" && seek >= 0) {
- var playing = self2.playing(id);
- if (playing) {
- self2.pause(id, true);
- }
- sound._seek = seek;
- sound._ended = false;
- self2._clearTimer(id);
- if (!self2._webAudio && sound._node && !isNaN(sound._node.duration)) {
- sound._node.currentTime = seek;
- }
- var seekAndEmit = function() {
- if (playing) {
- self2.play(id, true);
- }
- self2._emit("seek", id);
- };
- if (playing && !self2._webAudio) {
- var emitSeek = function() {
- if (!self2._playLock) {
- seekAndEmit();
- } else {
- setTimeout(emitSeek, 0);
- }
- };
- setTimeout(emitSeek, 0);
- } else {
- seekAndEmit();
- }
- } else {
- if (self2._webAudio) {
- var realTime = self2.playing(id) ? Howler2.ctx.currentTime - sound._playStart : 0;
- var rateSeek = sound._rateSeek ? sound._rateSeek - sound._seek : 0;
- return sound._seek + (rateSeek + realTime * Math.abs(sound._rate));
- } else {
- return sound._node.currentTime;
- }
- }
- }
- return self2;
- },
- /**
- * Check if a specific sound is currently playing or not (if id is provided), or check if at least one of the sounds in the group is playing or not.
- * @param {Number} id The sound id to check. If none is passed, the whole sound group is checked.
- * @return {Boolean} True if playing and false if not.
- */
- playing: function(id) {
- var self2 = this;
- if (typeof id === "number") {
- var sound = self2._soundById(id);
- return sound ? !sound._paused : false;
- }
- for (var i = 0; i < self2._sounds.length; i++) {
- if (!self2._sounds[i]._paused) {
- return true;
- }
- }
- return false;
- },
- /**
- * Get the duration of this sound. Passing a sound id will return the sprite duration.
- * @param {Number} id The sound id to check. If none is passed, return full source duration.
- * @return {Number} Audio duration in seconds.
- */
- duration: function(id) {
- var self2 = this;
- var duration2 = self2._duration;
- var sound = self2._soundById(id);
- if (sound) {
- duration2 = self2._sprite[sound._sprite][1] / 1e3;
- }
- return duration2;
- },
- /**
- * Returns the current loaded state of this Howl.
- * @return {String} 'unloaded', 'loading', 'loaded'
- */
- state: function() {
- return this._state;
- },
- /**
- * Unload and destroy the current Howl object.
- * This will immediately stop all sound instances attached to this group.
- */
- unload: function() {
- var self2 = this;
- var sounds = self2._sounds;
- for (var i = 0; i < sounds.length; i++) {
- if (!sounds[i]._paused) {
- self2.stop(sounds[i]._id);
- }
- if (!self2._webAudio) {
- self2._clearSound(sounds[i]._node);
- sounds[i]._node.removeEventListener("error", sounds[i]._errorFn, false);
- sounds[i]._node.removeEventListener(Howler2._canPlayEvent, sounds[i]._loadFn, false);
- sounds[i]._node.removeEventListener("ended", sounds[i]._endFn, false);
- Howler2._releaseHtml5Audio(sounds[i]._node);
- }
- delete sounds[i]._node;
- self2._clearTimer(sounds[i]._id);
- }
- var index = Howler2._howls.indexOf(self2);
- if (index >= 0) {
- Howler2._howls.splice(index, 1);
- }
- var remCache = true;
- for (i = 0; i < Howler2._howls.length; i++) {
- if (Howler2._howls[i]._src === self2._src || self2._src.indexOf(Howler2._howls[i]._src) >= 0) {
- remCache = false;
- break;
- }
- }
- if (remCache) {
- delete cache2[self2._src];
- }
- Howler2.noAudio = false;
- self2._state = "unloaded";
- self2._sounds = [];
- self2 = null;
- return null;
- },
- /**
- * Listen to a custom event.
- * @param {String} event Event name.
- * @param {Function} fn Listener to call.
- * @param {Number} id (optional) Only listen to events for this sound.
- * @param {Number} once (INTERNAL) Marks event to fire only once.
- * @return {Howl}
- */
- on: function(event, fn, id, once) {
- var self2 = this;
- var events2 = self2["_on" + event];
- if (typeof fn === "function") {
- events2.push(once ? { id, fn, once } : { id, fn });
- }
- return self2;
- },
- /**
- * Remove a custom event. Call without parameters to remove all events.
- * @param {String} event Event name.
- * @param {Function} fn Listener to remove. Leave empty to remove all.
- * @param {Number} id (optional) Only remove events for this sound.
- * @return {Howl}
- */
- off: function(event, fn, id) {
- var self2 = this;
- var events2 = self2["_on" + event];
- var i = 0;
- if (typeof fn === "number") {
- id = fn;
- fn = null;
- }
- if (fn || id) {
- for (i = 0; i < events2.length; i++) {
- var isId = id === events2[i].id;
- if (fn === events2[i].fn && isId || !fn && isId) {
- events2.splice(i, 1);
- break;
- }
- }
- } else if (event) {
- self2["_on" + event] = [];
- } else {
- var keys = Object.keys(self2);
- for (i = 0; i < keys.length; i++) {
- if (keys[i].indexOf("_on") === 0 && Array.isArray(self2[keys[i]])) {
- self2[keys[i]] = [];
- }
- }
- }
- return self2;
- },
- /**
- * Listen to a custom event and remove it once fired.
- * @param {String} event Event name.
- * @param {Function} fn Listener to call.
- * @param {Number} id (optional) Only listen to events for this sound.
- * @return {Howl}
- */
- once: function(event, fn, id) {
- var self2 = this;
- self2.on(event, fn, id, 1);
- return self2;
- },
- /**
- * Emit all events of a specific type and pass the sound id.
- * @param {String} event Event name.
- * @param {Number} id Sound ID.
- * @param {Number} msg Message to go with event.
- * @return {Howl}
- */
- _emit: function(event, id, msg2) {
- var self2 = this;
- var events2 = self2["_on" + event];
- for (var i = events2.length - 1; i >= 0; i--) {
- if (!events2[i].id || events2[i].id === id || event === "load") {
- setTimeout(function(fn) {
- fn.call(this, id, msg2);
- }.bind(self2, events2[i].fn), 0);
- if (events2[i].once) {
- self2.off(event, events2[i].fn, events2[i].id);
- }
- }
- }
- self2._loadQueue(event);
- return self2;
- },
- /**
- * Queue of actions initiated before the sound has loaded.
- * These will be called in sequence, with the next only firing
- * after the previous has finished executing (even if async like play).
- * @return {Howl}
- */
- _loadQueue: function(event) {
- var self2 = this;
- if (self2._queue.length > 0) {
- var task = self2._queue[0];
- if (task.event === event) {
- self2._queue.shift();
- self2._loadQueue();
- }
- if (!event) {
- task.action();
- }
- }
- return self2;
- },
- /**
- * Fired when playback ends at the end of the duration.
- * @param {Sound} sound The sound object to work with.
- * @return {Howl}
- */
- _ended: function(sound) {
- var self2 = this;
- var sprite = sound._sprite;
- if (!self2._webAudio && sound._node && !sound._node.paused && !sound._node.ended && sound._node.currentTime < sound._stop) {
- setTimeout(self2._ended.bind(self2, sound), 100);
- return self2;
- }
- var loop = !!(sound._loop || self2._sprite[sprite][2]);
- self2._emit("end", sound._id);
- if (!self2._webAudio && loop) {
- self2.stop(sound._id, true).play(sound._id);
- }
- if (self2._webAudio && loop) {
- self2._emit("play", sound._id);
- sound._seek = sound._start || 0;
- sound._rateSeek = 0;
- sound._playStart = Howler2.ctx.currentTime;
- var timeout = (sound._stop - sound._start) * 1e3 / Math.abs(sound._rate);
- self2._endTimers[sound._id] = setTimeout(self2._ended.bind(self2, sound), timeout);
- }
- if (self2._webAudio && !loop) {
- sound._paused = true;
- sound._ended = true;
- sound._seek = sound._start || 0;
- sound._rateSeek = 0;
- self2._clearTimer(sound._id);
- self2._cleanBuffer(sound._node);
- Howler2._autoSuspend();
- }
- if (!self2._webAudio && !loop) {
- self2.stop(sound._id, true);
- }
- return self2;
- },
- /**
- * Clear the end timer for a sound playback.
- * @param {Number} id The sound ID.
- * @return {Howl}
- */
- _clearTimer: function(id) {
- var self2 = this;
- if (self2._endTimers[id]) {
- if (typeof self2._endTimers[id] !== "function") {
- clearTimeout(self2._endTimers[id]);
- } else {
- var sound = self2._soundById(id);
- if (sound && sound._node) {
- sound._node.removeEventListener("ended", self2._endTimers[id], false);
- }
- }
- delete self2._endTimers[id];
- }
- return self2;
- },
- /**
- * Return the sound identified by this ID, or return null.
- * @param {Number} id Sound ID
- * @return {Object} Sound object or null.
- */
- _soundById: function(id) {
- var self2 = this;
- for (var i = 0; i < self2._sounds.length; i++) {
- if (id === self2._sounds[i]._id) {
- return self2._sounds[i];
- }
- }
- return null;
- },
- /**
- * Return an inactive sound from the pool or create a new one.
- * @return {Sound} Sound playback object.
- */
- _inactiveSound: function() {
- var self2 = this;
- self2._drain();
- for (var i = 0; i < self2._sounds.length; i++) {
- if (self2._sounds[i]._ended) {
- return self2._sounds[i].reset();
- }
- }
- return new Sound2(self2);
- },
- /**
- * Drain excess inactive sounds from the pool.
- */
- _drain: function() {
- var self2 = this;
- var limit = self2._pool;
- var cnt = 0;
- var i = 0;
- if (self2._sounds.length < limit) {
- return;
- }
- for (i = 0; i < self2._sounds.length; i++) {
- if (self2._sounds[i]._ended) {
- cnt++;
- }
- }
- for (i = self2._sounds.length - 1; i >= 0; i--) {
- if (cnt <= limit) {
- return;
- }
- if (self2._sounds[i]._ended) {
- if (self2._webAudio && self2._sounds[i]._node) {
- self2._sounds[i]._node.disconnect(0);
- }
- self2._sounds.splice(i, 1);
- cnt--;
- }
- }
- },
- /**
- * Get all ID's from the sounds pool.
- * @param {Number} id Only return one ID if one is passed.
- * @return {Array} Array of IDs.
- */
- _getSoundIds: function(id) {
- var self2 = this;
- if (typeof id === "undefined") {
- var ids = [];
- for (var i = 0; i < self2._sounds.length; i++) {
- ids.push(self2._sounds[i]._id);
- }
- return ids;
- } else {
- return [id];
- }
- },
- /**
- * Load the sound back into the buffer source.
- * @param {Sound} sound The sound object to work with.
- * @return {Howl}
- */
- _refreshBuffer: function(sound) {
- var self2 = this;
- sound._node.bufferSource = Howler2.ctx.createBufferSource();
- sound._node.bufferSource.buffer = cache2[self2._src];
- if (sound._panner) {
- sound._node.bufferSource.connect(sound._panner);
- } else {
- sound._node.bufferSource.connect(sound._node);
- }
- sound._node.bufferSource.loop = sound._loop;
- if (sound._loop) {
- sound._node.bufferSource.loopStart = sound._start || 0;
- sound._node.bufferSource.loopEnd = sound._stop || 0;
- }
- sound._node.bufferSource.playbackRate.setValueAtTime(sound._rate, Howler2.ctx.currentTime);
- return self2;
- },
- /**
- * Prevent memory leaks by cleaning up the buffer source after playback.
- * @param {Object} node Sound's audio node containing the buffer source.
- * @return {Howl}
- */
- _cleanBuffer: function(node) {
- var self2 = this;
- var isIOS = Howler2._navigator && Howler2._navigator.vendor.indexOf("Apple") >= 0;
- if (!node.bufferSource) {
- return self2;
- }
- if (Howler2._scratchBuffer && node.bufferSource) {
- node.bufferSource.onended = null;
- node.bufferSource.disconnect(0);
- if (isIOS) {
- try {
- node.bufferSource.buffer = Howler2._scratchBuffer;
- } catch (e) {
- }
- }
- }
- node.bufferSource = null;
- return self2;
- },
- /**
- * Set the source to a 0-second silence to stop any downloading (except in IE).
- * @param {Object} node Audio node to clear.
- */
- _clearSound: function(node) {
- var checkIE = /MSIE |Trident\//.test(Howler2._navigator && Howler2._navigator.userAgent);
- if (!checkIE) {
- node.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA";
- }
- }
- };
- var Sound2 = function(howl) {
- this._parent = howl;
- this.init();
- };
- Sound2.prototype = {
- /**
- * Initialize a new Sound object.
- * @return {Sound}
- */
- init: function() {
- var self2 = this;
- var parent = self2._parent;
- self2._muted = parent._muted;
- self2._loop = parent._loop;
- self2._volume = parent._volume;
- self2._rate = parent._rate;
- self2._seek = 0;
- self2._paused = true;
- self2._ended = true;
- self2._sprite = "__default";
- self2._id = ++Howler2._counter;
- parent._sounds.push(self2);
- self2.create();
- return self2;
- },
- /**
- * Create and setup a new sound object, whether HTML5 Audio or Web Audio.
- * @return {Sound}
- */
- create: function() {
- var self2 = this;
- var parent = self2._parent;
- var volume = Howler2._muted || self2._muted || self2._parent._muted ? 0 : self2._volume;
- if (parent._webAudio) {
- self2._node = typeof Howler2.ctx.createGain === "undefined" ? Howler2.ctx.createGainNode() : Howler2.ctx.createGain();
- self2._node.gain.setValueAtTime(volume, Howler2.ctx.currentTime);
- self2._node.paused = true;
- self2._node.connect(Howler2.masterGain);
- } else if (!Howler2.noAudio) {
- self2._node = Howler2._obtainHtml5Audio();
- self2._errorFn = self2._errorListener.bind(self2);
- self2._node.addEventListener("error", self2._errorFn, false);
- self2._loadFn = self2._loadListener.bind(self2);
- self2._node.addEventListener(Howler2._canPlayEvent, self2._loadFn, false);
- self2._endFn = self2._endListener.bind(self2);
- self2._node.addEventListener("ended", self2._endFn, false);
- self2._node.src = parent._src;
- self2._node.preload = parent._preload === true ? "auto" : parent._preload;
- self2._node.volume = volume * Howler2.volume();
- self2._node.load();
- }
- return self2;
- },
- /**
- * Reset the parameters of this sound to the original state (for recycle).
- * @return {Sound}
- */
- reset: function() {
- var self2 = this;
- var parent = self2._parent;
- self2._muted = parent._muted;
- self2._loop = parent._loop;
- self2._volume = parent._volume;
- self2._rate = parent._rate;
- self2._seek = 0;
- self2._rateSeek = 0;
- self2._paused = true;
- self2._ended = true;
- self2._sprite = "__default";
- self2._id = ++Howler2._counter;
- return self2;
- },
- /**
- * HTML5 Audio error listener callback.
- */
- _errorListener: function() {
- var self2 = this;
- self2._parent._emit("loaderror", self2._id, self2._node.error ? self2._node.error.code : 0);
- self2._node.removeEventListener("error", self2._errorFn, false);
- },
- /**
- * HTML5 Audio canplaythrough listener callback.
- */
- _loadListener: function() {
- var self2 = this;
- var parent = self2._parent;
- parent._duration = Math.ceil(self2._node.duration * 10) / 10;
- if (Object.keys(parent._sprite).length === 0) {
- parent._sprite = { __default: [0, parent._duration * 1e3] };
- }
- if (parent._state !== "loaded") {
- parent._state = "loaded";
- parent._emit("load");
- parent._loadQueue();
- }
- self2._node.removeEventListener(Howler2._canPlayEvent, self2._loadFn, false);
- },
- /**
- * HTML5 Audio ended listener callback.
- */
- _endListener: function() {
- var self2 = this;
- var parent = self2._parent;
- if (parent._duration === Infinity) {
- parent._duration = Math.ceil(self2._node.duration * 10) / 10;
- if (parent._sprite.__default[1] === Infinity) {
- parent._sprite.__default[1] = parent._duration * 1e3;
- }
- parent._ended(self2);
- }
- self2._node.removeEventListener("ended", self2._endFn, false);
- }
- };
- var cache2 = {};
- var loadBuffer = function(self2) {
- var url = self2._src;
- if (cache2[url]) {
- self2._duration = cache2[url].duration;
- loadSound(self2);
- return;
- }
- if (/^data:[^;]+;base64,/.test(url)) {
- var data = atob(url.split(",")[1]);
- var dataView = new Uint8Array(data.length);
- for (var i = 0; i < data.length; ++i) {
- dataView[i] = data.charCodeAt(i);
- }
- decodeAudioData(dataView.buffer, self2);
- } else {
- var xhr = new XMLHttpRequest();
- xhr.open(self2._xhr.method, url, true);
- xhr.withCredentials = self2._xhr.withCredentials;
- xhr.responseType = "arraybuffer";
- if (self2._xhr.headers) {
- Object.keys(self2._xhr.headers).forEach(function(key) {
- xhr.setRequestHeader(key, self2._xhr.headers[key]);
- });
- }
- xhr.onload = function() {
- var code = (xhr.status + "")[0];
- if (code !== "0" && code !== "2" && code !== "3") {
- self2._emit("loaderror", null, "Failed loading audio file with status: " + xhr.status + ".");
- return;
- }
- decodeAudioData(xhr.response, self2);
- };
- xhr.onerror = function() {
- if (self2._webAudio) {
- self2._html5 = true;
- self2._webAudio = false;
- self2._sounds = [];
- delete cache2[url];
- self2.load();
- }
- };
- safeXhrSend(xhr);
- }
- };
- var safeXhrSend = function(xhr) {
- try {
- xhr.send();
- } catch (e) {
- xhr.onerror();
- }
- };
- var decodeAudioData = function(arraybuffer, self2) {
- var error = function() {
- self2._emit("loaderror", null, "Decoding audio data failed.");
- };
- var success = function(buffer) {
- if (buffer && self2._sounds.length > 0) {
- cache2[self2._src] = buffer;
- loadSound(self2, buffer);
- } else {
- error();
- }
- };
- if (typeof Promise !== "undefined" && Howler2.ctx.decodeAudioData.length === 1) {
- Howler2.ctx.decodeAudioData(arraybuffer).then(success).catch(error);
- } else {
- Howler2.ctx.decodeAudioData(arraybuffer, success, error);
- }
- };
- var loadSound = function(self2, buffer) {
- if (buffer && !self2._duration) {
- self2._duration = buffer.duration;
- }
- if (Object.keys(self2._sprite).length === 0) {
- self2._sprite = { __default: [0, self2._duration * 1e3] };
- }
- if (self2._state !== "loaded") {
- self2._state = "loaded";
- self2._emit("load");
- self2._loadQueue();
- }
- };
- var setupAudioContext = function() {
- if (!Howler2.usingWebAudio) {
- return;
- }
- try {
- if (typeof AudioContext !== "undefined") {
- Howler2.ctx = new AudioContext();
- } else if (typeof webkitAudioContext !== "undefined") {
- Howler2.ctx = new webkitAudioContext();
- } else {
- Howler2.usingWebAudio = false;
- }
- } catch (e) {
- Howler2.usingWebAudio = false;
- }
- if (!Howler2.ctx) {
- Howler2.usingWebAudio = false;
- }
- var iOS = /iP(hone|od|ad)/.test(Howler2._navigator && Howler2._navigator.platform);
- var appVersion = Howler2._navigator && Howler2._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
- var version2 = appVersion ? parseInt(appVersion[1], 10) : null;
- if (iOS && version2 && version2 < 9) {
- var safari = /safari/.test(Howler2._navigator && Howler2._navigator.userAgent.toLowerCase());
- if (Howler2._navigator && !safari) {
- Howler2.usingWebAudio = false;
- }
- }
- if (Howler2.usingWebAudio) {
- Howler2.masterGain = typeof Howler2.ctx.createGain === "undefined" ? Howler2.ctx.createGainNode() : Howler2.ctx.createGain();
- Howler2.masterGain.gain.setValueAtTime(Howler2._muted ? 0 : Howler2._volume, Howler2.ctx.currentTime);
- Howler2.masterGain.connect(Howler2.ctx.destination);
- }
- Howler2._setup();
- };
- {
- exports2.Howler = Howler2;
- exports2.Howl = Howl2;
- }
- if (typeof commonjsGlobal !== "undefined") {
- commonjsGlobal.HowlerGlobal = HowlerGlobal2;
- commonjsGlobal.Howler = Howler2;
- commonjsGlobal.Howl = Howl2;
- commonjsGlobal.Sound = Sound2;
- } else if (typeof window !== "undefined") {
- window.HowlerGlobal = HowlerGlobal2;
- window.Howler = Howler2;
- window.Howl = Howl2;
- window.Sound = Sound2;
- }
- })();
- /*!
- * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
- *
- * howler.js v2.2.4
- * howlerjs.com
- *
- * (c) 2013-2020, James Simpson of GoldFire Studios
- * goldfirestudios.com
- *
- * MIT License
- */
- (function() {
- HowlerGlobal.prototype._pos = [0, 0, 0];
- HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0];
- HowlerGlobal.prototype.stereo = function(pan) {
- var self2 = this;
- if (!self2.ctx || !self2.ctx.listener) {
- return self2;
- }
- for (var i = self2._howls.length - 1; i >= 0; i--) {
- self2._howls[i].stereo(pan);
- }
- return self2;
- };
- HowlerGlobal.prototype.pos = function(x, y, z) {
- var self2 = this;
- if (!self2.ctx || !self2.ctx.listener) {
- return self2;
- }
- y = typeof y !== "number" ? self2._pos[1] : y;
- z = typeof z !== "number" ? self2._pos[2] : z;
- if (typeof x === "number") {
- self2._pos = [x, y, z];
- if (typeof self2.ctx.listener.positionX !== "undefined") {
- self2.ctx.listener.positionX.setTargetAtTime(self2._pos[0], Howler.ctx.currentTime, 0.1);
- self2.ctx.listener.positionY.setTargetAtTime(self2._pos[1], Howler.ctx.currentTime, 0.1);
- self2.ctx.listener.positionZ.setTargetAtTime(self2._pos[2], Howler.ctx.currentTime, 0.1);
- } else {
- self2.ctx.listener.setPosition(self2._pos[0], self2._pos[1], self2._pos[2]);
- }
- } else {
- return self2._pos;
- }
- return self2;
- };
- HowlerGlobal.prototype.orientation = function(x, y, z, xUp, yUp, zUp) {
- var self2 = this;
- if (!self2.ctx || !self2.ctx.listener) {
- return self2;
- }
- var or = self2._orientation;
- y = typeof y !== "number" ? or[1] : y;
- z = typeof z !== "number" ? or[2] : z;
- xUp = typeof xUp !== "number" ? or[3] : xUp;
- yUp = typeof yUp !== "number" ? or[4] : yUp;
- zUp = typeof zUp !== "number" ? or[5] : zUp;
- if (typeof x === "number") {
- self2._orientation = [x, y, z, xUp, yUp, zUp];
- if (typeof self2.ctx.listener.forwardX !== "undefined") {
- self2.ctx.listener.forwardX.setTargetAtTime(x, Howler.ctx.currentTime, 0.1);
- self2.ctx.listener.forwardY.setTargetAtTime(y, Howler.ctx.currentTime, 0.1);
- self2.ctx.listener.forwardZ.setTargetAtTime(z, Howler.ctx.currentTime, 0.1);
- self2.ctx.listener.upX.setTargetAtTime(xUp, Howler.ctx.currentTime, 0.1);
- self2.ctx.listener.upY.setTargetAtTime(yUp, Howler.ctx.currentTime, 0.1);
- self2.ctx.listener.upZ.setTargetAtTime(zUp, Howler.ctx.currentTime, 0.1);
- } else {
- self2.ctx.listener.setOrientation(x, y, z, xUp, yUp, zUp);
- }
- } else {
- return or;
- }
- return self2;
- };
- Howl.prototype.init = /* @__PURE__ */ function(_super) {
- return function(o) {
- var self2 = this;
- self2._orientation = o.orientation || [1, 0, 0];
- self2._stereo = o.stereo || null;
- self2._pos = o.pos || null;
- self2._pannerAttr = {
- coneInnerAngle: typeof o.coneInnerAngle !== "undefined" ? o.coneInnerAngle : 360,
- coneOuterAngle: typeof o.coneOuterAngle !== "undefined" ? o.coneOuterAngle : 360,
- coneOuterGain: typeof o.coneOuterGain !== "undefined" ? o.coneOuterGain : 0,
- distanceModel: typeof o.distanceModel !== "undefined" ? o.distanceModel : "inverse",
- maxDistance: typeof o.maxDistance !== "undefined" ? o.maxDistance : 1e4,
- panningModel: typeof o.panningModel !== "undefined" ? o.panningModel : "HRTF",
- refDistance: typeof o.refDistance !== "undefined" ? o.refDistance : 1,
- rolloffFactor: typeof o.rolloffFactor !== "undefined" ? o.rolloffFactor : 1
- };
- self2._onstereo = o.onstereo ? [{ fn: o.onstereo }] : [];
- self2._onpos = o.onpos ? [{ fn: o.onpos }] : [];
- self2._onorientation = o.onorientation ? [{ fn: o.onorientation }] : [];
- return _super.call(this, o);
- };
- }(Howl.prototype.init);
- Howl.prototype.stereo = function(pan, id) {
- var self2 = this;
- if (!self2._webAudio) {
- return self2;
- }
- if (self2._state !== "loaded") {
- self2._queue.push({
- event: "stereo",
- action: function() {
- self2.stereo(pan, id);
- }
- });
- return self2;
- }
- var pannerType = typeof Howler.ctx.createStereoPanner === "undefined" ? "spatial" : "stereo";
- if (typeof id === "undefined") {
- if (typeof pan === "number") {
- self2._stereo = pan;
- self2._pos = [pan, 0, 0];
- } else {
- return self2._stereo;
- }
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- var sound = self2._soundById(ids[i]);
- if (sound) {
- if (typeof pan === "number") {
- sound._stereo = pan;
- sound._pos = [pan, 0, 0];
- if (sound._node) {
- sound._pannerAttr.panningModel = "equalpower";
- if (!sound._panner || !sound._panner.pan) {
- setupPanner(sound, pannerType);
- }
- if (pannerType === "spatial") {
- if (typeof sound._panner.positionX !== "undefined") {
- sound._panner.positionX.setValueAtTime(pan, Howler.ctx.currentTime);
- sound._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime);
- sound._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime);
- } else {
- sound._panner.setPosition(pan, 0, 0);
- }
- } else {
- sound._panner.pan.setValueAtTime(pan, Howler.ctx.currentTime);
- }
- }
- self2._emit("stereo", sound._id);
- } else {
- return sound._stereo;
- }
- }
- }
- return self2;
- };
- Howl.prototype.pos = function(x, y, z, id) {
- var self2 = this;
- if (!self2._webAudio) {
- return self2;
- }
- if (self2._state !== "loaded") {
- self2._queue.push({
- event: "pos",
- action: function() {
- self2.pos(x, y, z, id);
- }
- });
- return self2;
- }
- y = typeof y !== "number" ? 0 : y;
- z = typeof z !== "number" ? -0.5 : z;
- if (typeof id === "undefined") {
- if (typeof x === "number") {
- self2._pos = [x, y, z];
- } else {
- return self2._pos;
- }
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- var sound = self2._soundById(ids[i]);
- if (sound) {
- if (typeof x === "number") {
- sound._pos = [x, y, z];
- if (sound._node) {
- if (!sound._panner || sound._panner.pan) {
- setupPanner(sound, "spatial");
- }
- if (typeof sound._panner.positionX !== "undefined") {
- sound._panner.positionX.setValueAtTime(x, Howler.ctx.currentTime);
- sound._panner.positionY.setValueAtTime(y, Howler.ctx.currentTime);
- sound._panner.positionZ.setValueAtTime(z, Howler.ctx.currentTime);
- } else {
- sound._panner.setPosition(x, y, z);
- }
- }
- self2._emit("pos", sound._id);
- } else {
- return sound._pos;
- }
- }
- }
- return self2;
- };
- Howl.prototype.orientation = function(x, y, z, id) {
- var self2 = this;
- if (!self2._webAudio) {
- return self2;
- }
- if (self2._state !== "loaded") {
- self2._queue.push({
- event: "orientation",
- action: function() {
- self2.orientation(x, y, z, id);
- }
- });
- return self2;
- }
- y = typeof y !== "number" ? self2._orientation[1] : y;
- z = typeof z !== "number" ? self2._orientation[2] : z;
- if (typeof id === "undefined") {
- if (typeof x === "number") {
- self2._orientation = [x, y, z];
- } else {
- return self2._orientation;
- }
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- var sound = self2._soundById(ids[i]);
- if (sound) {
- if (typeof x === "number") {
- sound._orientation = [x, y, z];
- if (sound._node) {
- if (!sound._panner) {
- if (!sound._pos) {
- sound._pos = self2._pos || [0, 0, -0.5];
- }
- setupPanner(sound, "spatial");
- }
- if (typeof sound._panner.orientationX !== "undefined") {
- sound._panner.orientationX.setValueAtTime(x, Howler.ctx.currentTime);
- sound._panner.orientationY.setValueAtTime(y, Howler.ctx.currentTime);
- sound._panner.orientationZ.setValueAtTime(z, Howler.ctx.currentTime);
- } else {
- sound._panner.setOrientation(x, y, z);
- }
- }
- self2._emit("orientation", sound._id);
- } else {
- return sound._orientation;
- }
- }
- }
- return self2;
- };
- Howl.prototype.pannerAttr = function() {
- var self2 = this;
- var args = arguments;
- var o, id, sound;
- if (!self2._webAudio) {
- return self2;
- }
- if (args.length === 0) {
- return self2._pannerAttr;
- } else if (args.length === 1) {
- if (typeof args[0] === "object") {
- o = args[0];
- if (typeof id === "undefined") {
- if (!o.pannerAttr) {
- o.pannerAttr = {
- coneInnerAngle: o.coneInnerAngle,
- coneOuterAngle: o.coneOuterAngle,
- coneOuterGain: o.coneOuterGain,
- distanceModel: o.distanceModel,
- maxDistance: o.maxDistance,
- refDistance: o.refDistance,
- rolloffFactor: o.rolloffFactor,
- panningModel: o.panningModel
- };
- }
- self2._pannerAttr = {
- coneInnerAngle: typeof o.pannerAttr.coneInnerAngle !== "undefined" ? o.pannerAttr.coneInnerAngle : self2._coneInnerAngle,
- coneOuterAngle: typeof o.pannerAttr.coneOuterAngle !== "undefined" ? o.pannerAttr.coneOuterAngle : self2._coneOuterAngle,
- coneOuterGain: typeof o.pannerAttr.coneOuterGain !== "undefined" ? o.pannerAttr.coneOuterGain : self2._coneOuterGain,
- distanceModel: typeof o.pannerAttr.distanceModel !== "undefined" ? o.pannerAttr.distanceModel : self2._distanceModel,
- maxDistance: typeof o.pannerAttr.maxDistance !== "undefined" ? o.pannerAttr.maxDistance : self2._maxDistance,
- refDistance: typeof o.pannerAttr.refDistance !== "undefined" ? o.pannerAttr.refDistance : self2._refDistance,
- rolloffFactor: typeof o.pannerAttr.rolloffFactor !== "undefined" ? o.pannerAttr.rolloffFactor : self2._rolloffFactor,
- panningModel: typeof o.pannerAttr.panningModel !== "undefined" ? o.pannerAttr.panningModel : self2._panningModel
- };
- }
- } else {
- sound = self2._soundById(parseInt(args[0], 10));
- return sound ? sound._pannerAttr : self2._pannerAttr;
- }
- } else if (args.length === 2) {
- o = args[0];
- id = parseInt(args[1], 10);
- }
- var ids = self2._getSoundIds(id);
- for (var i = 0; i < ids.length; i++) {
- sound = self2._soundById(ids[i]);
- if (sound) {
- var pa = sound._pannerAttr;
- pa = {
- coneInnerAngle: typeof o.coneInnerAngle !== "undefined" ? o.coneInnerAngle : pa.coneInnerAngle,
- coneOuterAngle: typeof o.coneOuterAngle !== "undefined" ? o.coneOuterAngle : pa.coneOuterAngle,
- coneOuterGain: typeof o.coneOuterGain !== "undefined" ? o.coneOuterGain : pa.coneOuterGain,
- distanceModel: typeof o.distanceModel !== "undefined" ? o.distanceModel : pa.distanceModel,
- maxDistance: typeof o.maxDistance !== "undefined" ? o.maxDistance : pa.maxDistance,
- refDistance: typeof o.refDistance !== "undefined" ? o.refDistance : pa.refDistance,
- rolloffFactor: typeof o.rolloffFactor !== "undefined" ? o.rolloffFactor : pa.rolloffFactor,
- panningModel: typeof o.panningModel !== "undefined" ? o.panningModel : pa.panningModel
- };
- var panner = sound._panner;
- if (!panner) {
- if (!sound._pos) {
- sound._pos = self2._pos || [0, 0, -0.5];
- }
- setupPanner(sound, "spatial");
- panner = sound._panner;
- }
- panner.coneInnerAngle = pa.coneInnerAngle;
- panner.coneOuterAngle = pa.coneOuterAngle;
- panner.coneOuterGain = pa.coneOuterGain;
- panner.distanceModel = pa.distanceModel;
- panner.maxDistance = pa.maxDistance;
- panner.refDistance = pa.refDistance;
- panner.rolloffFactor = pa.rolloffFactor;
- panner.panningModel = pa.panningModel;
- }
- }
- return self2;
- };
- Sound.prototype.init = /* @__PURE__ */ function(_super) {
- return function() {
- var self2 = this;
- var parent = self2._parent;
- self2._orientation = parent._orientation;
- self2._stereo = parent._stereo;
- self2._pos = parent._pos;
- self2._pannerAttr = parent._pannerAttr;
- _super.call(this);
- if (self2._stereo) {
- parent.stereo(self2._stereo);
- } else if (self2._pos) {
- parent.pos(self2._pos[0], self2._pos[1], self2._pos[2], self2._id);
- }
- };
- }(Sound.prototype.init);
- Sound.prototype.reset = /* @__PURE__ */ function(_super) {
- return function() {
- var self2 = this;
- var parent = self2._parent;
- self2._orientation = parent._orientation;
- self2._stereo = parent._stereo;
- self2._pos = parent._pos;
- self2._pannerAttr = parent._pannerAttr;
- if (self2._stereo) {
- parent.stereo(self2._stereo);
- } else if (self2._pos) {
- parent.pos(self2._pos[0], self2._pos[1], self2._pos[2], self2._id);
- } else if (self2._panner) {
- self2._panner.disconnect(0);
- self2._panner = void 0;
- parent._refreshBuffer(self2);
- }
- return _super.call(this);
- };
- }(Sound.prototype.reset);
- var setupPanner = function(sound, type) {
- type = type || "spatial";
- if (type === "spatial") {
- sound._panner = Howler.ctx.createPanner();
- sound._panner.coneInnerAngle = sound._pannerAttr.coneInnerAngle;
- sound._panner.coneOuterAngle = sound._pannerAttr.coneOuterAngle;
- sound._panner.coneOuterGain = sound._pannerAttr.coneOuterGain;
- sound._panner.distanceModel = sound._pannerAttr.distanceModel;
- sound._panner.maxDistance = sound._pannerAttr.maxDistance;
- sound._panner.refDistance = sound._pannerAttr.refDistance;
- sound._panner.rolloffFactor = sound._pannerAttr.rolloffFactor;
- sound._panner.panningModel = sound._pannerAttr.panningModel;
- if (typeof sound._panner.positionX !== "undefined") {
- sound._panner.positionX.setValueAtTime(sound._pos[0], Howler.ctx.currentTime);
- sound._panner.positionY.setValueAtTime(sound._pos[1], Howler.ctx.currentTime);
- sound._panner.positionZ.setValueAtTime(sound._pos[2], Howler.ctx.currentTime);
- } else {
- sound._panner.setPosition(sound._pos[0], sound._pos[1], sound._pos[2]);
- }
- if (typeof sound._panner.orientationX !== "undefined") {
- sound._panner.orientationX.setValueAtTime(sound._orientation[0], Howler.ctx.currentTime);
- sound._panner.orientationY.setValueAtTime(sound._orientation[1], Howler.ctx.currentTime);
- sound._panner.orientationZ.setValueAtTime(sound._orientation[2], Howler.ctx.currentTime);
- } else {
- sound._panner.setOrientation(sound._orientation[0], sound._orientation[1], sound._orientation[2]);
- }
- } else {
- sound._panner = Howler.ctx.createStereoPanner();
- sound._panner.pan.setValueAtTime(sound._stereo, Howler.ctx.currentTime);
- }
- sound._panner.connect(sound._node);
- if (!sound._paused) {
- sound._parent.pause(sound._id, true).play(sound._id, true);
- }
- };
- })();
-})(howler);
-const setData = window.electron.ipcRenderer.sendSync("get-store-value", "set");
-const baseURL$1 = window.electron ? `http://127.0.0.1:${setData.musicApiPort}` : "http://110.42.251.190:9898";
-const request$1 = axios.create({
- baseURL: baseURL$1,
- timeout: 5e3
-});
-const MAX_RETRIES = 3;
-const RETRY_DELAY = 500;
-request$1.interceptors.request.use(
- (config2) => {
- config2.retryCount = 0;
- if (config2.method === "get") {
- config2.params = {
- ...config2.params,
- timestamp: Date.now()
- };
- const token = localStorage.getItem("token");
- if (token) {
- config2.params.cookie = token;
- }
- }
- return config2;
- },
- (error) => {
- return Promise.reject(error);
- }
-);
-request$1.interceptors.response.use(
- (response) => {
- return response;
- },
- async (error) => {
- const config2 = error.config;
- if (!config2 || !config2.retryCount) {
- config2.retryCount = 0;
- }
- if (config2.retryCount < MAX_RETRIES) {
- config2.retryCount++;
- await new Promise((resolve2) => setTimeout(resolve2, RETRY_DELAY));
- return request$1(config2);
- }
- return Promise.reject(error);
- }
-);
-const baseURL = `${"http://110.42.251.190:4100"}`;
-const request = axios.create({
- baseURL,
- timeout: 1e4
-});
-request.interceptors.request.use(
- (config2) => {
- return config2;
- },
- (error) => {
- return Promise.reject(error);
- }
-);
-const getMusicUrl = (id) => {
- return request$1.get("/song/url", { params: { id } });
-};
-const getMusicDetail = (ids) => {
- return request$1.get("/song/detail", { params: { ids: ids.join(",") } });
-};
-const getMusicLrc = (id) => {
- return request$1.get("/lyric", { params: { id } });
-};
-const getParsingMusicUrl = (id) => {
- if (isElectron) {
- return window.api.unblockMusic(id);
- }
- return request.get("/music", { params: { id } });
-};
-function tryOnScopeDispose(fn) {
- if (getCurrentScope()) {
- onScopeDispose(fn);
- return true;
- }
- return false;
-}
-function toValue(r) {
- return typeof r === "function" ? r() : unref(r);
-}
-const isClient = typeof window !== "undefined" && typeof document !== "undefined";
-typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
-const toString2 = Object.prototype.toString;
-const isObject = (val) => toString2.call(val) === "[object Object]";
-const noop = () => {
-};
-function createFilterWrapper(filter2, fn) {
- function wrapper(...args) {
- return new Promise((resolve2, reject) => {
- Promise.resolve(filter2(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve2).catch(reject);
- });
- }
- return wrapper;
-}
-const bypassFilter = (invoke2) => {
- return invoke2();
-};
-function debounceFilter(ms, options = {}) {
- let timer;
- let maxTimer;
- let lastRejector = noop;
- const _clearTimeout = (timer2) => {
- clearTimeout(timer2);
- lastRejector();
- lastRejector = noop;
- };
- const filter2 = (invoke2) => {
- const duration2 = toValue(ms);
- const maxDuration = toValue(options.maxWait);
- if (timer)
- _clearTimeout(timer);
- if (duration2 <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
- if (maxTimer) {
- _clearTimeout(maxTimer);
- maxTimer = null;
- }
- return Promise.resolve(invoke2());
- }
- return new Promise((resolve2, reject) => {
- lastRejector = options.rejectOnCancel ? reject : resolve2;
- if (maxDuration && !maxTimer) {
- maxTimer = setTimeout(() => {
- if (timer)
- _clearTimeout(timer);
- maxTimer = null;
- resolve2(invoke2());
- }, maxDuration);
- }
- timer = setTimeout(() => {
- if (maxTimer)
- _clearTimeout(maxTimer);
- maxTimer = null;
- resolve2(invoke2());
- }, duration2);
- });
- };
- return filter2;
-}
-function throttleFilter(...args) {
- let lastExec = 0;
- let timer;
- let isLeading = true;
- let lastRejector = noop;
- let lastValue;
- let ms;
- let trailing;
- let leading;
- let rejectOnCancel;
- if (!isRef(args[0]) && typeof args[0] === "object")
- ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
- else
- [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
- const clear = () => {
- if (timer) {
- clearTimeout(timer);
- timer = void 0;
- lastRejector();
- lastRejector = noop;
- }
- };
- const filter2 = (_invoke) => {
- const duration2 = toValue(ms);
- const elapsed = Date.now() - lastExec;
- const invoke2 = () => {
- return lastValue = _invoke();
- };
- clear();
- if (duration2 <= 0) {
- lastExec = Date.now();
- return invoke2();
- }
- if (elapsed > duration2 && (leading || !isLeading)) {
- lastExec = Date.now();
- invoke2();
- } else if (trailing) {
- lastValue = new Promise((resolve2, reject) => {
- lastRejector = rejectOnCancel ? reject : resolve2;
- timer = setTimeout(() => {
- lastExec = Date.now();
- isLeading = true;
- resolve2(invoke2());
- clear();
- }, Math.max(0, duration2 - elapsed));
- });
- }
- if (!leading && !timer)
- timer = setTimeout(() => isLeading = true, duration2);
- isLeading = false;
- return lastValue;
- };
- return filter2;
-}
-function pausableFilter(extendFilter = bypassFilter) {
- const isActive = ref(true);
- function pause() {
- isActive.value = false;
- }
- function resume() {
- isActive.value = true;
- }
- const eventFilter = (...args) => {
- if (isActive.value)
- extendFilter(...args);
- };
- return { isActive: readonly(isActive), pause, resume, eventFilter };
-}
-function getLifeCycleTarget(target) {
- return getCurrentInstance();
-}
-function useDebounceFn(fn, ms = 200, options = {}) {
- return createFilterWrapper(
- debounceFilter(ms, options),
- fn
- );
-}
-function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
- return createFilterWrapper(
- throttleFilter(ms, trailing, leading, rejectOnCancel),
- fn
- );
-}
-function watchWithFilter(source, cb, options = {}) {
- const {
- eventFilter = bypassFilter,
- ...watchOptions
- } = options;
- return watch(
- source,
- createFilterWrapper(
- eventFilter,
- cb
- ),
- watchOptions
- );
-}
-function watchPausable(source, cb, options = {}) {
- const {
- eventFilter: filter2,
- ...watchOptions
- } = options;
- const { eventFilter, pause, resume, isActive } = pausableFilter(filter2);
- const stop = watchWithFilter(
- source,
- cb,
- {
- ...watchOptions,
- eventFilter
- }
- );
- return { stop, pause, resume, isActive };
-}
-function tryOnMounted(fn, sync = true, target) {
- const instance = getLifeCycleTarget();
- if (instance)
- onMounted(fn, target);
- else if (sync)
- fn();
- else
- nextTick(fn);
-}
-const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
-const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
-function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
- let m = hours < 12 ? "AM" : "PM";
- if (hasPeriod)
- m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
- return isLowercase ? m.toLowerCase() : m;
-}
-function formatOrdinal(num) {
- const suffixes = ["th", "st", "nd", "rd"];
- const v = num % 100;
- return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
-}
-function formatDate(date, formatStr, options = {}) {
- var _a;
- const years = date.getFullYear();
- const month = date.getMonth();
- const days = date.getDate();
- const hours = date.getHours();
- const minutes = date.getMinutes();
- const seconds = date.getSeconds();
- const milliseconds = date.getMilliseconds();
- const day = date.getDay();
- const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
- const matches2 = {
- Yo: () => formatOrdinal(years),
- YY: () => String(years).slice(-2),
- YYYY: () => years,
- M: () => month + 1,
- Mo: () => formatOrdinal(month + 1),
- MM: () => `${month + 1}`.padStart(2, "0"),
- MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }),
- MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }),
- D: () => String(days),
- Do: () => formatOrdinal(days),
- DD: () => `${days}`.padStart(2, "0"),
- H: () => String(hours),
- Ho: () => formatOrdinal(hours),
- HH: () => `${hours}`.padStart(2, "0"),
- h: () => `${hours % 12 || 12}`.padStart(1, "0"),
- ho: () => formatOrdinal(hours % 12 || 12),
- hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
- m: () => String(minutes),
- mo: () => formatOrdinal(minutes),
- mm: () => `${minutes}`.padStart(2, "0"),
- s: () => String(seconds),
- so: () => formatOrdinal(seconds),
- ss: () => `${seconds}`.padStart(2, "0"),
- SSS: () => `${milliseconds}`.padStart(3, "0"),
- d: () => day,
- dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }),
- ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }),
- dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }),
- A: () => meridiem(hours, minutes),
- AA: () => meridiem(hours, minutes, false, true),
- a: () => meridiem(hours, minutes, true),
- aa: () => meridiem(hours, minutes, true, true)
- };
- return formatStr.replace(REGEX_FORMAT, (match, $1) => {
- var _a2, _b;
- return (_b = $1 != null ? $1 : (_a2 = matches2[match]) == null ? void 0 : _a2.call(matches2)) != null ? _b : match;
- });
-}
-function normalizeDate(date) {
- if (date === null)
- return new Date(Number.NaN);
- if (date === void 0)
- return /* @__PURE__ */ new Date();
- if (date instanceof Date)
- return new Date(date);
- if (typeof date === "string" && !/Z$/i.test(date)) {
- const d = date.match(REGEX_PARSE);
- if (d) {
- const m = d[2] - 1 || 0;
- const ms = (d[7] || "0").substring(0, 3);
- return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
- }
- }
- return new Date(date);
-}
-function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
- return computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
-}
-const defaultWindow = isClient ? window : void 0;
-function unrefElement(elRef) {
- var _a;
- const plain = toValue(elRef);
- return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
-}
-function useEventListener(...args) {
- let target;
- let events2;
- let listeners;
- let options;
- if (typeof args[0] === "string" || Array.isArray(args[0])) {
- [events2, listeners, options] = args;
- target = defaultWindow;
- } else {
- [target, events2, listeners, options] = args;
- }
- if (!target)
- return noop;
- if (!Array.isArray(events2))
- events2 = [events2];
- if (!Array.isArray(listeners))
- listeners = [listeners];
- const cleanups = [];
- const cleanup = () => {
- cleanups.forEach((fn) => fn());
- cleanups.length = 0;
- };
- const register2 = (el, event, listener, options2) => {
- el.addEventListener(event, listener, options2);
- return () => el.removeEventListener(event, listener, options2);
- };
- const stopWatch = watch(
- () => [unrefElement(target), toValue(options)],
- ([el, options2]) => {
- cleanup();
- if (!el)
- return;
- const optionsClone = isObject(options2) ? { ...options2 } : options2;
- cleanups.push(
- ...events2.flatMap((event) => {
- return listeners.map((listener) => register2(el, event, listener, optionsClone));
- })
- );
- },
- { immediate: true, flush: "post" }
- );
- const stop = () => {
- stopWatch();
- cleanup();
- };
- tryOnScopeDispose(stop);
- return stop;
-}
-const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
-const globalKey = "__vueuse_ssr_handlers__";
-const handlers = /* @__PURE__ */ getHandlers();
-function getHandlers() {
- if (!(globalKey in _global))
- _global[globalKey] = _global[globalKey] || {};
- return _global[globalKey];
-}
-function getSSRHandler(key, fallback) {
- return handlers[key] || fallback;
-}
-function guessSerializerType(rawInit) {
- return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
-}
-const StorageSerializers = {
- boolean: {
- read: (v) => v === "true",
- write: (v) => String(v)
- },
- object: {
- read: (v) => JSON.parse(v),
- write: (v) => JSON.stringify(v)
- },
- number: {
- read: (v) => Number.parseFloat(v),
- write: (v) => String(v)
- },
- any: {
- read: (v) => v,
- write: (v) => String(v)
- },
- string: {
- read: (v) => v,
- write: (v) => String(v)
- },
- map: {
- read: (v) => new Map(JSON.parse(v)),
- write: (v) => JSON.stringify(Array.from(v.entries()))
- },
- set: {
- read: (v) => new Set(JSON.parse(v)),
- write: (v) => JSON.stringify(Array.from(v))
- },
- date: {
- read: (v) => new Date(v),
- write: (v) => v.toISOString()
- }
-};
-const customStorageEventName = "vueuse-storage";
-function useStorage(key, defaults2, storage, options = {}) {
- var _a;
- const {
- flush = "pre",
- deep = true,
- listenToStorageChanges = true,
- writeDefaults = true,
- mergeDefaults = false,
- shallow,
- window: window2 = defaultWindow,
- eventFilter,
- onError = (e) => {
- console.error(e);
- },
- initOnMounted
- } = options;
- const data = (shallow ? shallowRef : ref)(typeof defaults2 === "function" ? defaults2() : defaults2);
- if (!storage) {
- try {
- storage = getSSRHandler("getDefaultStorage", () => {
- var _a2;
- return (_a2 = defaultWindow) == null ? void 0 : _a2.localStorage;
- })();
- } catch (e) {
- onError(e);
- }
- }
- if (!storage)
- return data;
- const rawInit = toValue(defaults2);
- const type = guessSerializerType(rawInit);
- const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
- const { pause: pauseWatch, resume: resumeWatch } = watchPausable(
- data,
- () => write(data.value),
- { flush, deep, eventFilter }
- );
- if (window2 && listenToStorageChanges) {
- tryOnMounted(() => {
- if (storage instanceof Storage)
- useEventListener(window2, "storage", update3);
- else
- useEventListener(window2, customStorageEventName, updateFromCustomEvent);
- if (initOnMounted)
- update3();
- });
- }
- if (!initOnMounted)
- update3();
- function dispatchWriteEvent(oldValue, newValue) {
- if (window2) {
- const payload = {
- key,
- oldValue,
- newValue,
- storageArea: storage
- };
- window2.dispatchEvent(storage instanceof Storage ? new StorageEvent("storage", payload) : new CustomEvent(customStorageEventName, {
- detail: payload
- }));
- }
- }
- function write(v) {
- try {
- const oldValue = storage.getItem(key);
- if (v == null) {
- dispatchWriteEvent(oldValue, null);
- storage.removeItem(key);
- } else {
- const serialized = serializer.write(v);
- if (oldValue !== serialized) {
- storage.setItem(key, serialized);
- dispatchWriteEvent(oldValue, serialized);
- }
- }
- } catch (e) {
- onError(e);
- }
- }
- function read(event) {
- const rawValue = event ? event.newValue : storage.getItem(key);
- if (rawValue == null) {
- if (writeDefaults && rawInit != null)
- storage.setItem(key, serializer.write(rawInit));
- return rawInit;
- } else if (!event && mergeDefaults) {
- const value = serializer.read(rawValue);
- if (typeof mergeDefaults === "function")
- return mergeDefaults(value, rawInit);
- else if (type === "object" && !Array.isArray(value))
- return { ...rawInit, ...value };
- return value;
- } else if (typeof rawValue !== "string") {
- return rawValue;
- } else {
- return serializer.read(rawValue);
- }
- }
- function update3(event) {
- if (event && event.storageArea !== storage)
- return;
- if (event && event.key == null) {
- data.value = rawInit;
- return;
- }
- if (event && event.key !== key)
- return;
- pauseWatch();
- try {
- if ((event == null ? void 0 : event.newValue) !== serializer.write(data.value))
- data.value = read(event);
- } catch (e) {
- onError(e);
- } finally {
- if (event)
- nextTick(resumeWatch);
- else
- resumeWatch();
- }
- }
- function updateFromCustomEvent(event) {
- update3(event.detail);
- }
- return data;
-}
-function useLocalStorage(key, initialValue, options = {}) {
- const { window: window2 = defaultWindow } = options;
- return useStorage(key, initialValue, window2 == null ? void 0 : window2.localStorage, options);
-}
-const useMusicHistory = () => {
- const musicHistory2 = useLocalStorage("musicHistory", []);
- const addMusic = (music) => {
- const index = musicHistory2.value.findIndex((item) => item.id === music.id);
- if (index !== -1) {
- musicHistory2.value[index].count = (musicHistory2.value[index].count || 0) + 1;
- musicHistory2.value.unshift(musicHistory2.value.splice(index, 1)[0]);
- } else {
- musicHistory2.value.unshift({ ...music, count: 1 });
- }
- };
- const delMusic = (music) => {
- const index = musicHistory2.value.findIndex((item) => item.id === music.id);
- if (index !== -1) {
- musicHistory2.value.splice(index, 1);
- }
- };
- const musicList = ref(musicHistory2.value);
- watch(
- () => musicHistory2.value,
- () => {
- musicList.value = musicHistory2.value;
- }
- );
- return {
- musicHistory: musicHistory2,
- musicList,
- addMusic,
- delMusic
- };
-};
-class AudioService {
- currentSound = null;
- play(url) {
- if (this.currentSound) {
- this.currentSound.unload();
- }
- this.currentSound = null;
- this.currentSound = new howler.Howl({
- src: [url],
- html5: true,
- autoplay: true,
- volume: localStorage.getItem("volume") ? parseFloat(localStorage.getItem("volume")) : 1
- });
- return this.currentSound;
- }
- getCurrentSound() {
- return this.currentSound;
- }
- stop() {
- if (this.currentSound) {
- this.currentSound.stop();
- this.currentSound.unload();
- this.currentSound = null;
- }
- }
- // 监听播放
- onPlay(callback) {
- if (this.currentSound) {
- this.currentSound.on("play", callback);
- }
- }
- // 监听暂停
- onPause(callback) {
- if (this.currentSound) {
- this.currentSound.on("pause", callback);
- }
- }
- // 监听结束
- onEnd(callback) {
- if (this.currentSound) {
- this.currentSound.on("end", callback);
- }
- }
-}
-const audioService = new AudioService();
-const getImageLinearBackground = async (imageSrc) => {
- try {
- const primaryColor = await getImagePrimaryColor(imageSrc);
- return {
- backgroundColor: generateGradientBackground(primaryColor),
- primaryColor
- };
- } catch (error) {
- console.error("error", error);
- return {
- backgroundColor: "",
- primaryColor: ""
- };
- }
-};
-const getImageBackground = async (img) => {
- try {
- const primaryColor = await getImageColor(img);
- return {
- backgroundColor: generateGradientBackground(primaryColor),
- primaryColor
- };
- } catch (error) {
- console.error("error", error);
- return {
- backgroundColor: "",
- primaryColor: ""
- };
- }
-};
-const getImageColor = (img) => {
- return new Promise((resolve2, reject) => {
- const canvas = document.createElement("canvas");
- const ctx2 = canvas.getContext("2d");
- if (!ctx2) {
- reject(new Error("无法获取canvas上下文"));
- return;
- }
- canvas.width = img.width;
- canvas.height = img.height;
- ctx2.drawImage(img, 0, 0, canvas.width, canvas.height);
- const imageData = ctx2.getImageData(0, 0, canvas.width, canvas.height);
- const color = getAverageColor(imageData.data);
- resolve2(`rgb(${color.join(",")})`);
- });
-};
-const getImagePrimaryColor = (imageSrc) => {
- return new Promise((resolve2, reject) => {
- const img = new Image();
- img.crossOrigin = "Anonymous";
- img.src = imageSrc;
- img.onload = () => {
- const canvas = document.createElement("canvas");
- const ctx2 = canvas.getContext("2d");
- if (!ctx2) {
- reject(new Error("无法获取canvas上下文"));
- return;
- }
- canvas.width = img.width;
- canvas.height = img.height;
- ctx2.drawImage(img, 0, 0, canvas.width, canvas.height);
- const imageData = ctx2.getImageData(0, 0, canvas.width, canvas.height);
- const color = getAverageColor(imageData.data);
- resolve2(`rgb(${color.join(",")})`);
- };
- img.onerror = () => reject(new Error("图片加载失败"));
- });
-};
-const getAverageColor = (data) => {
- let r = 0;
- let g = 0;
- let b = 0;
- let count = 0;
- for (let i = 0; i < data.length; i += 4) {
- r += data[i];
- g += data[i + 1];
- b += data[i + 2];
- count++;
- }
- return [Math.round(r / count), Math.round(g / count), Math.round(b / count)];
-};
-const generateGradientBackground = (color) => {
- const [r, g, b] = color.match(/\d+/g)?.map(Number) || [0, 0, 0];
- const [h2, s, l] = rgbToHsl(r, g, b);
- const lightL = Math.min(l + 0.2, 0.95);
- const darkL = Math.max(l - 0.3, 0.05);
- const midL = (lightL + darkL) / 2;
- const lightS = Math.min(s * 0.8, 1);
- const darkS = Math.min(s * 1.2, 1);
- const [lightR, lightG, lightB] = hslToRgb(h2, lightS, lightL);
- const [midR, midG, midB] = hslToRgb(h2, s, midL);
- const [darkR, darkG, darkB] = hslToRgb(h2, darkS, darkL);
- const lightColor = `rgb(${lightR}, ${lightG}, ${lightB})`;
- const midColor = `rgb(${midR}, ${midG}, ${midB})`;
- const darkColor = `rgb(${darkR}, ${darkG}, ${darkB})`;
- return `linear-gradient(to bottom, ${lightColor} 0%, ${midColor} 50%, ${darkColor} 100%)`;
-};
-function rgbToHsl(r, g, b) {
- r /= 255;
- g /= 255;
- b /= 255;
- const max = Math.max(r, g, b);
- const min = Math.min(r, g, b);
- let h2 = 0;
- let s;
- const l = (max + min) / 2;
- if (max === min) {
- h2 = s = 0;
- } else {
- const d = max - min;
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
- switch (max) {
- case r:
- h2 = (g - b) / d + (g < b ? 6 : 0);
- break;
- case g:
- h2 = (b - r) / d + 2;
- break;
- case b:
- h2 = (r - g) / d + 4;
- break;
- }
- h2 /= 6;
- }
- return [h2, s, l];
-}
-function hslToRgb(h2, s, l) {
- let r;
- let g;
- let b;
- if (s === 0) {
- r = g = b = l;
- } else {
- const hue2rgb = (p22, q2, t) => {
- if (t < 0) t += 1;
- if (t > 1) t -= 1;
- if (t < 1 / 6) return p22 + (q2 - p22) * 6 * t;
- if (t < 1 / 2) return q2;
- if (t < 2 / 3) return p22 + (q2 - p22) * (2 / 3 - t) * 6;
- return p22;
- };
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
- const p2 = 2 * l - q;
- r = hue2rgb(p2, q, h2 + 1 / 3);
- g = hue2rgb(p2, q, h2);
- b = hue2rgb(p2, q, h2 - 1 / 3);
- }
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
-}
-const calculateBrightness = (r, g, b) => {
- return (0.299 * r + 0.587 * g + 0.114 * b) / 255;
-};
-const parseGradient = (gradientStr) => {
- const matches2 = gradientStr.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/g);
- if (!matches2) return [];
- return matches2.map((rgb) => {
- const [r, g, b] = rgb.match(/\d+/g).map(Number);
- return { r, g, b };
- });
-};
-const interpolateRGB = (start, end, progress) => {
- return Math.round(start + (end - start) * progress);
-};
-const createGradientString = (colors2, percentages = [0, 50, 100]) => {
- return `linear-gradient(to bottom, ${colors2.map((color, i) => `rgb(${color.r}, ${color.g}, ${color.b}) ${percentages[i]}%`).join(", ")})`;
-};
-const getTextColors = (gradient = "") => {
- const defaultColors = {
- primary: "rgba(255, 255, 255, 0.54)",
- active: "#ffffff",
- theme: "light"
- };
- if (!gradient) return defaultColors;
- const colors2 = parseGradient(gradient);
- if (!colors2.length) return defaultColors;
- const mainColor = colors2[1] || colors2[0];
- const brightness = calculateBrightness(mainColor.r, mainColor.g, mainColor.b);
- const isDark = brightness > 0.6;
- return {
- primary: isDark ? "rgba(0, 0, 0, 0.54)" : "rgba(255, 255, 255, 0.54)",
- active: isDark ? "#000000" : "#ffffff",
- theme: isDark ? "dark" : "light"
- };
-};
-const getHoverBackgroundColor = (isDark) => {
- return isDark ? "rgba(0, 0, 0, 0.08)" : "rgba(255, 255, 255, 0.08)";
-};
-const animateGradient = (oldGradient, newGradient, onUpdate, duration2 = 1e3) => {
- const startColors = parseGradient(oldGradient);
- const endColors = parseGradient(newGradient);
- if (startColors.length !== endColors.length) return null;
- const startTime = performance.now();
- const animate = (currentTime) => {
- const elapsed = currentTime - startTime;
- const progress = Math.min(elapsed / duration2, 1);
- const currentColors = startColors.map((startColor, i) => ({
- r: interpolateRGB(startColor.r, endColors[i].r, progress),
- g: interpolateRGB(startColor.g, endColors[i].g, progress),
- b: interpolateRGB(startColor.b, endColors[i].b, progress)
- }));
- onUpdate(createGradientString(currentColors));
- if (progress < 1) {
- return requestAnimationFrame(animate);
- }
- return null;
- };
- return requestAnimationFrame(animate);
-};
-const musicHistory = useMusicHistory();
-const getSongUrl = async (id) => {
- const { data } = await getMusicUrl(id);
- let url = "";
- try {
- if (data.data[0].freeTrialInfo || !data.data[0].url) {
- const res = await getParsingMusicUrl(id);
- console.log("res", res);
- url = res.data.data.url;
- }
- } catch (error) {
- console.error("error", error);
- }
- url = url || data.data[0].url;
- return getMusicProxyUrl(url);
-};
-const getSongDetail = async (playMusic) => {
- playMusic.playLoading = true;
- const playMusicUrl = await getSongUrl(playMusic.id);
- const { backgroundColor, primaryColor } = playMusic.backgroundColor && playMusic.primaryColor ? playMusic : await getImageLinearBackground(getImgUrl(playMusic?.picUrl, "30y30"));
- playMusic.playLoading = false;
- return { ...playMusic, playMusicUrl, backgroundColor, primaryColor };
-};
-const useMusicListHook = () => {
- const handlePlayMusic2 = async (state2, playMusic) => {
- const updatedPlayMusic = await getSongDetail(playMusic);
- state2.playMusic = updatedPlayMusic;
- state2.playMusicUrl = updatedPlayMusic.playMusicUrl;
- state2.play = true;
- document.title = `${updatedPlayMusic.name} - ${updatedPlayMusic?.song?.artists?.reduce((prev, curr) => `${prev}${curr.name}/`, "")}`;
- loadLrcAsync(state2, updatedPlayMusic.id);
- musicHistory.addMusic(state2.playMusic);
- const playListIndex = state2.playList.findIndex((item) => item.id === playMusic.id);
- state2.playListIndex = playListIndex;
- fetchSongs(state2, playListIndex + 1, playListIndex + 6);
- };
- const preloadNextSong = (nextSongUrl) => {
- const sound = new howler.Howl({
- src: [nextSongUrl],
- html5: true,
- preload: true,
- autoplay: false
- });
- return sound;
- };
- const fetchSongs = async (state2, startIndex, endIndex) => {
- const songs = state2.playList.slice(
- Math.max(0, startIndex),
- Math.min(endIndex, state2.playList.length)
- );
- const detailedSongs = await Promise.all(
- songs.map(async (song) => {
- if (!song.playMusicUrl) {
- return await getSongDetail(song);
- }
- return song;
- })
- );
- const nextSong = detailedSongs[0];
- if (!(nextSong.lyric && nextSong.lyric.lrcTimeArray.length > 0)) {
- nextSong.lyric = await loadLrc(nextSong.id);
- }
- detailedSongs.forEach((song, index) => {
- state2.playList[startIndex + index] = song;
- });
- preloadNextSong(nextSong.playMusicUrl);
- };
- const nextPlay2 = async (state2) => {
- if (state2.playList.length === 0) {
- state2.play = true;
- return;
- }
- const playListIndex = (state2.playListIndex + 1) % state2.playList.length;
- await handlePlayMusic2(state2, state2.playList[playListIndex]);
- };
- const prevPlay2 = async (state2) => {
- if (state2.playList.length === 0) {
- state2.play = true;
- return;
- }
- const playListIndex = (state2.playListIndex - 1 + state2.playList.length) % state2.playList.length;
- await handlePlayMusic2(state2, state2.playList[playListIndex]);
- await fetchSongs(state2, playListIndex - 5, playListIndex);
- };
- const parseTime = (timeString) => {
- const [minutes, seconds] = timeString.split(":");
- return Number(minutes) * 60 + Number(seconds);
- };
- const parseLyricLine = (lyricLine) => {
- const TIME_REGEX = /(\d{2}:\d{2}(\.\d*)?)/g;
- const LRC_REGEX = /(\[(\d{2}):(\d{2})(\.(\d*))?\])/g;
- const timeText = lyricLine.match(TIME_REGEX)?.[0] || "";
- const time2 = parseTime(timeText);
- const text = lyricLine.replace(LRC_REGEX, "").trim();
- return { time: time2, text };
- };
- const parseLyrics = (lyricsString) => {
- const lines = lyricsString.split("\n");
- const lyrics = [];
- const times = [];
- lines.forEach((line) => {
- const { time: time2, text } = parseLyricLine(line);
- times.push(time2);
- lyrics.push({ text, trText: "" });
- });
- return { lyrics, times };
- };
- const loadLrc = async (playMusicId) => {
- try {
- const { data } = await getMusicLrc(playMusicId);
- const { lyrics, times } = parseLyrics(data.lrc.lyric);
- const tlyric = {};
- if (data.tlyric.lyric) {
- const { lyrics: tLyrics, times: tTimes } = parseLyrics(data.tlyric.lyric);
- tLyrics.forEach((lyric, index) => {
- tlyric[tTimes[index].toString()] = lyric.text;
- });
- }
- lyrics.forEach((item, index) => {
- item.trText = item.text ? tlyric[times[index].toString()] || "" : "";
- });
- return {
- lrcTimeArray: times,
- lrcArray: lyrics
- };
- } catch (err) {
- console.error("Error loading lyrics:", err);
- return {
- lrcTimeArray: [],
- lrcArray: []
- };
- }
- };
- const loadLrcAsync = async (state2, playMusicId) => {
- if (state2.playMusic.lyric && state2.playMusic.lyric.lrcTimeArray.length > 0) {
- return;
- }
- const lyrics = await loadLrc(playMusicId);
- state2.playMusic.lyric = lyrics;
- };
- const play = () => {
- audioService.getCurrentSound()?.play();
- };
- const pause = () => {
- audioService.getCurrentSound()?.pause();
- };
- return {
- handlePlayMusic: handlePlayMusic2,
- nextPlay: nextPlay2,
- prevPlay: prevPlay2,
- play,
- pause
- };
-};
-const layoutRouter = [
- {
- path: "/",
- name: "home",
- meta: {
- title: "首页",
- icon: "icon-Home",
- keepAlive: true,
- isMobile: true
- },
- component: () => __vitePreload(() => import("./index-DSilVM87.js"), true ? __vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]) : void 0, import.meta.url)
- },
- {
- path: "/search",
- name: "search",
- meta: {
- title: "搜索",
- noScroll: true,
- icon: "icon-Search",
- keepAlive: true,
- isMobile: true
- },
- component: () => __vitePreload(() => import("./index-C-VCusx9.js"), true ? __vite__mapDeps([15,1,3,4,5,6,7,2,8,9,10,11,16,17,18,19,20,21]) : void 0, import.meta.url)
- },
- {
- path: "/list",
- name: "list",
- meta: {
- title: "歌单",
- icon: "icon-Paper",
- keepAlive: true,
- isMobile: true
- },
- component: () => __vitePreload(() => import("./index-Bc5fdT5j.js"), true ? __vite__mapDeps([22,1,2,3,4,5,6,7,8,9,10,11,23]) : void 0, import.meta.url)
- },
- {
- path: "/mv",
- name: "mv",
- meta: {
- title: "MV",
- icon: "icon-recordfill",
- keepAlive: true,
- isMobile: true
- },
- component: () => __vitePreload(() => import("./index-SvIREzLs.js"), true ? __vite__mapDeps([24,16,17,4,5,18,8,6,19,25]) : void 0, import.meta.url)
- },
- // {
- // path: '/history',
- // name: 'history',
- // meta: {
- // title: '历史',
- // icon: 'icon-a-TicketStar',
- // keepAlive: true,
- // },
- // component: () => import('@/views/history/index.vue'),
- // },
- {
- path: "/history",
- name: "history",
- component: () => __vitePreload(() => import("./index-DhLgZEXT.js"), true ? __vite__mapDeps([26,12,3,4,5,6,7,13,27]) : void 0, import.meta.url),
- meta: {
- title: "收藏历史",
- icon: "icon-a-TicketStar",
- keepAlive: true
- }
- },
- {
- path: "/user",
- name: "user",
- meta: {
- title: "用户",
- icon: "icon-Profile",
- keepAlive: true,
- noScroll: true,
- isMobile: true
- },
- component: () => __vitePreload(() => import("./index-BPmJoRDi.js"), true ? __vite__mapDeps([28,2,3,4,5,6,7,8,9,10,11,29]) : void 0, import.meta.url)
- },
- {
- path: "/set",
- name: "set",
- meta: {
- title: "设置",
- icon: "ri-settings-3-fill",
- keepAlive: true,
- noScroll: true
- },
- component: () => __vitePreload(() => import("./index-RCxsGzpS.js"), true ? __vite__mapDeps([30,31,5,10,18,32]) : void 0, import.meta.url)
- }
-];
-const applyTheme = (theme) => {
- if (theme === "dark") {
- document.documentElement.classList.add("dark");
- } else {
- document.documentElement.classList.remove("dark");
- }
- localStorage.setItem("theme", theme);
-};
-const getCurrentTheme = () => {
- return localStorage.getItem("theme") || "light";
-};
-const defaultSettings = {
- isProxy: false,
- noAnimate: false,
- animationSpeed: 1,
- author: "Alger",
- authorUrl: "https://github.com/algerkong"
-};
-function getLocalStorageItem(key, defaultValue) {
- const item = localStorage.getItem(key);
- return item ? JSON.parse(item) : defaultValue;
-}
-const state = {
- menus: layoutRouter,
- play: false,
- isPlay: false,
- playMusic: {},
- playMusicUrl: "",
- user: getLocalStorageItem("user", null),
- playList: [],
- playListIndex: 0,
- setData: defaultSettings,
- lyric: {},
- isMobile: false,
- searchValue: "",
- searchType: 1,
- favoriteList: getLocalStorageItem("favoriteList", []),
- playMode: getLocalStorageItem("playMode", 0),
- theme: getCurrentTheme()
-};
-const { handlePlayMusic, nextPlay, prevPlay } = useMusicListHook();
-const mutations = {
- setMenus(state2, menus) {
- state2.menus = menus;
- },
- async setPlay(state2, playMusic) {
- await handlePlayMusic(state2, playMusic);
- },
- setIsPlay(state2, isPlay) {
- state2.isPlay = isPlay;
- },
- setPlayMusic(state2, play) {
- state2.play = play;
- },
- setPlayList(state2, playList) {
- state2.playListIndex = playList.findIndex((item) => item.id === state2.playMusic.id);
- state2.playList = playList;
- },
- async nextPlay(state2) {
- await nextPlay(state2);
- },
- async prevPlay(state2) {
- await prevPlay(state2);
- },
- setSetData(state2, setData2) {
- state2.setData = setData2;
- if (isElectron) {
- window.electron.ipcRenderer.send("set-store-value", "set", JSON.parse(JSON.stringify(setData2)));
- } else {
- localStorage.setItem("appSettings", JSON.stringify(setData2));
- }
- },
- addToFavorite(state2, songId) {
- if (!state2.favoriteList.includes(songId)) {
- state2.favoriteList = [songId, ...state2.favoriteList];
- localStorage.setItem("favoriteList", JSON.stringify(state2.favoriteList));
- }
- },
- removeFromFavorite(state2, songId) {
- state2.favoriteList = state2.favoriteList.filter((id) => id !== songId);
- localStorage.setItem("favoriteList", JSON.stringify(state2.favoriteList));
- },
- togglePlayMode(state2) {
- state2.playMode = (state2.playMode + 1) % 3;
- localStorage.setItem("playMode", JSON.stringify(state2.playMode));
- },
- toggleTheme(state2) {
- state2.theme = state2.theme === "dark" ? "light" : "dark";
- applyTheme(state2.theme);
- }
-};
-const actions = {
- initializeSettings({ commit: commit2 }) {
- if (isElectron) {
- const setData2 = window.electron.ipcRenderer.sendSync("get-store-value", "set");
- commit2("setSetData", setData2 || defaultSettings);
- } else {
- const savedSettings = localStorage.getItem("appSettings");
- if (savedSettings) {
- commit2("setSetData", {
- ...defaultSettings,
- ...JSON.parse(savedSettings)
- });
- } else {
- commit2("setSetData", defaultSettings);
- }
- }
- },
- initializeTheme({ state: state2 }) {
- applyTheme(state2.theme);
- }
-};
-const store = createStore({
- state,
- mutations,
- actions
-});
-const setBackgroundImg = (url) => {
- return `background-image:url(${url})`;
-};
-const setAnimationClass = (type) => {
- if (store.state.setData && store.state.setData.noAnimate) {
- return "";
- }
- const speed = store.state.setData?.animationSpeed || 1;
- let speedClass = "";
- if (speed <= 0.3) speedClass = "animate__slower";
- else if (speed <= 0.8) speedClass = "animate__slow";
- else if (speed >= 2.5) speedClass = "animate__faster";
- else if (speed >= 1.5) speedClass = "animate__fast";
- return `animate__animated ${type}${speedClass ? ` ${speedClass}` : ""}`;
-};
-const setAnimationDelay = (index = 6, time2 = 50) => {
- const speed = store.state.setData?.animationSpeed || 1;
- return `animation-delay:${index * time2 / (speed * 2)}ms`;
-};
-const secondToMinute = (s) => {
- if (!s) {
- return "00:00";
- }
- const minute = Math.floor(s / 60);
- const second = Math.floor(s % 60);
- const minuteStr = minute > 9 ? minute.toString() : `0${minute.toString()}`;
- const secondStr = second > 9 ? second.toString() : `0${second.toString()}`;
- return `${minuteStr}:${secondStr}`;
-};
-const units = [
- { value: 1e8, symbol: "亿" },
- { value: 1e4, symbol: "万" }
-];
-const formatNumber = (num) => {
- num = Number(num);
- for (let i = 0; i < units.length; i++) {
- if (num >= units[i].value) {
- return `${(num / units[i].value).toFixed(1)}${units[i].symbol}`;
- }
- }
- return num.toString();
-};
-const windowData = window;
-const getIsMc = () => {
- if (!windowData.electron) {
- return false;
- }
- const setData2 = window.electron.ipcRenderer.sendSync("get-store-value", "set");
- if (setData2.isProxy) {
- return true;
- }
- return false;
-};
-const ProxyUrl = "http://110.42.251.190:9898";
-const getMusicProxyUrl = (url) => {
- if (!getIsMc()) {
- return url;
- }
- const PUrl = url.split("").join("+");
- return `${ProxyUrl}/mc?url=${PUrl}`;
-};
-const getImgUrl = (url, size2 = "") => {
- const bdUrl = "https://image.baidu.com/search/down?url=";
- const imgUrl = `${url}?param=${size2}`;
- if (!getIsMc()) {
- return imgUrl;
- }
- return `${bdUrl}${encodeURIComponent(imgUrl)}`;
-};
-const isMobile = computed(() => {
- const flag = navigator.userAgent.match(
- /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
- );
- store.state.isMobile = !!flag;
- if (flag) document.documentElement.classList.add("mobile");
- return !!flag;
-});
-const isElectron = window.electron !== void 0;
-const checkUpdate = async () => {
- try {
- const response = await axios.get("https://api.github.com/repos/algerkong/AlgerMusicPlayer/releases/latest");
- const latestVersion = response.data.tag_name.replace("v", "");
- const currentVersion = config.version;
- console.log(latestVersion, currentVersion);
- const latest = latestVersion.split(".").map(Number);
- const current = currentVersion.split(".").map(Number);
- let hasUpdate = false;
- for (let i = 0; i < 3; i++) {
- if (latest[i] > current[i]) {
- hasUpdate = true;
- break;
- } else if (latest[i] < current[i]) {
- break;
- }
- }
- return {
- hasUpdate,
- latestVersion,
- currentVersion,
- releaseInfo: response.data
- };
- } catch (error) {
- console.error("检查更新失败:", error);
- return {
- hasUpdate: false,
- latestVersion: "",
- currentVersion: config.version,
- releaseInfo: null
- };
- }
-};
-const _hoisted_1$3 = { class: "modal-content" };
-const _hoisted_2$3 = { class: "modal-header" };
-const _hoisted_3$2 = { class: "app-info" };
-const _hoisted_4$2 = { class: "app-name" };
-const _hoisted_5$1 = { class: "modal-actions" };
-const _sfc_main$5 = /* @__PURE__ */ defineComponent({
- __name: "InstallAppModal",
- setup(__props) {
- const showModal = ref(false);
- const noPrompt = ref(false);
- const closeModal = () => {
- showModal.value = false;
- if (noPrompt.value) {
- localStorage.setItem("installPromptDismissed", "true");
- }
- };
- onMounted(() => {
- if (isElectron || isMobile.value) {
- return;
- }
- const isDismissed = localStorage.getItem("installPromptDismissed") === "true";
- if (isDismissed) {
- return;
- }
- showModal.value = true;
- });
- const handleInstall = async () => {
- const { userAgent } = navigator;
- console.log("userAgent", userAgent);
- const isMac = userAgent.includes("Mac");
- const isWindows = userAgent.includes("Win");
- const isARM = userAgent.includes("ARM") || userAgent.includes("arm") || userAgent.includes("OS X");
- const isX64 = userAgent.includes("x86_64") || userAgent.includes("Win64") || userAgent.includes("WOW64");
- const isX86 = !isX64 && (userAgent.includes("i686") || userAgent.includes("i386") || userAgent.includes("Win32"));
- const getDownloadUrl = (os, arch) => {
- const version2 = config.version;
- const setup = os !== "mac" ? "Setup_" : "";
- return `https://gh.llkk.cc/https://github.com/algerkong/AlgerMusicPlayer/releases/download/${version2}/AlgerMusic_${version2}_${setup}${arch}.${os === "mac" ? "dmg" : "exe"}`;
- };
- const osType = isMac ? "mac" : isWindows ? "windows" : null;
- const archType = isARM ? "arm64" : isX64 ? "x64" : isX86 ? "x86" : null;
- const downloadUrl = osType && archType ? getDownloadUrl(osType, archType) : null;
- window.open(downloadUrl || "https://github.com/algerkong/AlgerMusicPlayer/releases", "_blank");
- };
- return (_ctx, _cache) => {
- const _component_n_checkbox = __unplugin_components_0$2;
- const _component_n_button = Button;
- const _component_n_modal = __unplugin_components_3;
- return openBlock(), createBlock(_component_n_modal, {
- show: showModal.value,
- "onUpdate:show": _cache[1] || (_cache[1] = ($event) => showModal.value = $event),
- preset: "dialog",
- "show-icon": false,
- "mask-closable": true,
- class: "install-app-modal"
- }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_1$3, [
- createBaseVNode("div", _hoisted_2$3, [
- _cache[4] || (_cache[4] = createBaseVNode("div", { class: "app-icon" }, [
- createBaseVNode("img", {
- src: _imports_0,
- alt: "App Icon"
- })
- ], -1)),
- createBaseVNode("div", _hoisted_3$2, [
- createBaseVNode("h2", _hoisted_4$2, "Alger Music Player " + toDisplayString(unref(config).version), 1),
- _cache[3] || (_cache[3] = createBaseVNode("p", { class: "app-desc mb-2" }, "在桌面安装应用,获得更好的体验", -1)),
- createVNode(_component_n_checkbox, {
- checked: noPrompt.value,
- "onUpdate:checked": _cache[0] || (_cache[0] = ($event) => noPrompt.value = $event)
- }, {
- default: withCtx(() => _cache[2] || (_cache[2] = [
- createTextVNode("不再提示")
- ])),
- _: 1
- }, 8, ["checked"])
- ])
- ]),
- createBaseVNode("div", _hoisted_5$1, [
- createVNode(_component_n_button, {
- class: "cancel-btn",
- onClick: closeModal
- }, {
- default: withCtx(() => _cache[5] || (_cache[5] = [
- createTextVNode("暂不安装")
- ])),
- _: 1
- }),
- createVNode(_component_n_button, {
- type: "primary",
- class: "install-btn",
- onClick: handleInstall
- }, {
- default: withCtx(() => _cache[6] || (_cache[6] = [
- createTextVNode("立即安装")
- ])),
- _: 1
- })
- ]),
- _cache[7] || (_cache[7] = createBaseVNode("div", { class: "modal-desc mt-4 text-center" }, [
- createBaseVNode("p", { class: "text-xs text-gray-400" }, [
- createTextVNode(" 下载遇到问题?去 "),
- createBaseVNode("a", {
- class: "text-green-500",
- target: "_blank",
- href: "https://github.com/algerkong/AlgerMusicPlayer/releases"
- }, "GitHub"),
- createTextVNode(" 下载最新版本 ")
- ])
- ], -1))
- ])
- ]),
- _: 1
- }, 8, ["show"]);
- };
- }
-});
-const _export_sfc = (sfc, props) => {
- const target = sfc.__vccOpts || sfc;
- for (const [key, val] of props) {
- target[key] = val;
- }
- return target;
-};
-const InstallAppModal = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-40e226b5"]]);
-const _sfc_main$4 = /* @__PURE__ */ defineComponent({
- __name: "PlayBottom",
- props: {
- height: {
- type: String,
- default: void 0
- }
- },
- setup(__props) {
- const store2 = useStore();
- const isPlay = computed(() => store2.state.isPlay);
- return (_ctx, _cache) => {
- return unref(isPlay) ? (openBlock(), createElementBlock("div", {
- key: 0,
- class: "bottom",
- style: normalizeStyle({ height: __props.height })
- }, null, 4)) : createCommentVNode("", true);
- };
- }
-});
-const PlayBottom = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-7497922f"]]);
-function _getDefaults() {
- return {
- async: false,
- breaks: false,
- extensions: null,
- gfm: true,
- hooks: null,
- pedantic: false,
- renderer: null,
- silent: false,
- tokenizer: null,
- walkTokens: null
- };
-}
-let _defaults = _getDefaults();
-function changeDefaults(newDefaults) {
- _defaults = newDefaults;
-}
-const noopTest = { exec: () => null };
-function edit(regex, opt = "") {
- let source = typeof regex === "string" ? regex : regex.source;
- const obj = {
- replace: (name2, val) => {
- let valSource = typeof val === "string" ? val : val.source;
- valSource = valSource.replace(other.caret, "$1");
- source = source.replace(name2, valSource);
- return obj;
- },
- getRegex: () => {
- return new RegExp(source, opt);
- }
- };
- return obj;
-}
-const other = {
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
- outputLinkReplace: /\\([\[\]])/g,
- indentCodeCompensation: /^(\s+)(?:```)/,
- beginningSpace: /^\s+/,
- endingHash: /#$/,
- startingSpaceChar: /^ /,
- endingSpaceChar: / $/,
- nonSpaceChar: /[^ ]/,
- newLineCharGlobal: /\n/g,
- tabCharGlobal: /\t/g,
- multipleSpaceGlobal: /\s+/g,
- blankLine: /^[ \t]*$/,
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
- blockquoteStart: /^ {0,3}>/,
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
- listReplaceTabs: /^\t+/,
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
- listIsTask: /^\[[ xX]\] /,
- listReplaceTask: /^\[[ xX]\] +/,
- anyLine: /\n.*\n/,
- hrefBrackets: /^<(.*)>$/,
- tableDelimiter: /[:|]/,
- tableAlignChars: /^\||\| *$/g,
- tableRowBlankLine: /\n[ \t]*$/,
- tableAlignRight: /^ *-+: *$/,
- tableAlignCenter: /^ *:-+: *$/,
- tableAlignLeft: /^ *:-+ *$/,
- startATag: /^/i,
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
- startAngleBracket: /^,
- endAngleBracket: />$/,
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
- escapeTest: /[&<>"']/,
- escapeReplace: /[&<>"']/g,
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
- caret: /(^|[^\[])\^/g,
- percentDecode: /%25/g,
- findPipe: /\|/g,
- splitPipe: / \|/,
- slashPipe: /\\\|/g,
- carriageReturn: /\r\n|\r/g,
- spaceLine: /^ +$/gm,
- notSpaceStart: /^\S*/,
- endingNewline: /\n$/,
- listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
- nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
- hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
- fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
- headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
- htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
-};
-const newline = /^(?:[ \t]*(?:\n|$))+/;
-const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
-const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
-const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
-const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
-const bullet = /(?:[*+-]|\d{1,9}[.)])/;
-const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
-const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
-const blockText = /^[^\n]+/;
-const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
-const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
-const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
-const _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
-const _comment = /|$))/;
-const html = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
-const paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
-const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
-const blockNormal = {
- blockquote,
- code: blockCode,
- def,
- fences,
- heading,
- hr,
- html,
- lheading,
- list,
- newline,
- paragraph,
- table: noopTest,
- text: blockText
-};
-const gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
-const blockGfm = {
- ...blockNormal,
- table: gfmTable,
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
-};
-const blockPedantic = {
- ...blockNormal,
- html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
- def: /^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
- fences: noopTest,
- // fences not supported
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
-};
-const escape$1 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
-const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
-const br = /^( {2,}|\\)\n(?!\s*$)/;
-const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\]*?>/g;
-const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
-const emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
-const emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
-const anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
-const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
-const _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
-const tag = edit("^comment|^[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
-const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
-const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
-const reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
-const nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
-const reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
-const inlineNormal = {
- _backpedal: noopTest,
- // only used for GFM url
- anyPunctuation,
- autolink,
- blockSkip,
- br,
- code: inlineCode,
- del: noopTest,
- emStrongLDelim,
- emStrongRDelimAst,
- emStrongRDelimUnd,
- escape: escape$1,
- link,
- nolink,
- punctuation,
- reflink,
- reflinkSearch,
- tag,
- text: inlineText,
- url: noopTest
-};
-const inlinePedantic = {
- ...inlineNormal,
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
-};
-const inlineGfm = {
- ...inlineNormal,
- escape: edit(escape$1).replace("])", "~|])").getRegex(),
- url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\": ">",
- '"': """,
- "'": "'"
-};
-const getEscapeReplacement = (ch) => escapeReplacements[ch];
-function escape(html2, encode2) {
- if (encode2) {
- if (other.escapeTest.test(html2)) {
- return html2.replace(other.escapeReplace, getEscapeReplacement);
- }
- } else {
- if (other.escapeTestNoEncode.test(html2)) {
- return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
- }
- }
- return html2;
-}
-function cleanUrl(href) {
- try {
- href = encodeURI(href).replace(other.percentDecode, "%");
- } catch {
- return null;
- }
- return href;
-}
-function splitCells(tableRow, count) {
- const row = tableRow.replace(other.findPipe, (match, offset, str) => {
- let escaped = false;
- let curr = offset;
- while (--curr >= 0 && str[curr] === "\\")
- escaped = !escaped;
- if (escaped) {
- return "|";
- } else {
- return " |";
- }
- }), cells = row.split(other.splitPipe);
- let i = 0;
- if (!cells[0].trim()) {
- cells.shift();
- }
- if (cells.length > 0 && !cells.at(-1)?.trim()) {
- cells.pop();
- }
- if (count) {
- if (cells.length > count) {
- cells.splice(count);
- } else {
- while (cells.length < count)
- cells.push("");
- }
- }
- for (; i < cells.length; i++) {
- cells[i] = cells[i].trim().replace(other.slashPipe, "|");
- }
- return cells;
-}
-function rtrim(str, c2, invert) {
- const l = str.length;
- if (l === 0) {
- return "";
- }
- let suffLen = 0;
- while (suffLen < l) {
- const currChar = str.charAt(l - suffLen - 1);
- if (currChar === c2 && !invert) {
- suffLen++;
- } else {
- break;
- }
- }
- return str.slice(0, l - suffLen);
-}
-function findClosingBracket(str, b) {
- if (str.indexOf(b[1]) === -1) {
- return -1;
- }
- let level = 0;
- for (let i = 0; i < str.length; i++) {
- if (str[i] === "\\") {
- i++;
- } else if (str[i] === b[0]) {
- level++;
- } else if (str[i] === b[1]) {
- level--;
- if (level < 0) {
- return i;
- }
- }
- }
- return -1;
-}
-function outputLink(cap, link2, raw, lexer, rules) {
- const href = link2.href;
- const title = link2.title || null;
- const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
- if (cap[0].charAt(0) !== "!") {
- lexer.state.inLink = true;
- const token = {
- type: "link",
- raw,
- href,
- title,
- text,
- tokens: lexer.inlineTokens(text)
- };
- lexer.state.inLink = false;
- return token;
- }
- return {
- type: "image",
- raw,
- href,
- title,
- text
- };
-}
-function indentCodeCompensation(raw, text, rules) {
- const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
- if (matchIndentToCode === null) {
- return text;
- }
- const indentToCode = matchIndentToCode[1];
- return text.split("\n").map((node) => {
- const matchIndentInNode = node.match(rules.other.beginningSpace);
- if (matchIndentInNode === null) {
- return node;
- }
- const [indentInNode] = matchIndentInNode;
- if (indentInNode.length >= indentToCode.length) {
- return node.slice(indentToCode.length);
- }
- return node;
- }).join("\n");
-}
-class _Tokenizer {
- options;
- rules;
- // set by the lexer
- lexer;
- // set by the lexer
- constructor(options) {
- this.options = options || _defaults;
- }
- space(src) {
- const cap = this.rules.block.newline.exec(src);
- if (cap && cap[0].length > 0) {
- return {
- type: "space",
- raw: cap[0]
- };
- }
- }
- code(src) {
- const cap = this.rules.block.code.exec(src);
- if (cap) {
- const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
- return {
- type: "code",
- raw: cap[0],
- codeBlockStyle: "indented",
- text: !this.options.pedantic ? rtrim(text, "\n") : text
- };
- }
- }
- fences(src) {
- const cap = this.rules.block.fences.exec(src);
- if (cap) {
- const raw = cap[0];
- const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
- return {
- type: "code",
- raw,
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
- text
- };
- }
- }
- heading(src) {
- const cap = this.rules.block.heading.exec(src);
- if (cap) {
- let text = cap[2].trim();
- if (this.rules.other.endingHash.test(text)) {
- const trimmed = rtrim(text, "#");
- if (this.options.pedantic) {
- text = trimmed.trim();
- } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
- text = trimmed.trim();
- }
- }
- return {
- type: "heading",
- raw: cap[0],
- depth: cap[1].length,
- text,
- tokens: this.lexer.inline(text)
- };
- }
- }
- hr(src) {
- const cap = this.rules.block.hr.exec(src);
- if (cap) {
- return {
- type: "hr",
- raw: rtrim(cap[0], "\n")
- };
- }
- }
- blockquote(src) {
- const cap = this.rules.block.blockquote.exec(src);
- if (cap) {
- let lines = rtrim(cap[0], "\n").split("\n");
- let raw = "";
- let text = "";
- const tokens = [];
- while (lines.length > 0) {
- let inBlockquote = false;
- const currentLines = [];
- let i;
- for (i = 0; i < lines.length; i++) {
- if (this.rules.other.blockquoteStart.test(lines[i])) {
- currentLines.push(lines[i]);
- inBlockquote = true;
- } else if (!inBlockquote) {
- currentLines.push(lines[i]);
- } else {
- break;
- }
- }
- lines = lines.slice(i);
- const currentRaw = currentLines.join("\n");
- const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
- raw = raw ? `${raw}
-${currentRaw}` : currentRaw;
- text = text ? `${text}
-${currentText}` : currentText;
- const top = this.lexer.state.top;
- this.lexer.state.top = true;
- this.lexer.blockTokens(currentText, tokens, true);
- this.lexer.state.top = top;
- if (lines.length === 0) {
- break;
- }
- const lastToken = tokens.at(-1);
- if (lastToken?.type === "code") {
- break;
- } else if (lastToken?.type === "blockquote") {
- const oldToken = lastToken;
- const newText = oldToken.raw + "\n" + lines.join("\n");
- const newToken = this.blockquote(newText);
- tokens[tokens.length - 1] = newToken;
- raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
- text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
- break;
- } else if (lastToken?.type === "list") {
- const oldToken = lastToken;
- const newText = oldToken.raw + "\n" + lines.join("\n");
- const newToken = this.list(newText);
- tokens[tokens.length - 1] = newToken;
- raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
- text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
- lines = newText.substring(tokens.at(-1).raw.length).split("\n");
- continue;
- }
- }
- return {
- type: "blockquote",
- raw,
- tokens,
- text
- };
- }
- }
- list(src) {
- let cap = this.rules.block.list.exec(src);
- if (cap) {
- let bull = cap[1].trim();
- const isordered = bull.length > 1;
- const list2 = {
- type: "list",
- raw: "",
- ordered: isordered,
- start: isordered ? +bull.slice(0, -1) : "",
- loose: false,
- items: []
- };
- bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
- if (this.options.pedantic) {
- bull = isordered ? bull : "[*+-]";
- }
- const itemRegex = this.rules.other.listItemRegex(bull);
- let endsWithBlankLine = false;
- while (src) {
- let endEarly = false;
- let raw = "";
- let itemContents = "";
- if (!(cap = itemRegex.exec(src))) {
- break;
- }
- if (this.rules.block.hr.test(src)) {
- break;
- }
- raw = cap[0];
- src = src.substring(raw.length);
- let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
- let nextLine = src.split("\n", 1)[0];
- let blankLine = !line.trim();
- let indent = 0;
- if (this.options.pedantic) {
- indent = 2;
- itemContents = line.trimStart();
- } else if (blankLine) {
- indent = cap[1].length + 1;
- } else {
- indent = cap[2].search(this.rules.other.nonSpaceChar);
- indent = indent > 4 ? 1 : indent;
- itemContents = line.slice(indent);
- indent += cap[1].length;
- }
- if (blankLine && this.rules.other.blankLine.test(nextLine)) {
- raw += nextLine + "\n";
- src = src.substring(nextLine.length + 1);
- endEarly = true;
- }
- if (!endEarly) {
- const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
- const hrRegex = this.rules.other.hrRegex(indent);
- const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
- const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
- const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
- while (src) {
- const rawLine = src.split("\n", 1)[0];
- let nextLineWithoutTabs;
- nextLine = rawLine;
- if (this.options.pedantic) {
- nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
- nextLineWithoutTabs = nextLine;
- } else {
- nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
- }
- if (fencesBeginRegex.test(nextLine)) {
- break;
- }
- if (headingBeginRegex.test(nextLine)) {
- break;
- }
- if (htmlBeginRegex.test(nextLine)) {
- break;
- }
- if (nextBulletRegex.test(nextLine)) {
- break;
- }
- if (hrRegex.test(nextLine)) {
- break;
- }
- if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
- itemContents += "\n" + nextLineWithoutTabs.slice(indent);
- } else {
- if (blankLine) {
- break;
- }
- if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
- break;
- }
- if (fencesBeginRegex.test(line)) {
- break;
- }
- if (headingBeginRegex.test(line)) {
- break;
- }
- if (hrRegex.test(line)) {
- break;
- }
- itemContents += "\n" + nextLine;
- }
- if (!blankLine && !nextLine.trim()) {
- blankLine = true;
- }
- raw += rawLine + "\n";
- src = src.substring(rawLine.length + 1);
- line = nextLineWithoutTabs.slice(indent);
- }
- }
- if (!list2.loose) {
- if (endsWithBlankLine) {
- list2.loose = true;
- } else if (this.rules.other.doubleBlankLine.test(raw)) {
- endsWithBlankLine = true;
- }
- }
- let istask = null;
- let ischecked;
- if (this.options.gfm) {
- istask = this.rules.other.listIsTask.exec(itemContents);
- if (istask) {
- ischecked = istask[0] !== "[ ] ";
- itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
- }
- }
- list2.items.push({
- type: "list_item",
- raw,
- task: !!istask,
- checked: ischecked,
- loose: false,
- text: itemContents,
- tokens: []
- });
- list2.raw += raw;
- }
- const lastItem = list2.items.at(-1);
- if (lastItem) {
- lastItem.raw = lastItem.raw.trimEnd();
- lastItem.text = lastItem.text.trimEnd();
- } else {
- return;
- }
- list2.raw = list2.raw.trimEnd();
- for (let i = 0; i < list2.items.length; i++) {
- this.lexer.state.top = false;
- list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
- if (!list2.loose) {
- const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
- list2.loose = hasMultipleLineBreaks;
- }
- }
- if (list2.loose) {
- for (let i = 0; i < list2.items.length; i++) {
- list2.items[i].loose = true;
- }
- }
- return list2;
- }
- }
- html(src) {
- const cap = this.rules.block.html.exec(src);
- if (cap) {
- const token = {
- type: "html",
- block: true,
- raw: cap[0],
- pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
- text: cap[0]
- };
- return token;
- }
- }
- def(src) {
- const cap = this.rules.block.def.exec(src);
- if (cap) {
- const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
- const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
- return {
- type: "def",
- tag: tag2,
- raw: cap[0],
- href,
- title
- };
- }
- }
- table(src) {
- const cap = this.rules.block.table.exec(src);
- if (!cap) {
- return;
- }
- if (!this.rules.other.tableDelimiter.test(cap[2])) {
- return;
- }
- const headers = splitCells(cap[1]);
- const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
- const rows = cap[3]?.trim() ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
- const item = {
- type: "table",
- raw: cap[0],
- header: [],
- align: [],
- rows: []
- };
- if (headers.length !== aligns.length) {
- return;
- }
- for (const align of aligns) {
- if (this.rules.other.tableAlignRight.test(align)) {
- item.align.push("right");
- } else if (this.rules.other.tableAlignCenter.test(align)) {
- item.align.push("center");
- } else if (this.rules.other.tableAlignLeft.test(align)) {
- item.align.push("left");
- } else {
- item.align.push(null);
- }
- }
- for (let i = 0; i < headers.length; i++) {
- item.header.push({
- text: headers[i],
- tokens: this.lexer.inline(headers[i]),
- header: true,
- align: item.align[i]
- });
- }
- for (const row of rows) {
- item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
- return {
- text: cell,
- tokens: this.lexer.inline(cell),
- header: false,
- align: item.align[i]
- };
- }));
- }
- return item;
- }
- lheading(src) {
- const cap = this.rules.block.lheading.exec(src);
- if (cap) {
- return {
- type: "heading",
- raw: cap[0],
- depth: cap[2].charAt(0) === "=" ? 1 : 2,
- text: cap[1],
- tokens: this.lexer.inline(cap[1])
- };
- }
- }
- paragraph(src) {
- const cap = this.rules.block.paragraph.exec(src);
- if (cap) {
- const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
- return {
- type: "paragraph",
- raw: cap[0],
- text,
- tokens: this.lexer.inline(text)
- };
- }
- }
- text(src) {
- const cap = this.rules.block.text.exec(src);
- if (cap) {
- return {
- type: "text",
- raw: cap[0],
- text: cap[0],
- tokens: this.lexer.inline(cap[0])
- };
- }
- }
- escape(src) {
- const cap = this.rules.inline.escape.exec(src);
- if (cap) {
- return {
- type: "escape",
- raw: cap[0],
- text: cap[1]
- };
- }
- }
- tag(src) {
- const cap = this.rules.inline.tag.exec(src);
- if (cap) {
- if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
- this.lexer.state.inLink = true;
- } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
- this.lexer.state.inLink = false;
- }
- if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
- this.lexer.state.inRawBlock = true;
- } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
- this.lexer.state.inRawBlock = false;
- }
- return {
- type: "html",
- raw: cap[0],
- inLink: this.lexer.state.inLink,
- inRawBlock: this.lexer.state.inRawBlock,
- block: false,
- text: cap[0]
- };
- }
- }
- link(src) {
- const cap = this.rules.inline.link.exec(src);
- if (cap) {
- const trimmedUrl = cap[2].trim();
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
- if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
- return;
- }
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
- if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
- return;
- }
- } else {
- const lastParenIndex = findClosingBracket(cap[2], "()");
- if (lastParenIndex > -1) {
- const start = cap[0].indexOf("!") === 0 ? 5 : 4;
- const linkLen = start + cap[1].length + lastParenIndex;
- cap[2] = cap[2].substring(0, lastParenIndex);
- cap[0] = cap[0].substring(0, linkLen).trim();
- cap[3] = "";
- }
- }
- let href = cap[2];
- let title = "";
- if (this.options.pedantic) {
- const link2 = this.rules.other.pedanticHrefTitle.exec(href);
- if (link2) {
- href = link2[1];
- title = link2[3];
- }
- } else {
- title = cap[3] ? cap[3].slice(1, -1) : "";
- }
- href = href.trim();
- if (this.rules.other.startAngleBracket.test(href)) {
- if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
- href = href.slice(1);
- } else {
- href = href.slice(1, -1);
- }
- }
- return outputLink(cap, {
- href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
- title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
- }, cap[0], this.lexer, this.rules);
- }
- }
- reflink(src, links) {
- let cap;
- if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
- const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
- const link2 = links[linkString.toLowerCase()];
- if (!link2) {
- const text = cap[0].charAt(0);
- return {
- type: "text",
- raw: text,
- text
- };
- }
- return outputLink(cap, link2, cap[0], this.lexer, this.rules);
- }
- }
- emStrong(src, maskedSrc, prevChar = "") {
- let match = this.rules.inline.emStrongLDelim.exec(src);
- if (!match)
- return;
- if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric))
- return;
- const nextChar = match[1] || match[2] || "";
- if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
- const lLength = [...match[0]].length - 1;
- let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
- const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
- endReg.lastIndex = 0;
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
- while ((match = endReg.exec(maskedSrc)) != null) {
- rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
- if (!rDelim)
- continue;
- rLength = [...rDelim].length;
- if (match[3] || match[4]) {
- delimTotal += rLength;
- continue;
- } else if (match[5] || match[6]) {
- if (lLength % 3 && !((lLength + rLength) % 3)) {
- midDelimTotal += rLength;
- continue;
- }
- }
- delimTotal -= rLength;
- if (delimTotal > 0)
- continue;
- rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
- const lastCharLength = [...match[0]][0].length;
- const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
- if (Math.min(lLength, rLength) % 2) {
- const text2 = raw.slice(1, -1);
- return {
- type: "em",
- raw,
- text: text2,
- tokens: this.lexer.inlineTokens(text2)
- };
- }
- const text = raw.slice(2, -2);
- return {
- type: "strong",
- raw,
- text,
- tokens: this.lexer.inlineTokens(text)
- };
- }
- }
- }
- codespan(src) {
- const cap = this.rules.inline.code.exec(src);
- if (cap) {
- let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
- const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
- const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
- if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
- text = text.substring(1, text.length - 1);
- }
- return {
- type: "codespan",
- raw: cap[0],
- text
- };
- }
- }
- br(src) {
- const cap = this.rules.inline.br.exec(src);
- if (cap) {
- return {
- type: "br",
- raw: cap[0]
- };
- }
- }
- del(src) {
- const cap = this.rules.inline.del.exec(src);
- if (cap) {
- return {
- type: "del",
- raw: cap[0],
- text: cap[2],
- tokens: this.lexer.inlineTokens(cap[2])
- };
- }
- }
- autolink(src) {
- const cap = this.rules.inline.autolink.exec(src);
- if (cap) {
- let text, href;
- if (cap[2] === "@") {
- text = cap[1];
- href = "mailto:" + text;
- } else {
- text = cap[1];
- href = text;
- }
- return {
- type: "link",
- raw: cap[0],
- text,
- href,
- tokens: [
- {
- type: "text",
- raw: text,
- text
- }
- ]
- };
- }
- }
- url(src) {
- let cap;
- if (cap = this.rules.inline.url.exec(src)) {
- let text, href;
- if (cap[2] === "@") {
- text = cap[0];
- href = "mailto:" + text;
- } else {
- let prevCapZero;
- do {
- prevCapZero = cap[0];
- cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
- } while (prevCapZero !== cap[0]);
- text = cap[0];
- if (cap[1] === "www.") {
- href = "http://" + cap[0];
- } else {
- href = cap[0];
- }
- }
- return {
- type: "link",
- raw: cap[0],
- text,
- href,
- tokens: [
- {
- type: "text",
- raw: text,
- text
- }
- ]
- };
- }
- }
- inlineText(src) {
- const cap = this.rules.inline.text.exec(src);
- if (cap) {
- const escaped = this.lexer.state.inRawBlock;
- return {
- type: "text",
- raw: cap[0],
- text: cap[0],
- escaped
- };
- }
- }
-}
-class _Lexer {
- tokens;
- options;
- state;
- tokenizer;
- inlineQueue;
- constructor(options) {
- this.tokens = [];
- this.tokens.links = /* @__PURE__ */ Object.create(null);
- this.options = options || _defaults;
- this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
- this.tokenizer = this.options.tokenizer;
- this.tokenizer.options = this.options;
- this.tokenizer.lexer = this;
- this.inlineQueue = [];
- this.state = {
- inLink: false,
- inRawBlock: false,
- top: true
- };
- const rules = {
- other,
- block: block.normal,
- inline: inline.normal
- };
- if (this.options.pedantic) {
- rules.block = block.pedantic;
- rules.inline = inline.pedantic;
- } else if (this.options.gfm) {
- rules.block = block.gfm;
- if (this.options.breaks) {
- rules.inline = inline.breaks;
- } else {
- rules.inline = inline.gfm;
- }
- }
- this.tokenizer.rules = rules;
- }
- /**
- * Expose Rules
- */
- static get rules() {
- return {
- block,
- inline
- };
- }
- /**
- * Static Lex Method
- */
- static lex(src, options) {
- const lexer = new _Lexer(options);
- return lexer.lex(src);
- }
- /**
- * Static Lex Inline Method
- */
- static lexInline(src, options) {
- const lexer = new _Lexer(options);
- return lexer.inlineTokens(src);
- }
- /**
- * Preprocessing
- */
- lex(src) {
- src = src.replace(other.carriageReturn, "\n");
- this.blockTokens(src, this.tokens);
- for (let i = 0; i < this.inlineQueue.length; i++) {
- const next = this.inlineQueue[i];
- this.inlineTokens(next.src, next.tokens);
- }
- this.inlineQueue = [];
- return this.tokens;
- }
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
- if (this.options.pedantic) {
- src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
- }
- while (src) {
- let token;
- if (this.options.extensions?.block?.some((extTokenizer) => {
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- return true;
- }
- return false;
- })) {
- continue;
- }
- if (token = this.tokenizer.space(src)) {
- src = src.substring(token.raw.length);
- const lastToken = tokens.at(-1);
- if (token.raw.length === 1 && lastToken !== void 0) {
- lastToken.raw += "\n";
- } else {
- tokens.push(token);
- }
- continue;
- }
- if (token = this.tokenizer.code(src)) {
- src = src.substring(token.raw.length);
- const lastToken = tokens.at(-1);
- if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
- lastToken.raw += "\n" + token.raw;
- lastToken.text += "\n" + token.text;
- this.inlineQueue.at(-1).src = lastToken.text;
- } else {
- tokens.push(token);
- }
- continue;
- }
- if (token = this.tokenizer.fences(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.heading(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.hr(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.blockquote(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.list(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.html(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.def(src)) {
- src = src.substring(token.raw.length);
- const lastToken = tokens.at(-1);
- if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
- lastToken.raw += "\n" + token.raw;
- lastToken.text += "\n" + token.raw;
- this.inlineQueue.at(-1).src = lastToken.text;
- } else if (!this.tokens.links[token.tag]) {
- this.tokens.links[token.tag] = {
- href: token.href,
- title: token.title
- };
- }
- continue;
- }
- if (token = this.tokenizer.table(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.lheading(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- let cutSrc = src;
- if (this.options.extensions?.startBlock) {
- let startIndex = Infinity;
- const tempSrc = src.slice(1);
- let tempStart;
- this.options.extensions.startBlock.forEach((getStartIndex) => {
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
- if (typeof tempStart === "number" && tempStart >= 0) {
- startIndex = Math.min(startIndex, tempStart);
- }
- });
- if (startIndex < Infinity && startIndex >= 0) {
- cutSrc = src.substring(0, startIndex + 1);
- }
- }
- if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
- const lastToken = tokens.at(-1);
- if (lastParagraphClipped && lastToken?.type === "paragraph") {
- lastToken.raw += "\n" + token.raw;
- lastToken.text += "\n" + token.text;
- this.inlineQueue.pop();
- this.inlineQueue.at(-1).src = lastToken.text;
- } else {
- tokens.push(token);
- }
- lastParagraphClipped = cutSrc.length !== src.length;
- src = src.substring(token.raw.length);
- continue;
- }
- if (token = this.tokenizer.text(src)) {
- src = src.substring(token.raw.length);
- const lastToken = tokens.at(-1);
- if (lastToken?.type === "text") {
- lastToken.raw += "\n" + token.raw;
- lastToken.text += "\n" + token.text;
- this.inlineQueue.pop();
- this.inlineQueue.at(-1).src = lastToken.text;
- } else {
- tokens.push(token);
- }
- continue;
- }
- if (src) {
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
- if (this.options.silent) {
- console.error(errMsg);
- break;
- } else {
- throw new Error(errMsg);
- }
- }
- }
- this.state.top = true;
- return tokens;
- }
- inline(src, tokens = []) {
- this.inlineQueue.push({ src, tokens });
- return tokens;
- }
- /**
- * Lexing/Compiling
- */
- inlineTokens(src, tokens = []) {
- let maskedSrc = src;
- let match = null;
- if (this.tokens.links) {
- const links = Object.keys(this.tokens.links);
- if (links.length > 0) {
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
- if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
- }
- }
- }
- }
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
- }
- while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
- maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
- }
- let keepPrevChar = false;
- let prevChar = "";
- while (src) {
- if (!keepPrevChar) {
- prevChar = "";
- }
- keepPrevChar = false;
- let token;
- if (this.options.extensions?.inline?.some((extTokenizer) => {
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- return true;
- }
- return false;
- })) {
- continue;
- }
- if (token = this.tokenizer.escape(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.tag(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.link(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.reflink(src, this.tokens.links)) {
- src = src.substring(token.raw.length);
- const lastToken = tokens.at(-1);
- if (token.type === "text" && lastToken?.type === "text") {
- lastToken.raw += token.raw;
- lastToken.text += token.text;
- } else {
- tokens.push(token);
- }
- continue;
- }
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.codespan(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.br(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.del(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (token = this.tokenizer.autolink(src)) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
- src = src.substring(token.raw.length);
- tokens.push(token);
- continue;
- }
- let cutSrc = src;
- if (this.options.extensions?.startInline) {
- let startIndex = Infinity;
- const tempSrc = src.slice(1);
- let tempStart;
- this.options.extensions.startInline.forEach((getStartIndex) => {
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
- if (typeof tempStart === "number" && tempStart >= 0) {
- startIndex = Math.min(startIndex, tempStart);
- }
- });
- if (startIndex < Infinity && startIndex >= 0) {
- cutSrc = src.substring(0, startIndex + 1);
- }
- }
- if (token = this.tokenizer.inlineText(cutSrc)) {
- src = src.substring(token.raw.length);
- if (token.raw.slice(-1) !== "_") {
- prevChar = token.raw.slice(-1);
- }
- keepPrevChar = true;
- const lastToken = tokens.at(-1);
- if (lastToken?.type === "text") {
- lastToken.raw += token.raw;
- lastToken.text += token.text;
- } else {
- tokens.push(token);
- }
- continue;
- }
- if (src) {
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
- if (this.options.silent) {
- console.error(errMsg);
- break;
- } else {
- throw new Error(errMsg);
- }
- }
- }
- return tokens;
- }
-}
-class _Renderer {
- options;
- parser;
- // set by the parser
- constructor(options) {
- this.options = options || _defaults;
- }
- space(token) {
- return "";
- }
- code({ text, lang, escaped }) {
- const langString = (lang || "").match(other.notSpaceStart)?.[0];
- const code = text.replace(other.endingNewline, "") + "\n";
- if (!langString) {
- return "" + (escaped ? code : escape(code, true)) + "
\n";
- }
- return '' + (escaped ? code : escape(code, true)) + "
\n";
- }
- blockquote({ tokens }) {
- const body = this.parser.parse(tokens);
- return `
-${body}
-`;
- }
- html({ text }) {
- return text;
- }
- heading({ tokens, depth }) {
- return `${this.parser.parseInline(tokens)}
-`;
- }
- hr(token) {
- return "
\n";
- }
- list(token) {
- const ordered = token.ordered;
- const start = token.start;
- let body = "";
- for (let j = 0; j < token.items.length; j++) {
- const item = token.items[j];
- body += this.listitem(item);
- }
- const type = ordered ? "ol" : "ul";
- const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
- return "<" + type + startAttr + ">\n" + body + "" + type + ">\n";
- }
- listitem(item) {
- let itemBody = "";
- if (item.task) {
- const checkbox = this.checkbox({ checked: !!item.checked });
- if (item.loose) {
- if (item.tokens[0]?.type === "paragraph") {
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
- item.tokens[0].tokens[0].text = checkbox + " " + escape(item.tokens[0].tokens[0].text);
- item.tokens[0].tokens[0].escaped = true;
- }
- } else {
- item.tokens.unshift({
- type: "text",
- raw: checkbox + " ",
- text: checkbox + " ",
- escaped: true
- });
- }
- } else {
- itemBody += checkbox + " ";
- }
- }
- itemBody += this.parser.parse(item.tokens, !!item.loose);
- return `${itemBody}
-`;
- }
- checkbox({ checked }) {
- return "';
- }
- paragraph({ tokens }) {
- return `${this.parser.parseInline(tokens)}
-`;
- }
- table(token) {
- let header = "";
- let cell = "";
- for (let j = 0; j < token.header.length; j++) {
- cell += this.tablecell(token.header[j]);
- }
- header += this.tablerow({ text: cell });
- let body = "";
- for (let j = 0; j < token.rows.length; j++) {
- const row = token.rows[j];
- cell = "";
- for (let k = 0; k < row.length; k++) {
- cell += this.tablecell(row[k]);
- }
- body += this.tablerow({ text: cell });
- }
- if (body)
- body = `${body}`;
- return "\n\n" + header + "\n" + body + "
\n";
- }
- tablerow({ text }) {
- return `
-${text}
-`;
- }
- tablecell(token) {
- const content = this.parser.parseInline(token.tokens);
- const type = token.header ? "th" : "td";
- const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
- return tag2 + content + `${type}>
-`;
- }
- /**
- * span level renderer
- */
- strong({ tokens }) {
- return `${this.parser.parseInline(tokens)}`;
- }
- em({ tokens }) {
- return `${this.parser.parseInline(tokens)}`;
- }
- codespan({ text }) {
- return `${escape(text, true)}`;
- }
- br(token) {
- return "
";
- }
- del({ tokens }) {
- return `${this.parser.parseInline(tokens)}`;
- }
- link({ href, title, tokens }) {
- const text = this.parser.parseInline(tokens);
- const cleanHref = cleanUrl(href);
- if (cleanHref === null) {
- return text;
- }
- href = cleanHref;
- let out = '" + text + "";
- return out;
- }
- image({ href, title, text }) {
- const cleanHref = cleanUrl(href);
- if (cleanHref === null) {
- return escape(text);
- }
- href = cleanHref;
- let out = `
";
- return out;
- }
- text(token) {
- return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape(token.text);
- }
-}
-class _TextRenderer {
- // no need for block level renderers
- strong({ text }) {
- return text;
- }
- em({ text }) {
- return text;
- }
- codespan({ text }) {
- return text;
- }
- del({ text }) {
- return text;
- }
- html({ text }) {
- return text;
- }
- text({ text }) {
- return text;
- }
- link({ text }) {
- return "" + text;
- }
- image({ text }) {
- return "" + text;
- }
- br() {
- return "";
- }
-}
-class _Parser {
- options;
- renderer;
- textRenderer;
- constructor(options) {
- this.options = options || _defaults;
- this.options.renderer = this.options.renderer || new _Renderer();
- this.renderer = this.options.renderer;
- this.renderer.options = this.options;
- this.renderer.parser = this;
- this.textRenderer = new _TextRenderer();
- }
- /**
- * Static Parse Method
- */
- static parse(tokens, options) {
- const parser = new _Parser(options);
- return parser.parse(tokens);
- }
- /**
- * Static Parse Inline Method
- */
- static parseInline(tokens, options) {
- const parser = new _Parser(options);
- return parser.parseInline(tokens);
- }
- /**
- * Parse Loop
- */
- parse(tokens, top = true) {
- let out = "";
- for (let i = 0; i < tokens.length; i++) {
- const anyToken = tokens[i];
- if (this.options.extensions?.renderers?.[anyToken.type]) {
- const genericToken = anyToken;
- const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
- if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
- out += ret || "";
- continue;
- }
- }
- const token = anyToken;
- switch (token.type) {
- case "space": {
- out += this.renderer.space(token);
- continue;
- }
- case "hr": {
- out += this.renderer.hr(token);
- continue;
- }
- case "heading": {
- out += this.renderer.heading(token);
- continue;
- }
- case "code": {
- out += this.renderer.code(token);
- continue;
- }
- case "table": {
- out += this.renderer.table(token);
- continue;
- }
- case "blockquote": {
- out += this.renderer.blockquote(token);
- continue;
- }
- case "list": {
- out += this.renderer.list(token);
- continue;
- }
- case "html": {
- out += this.renderer.html(token);
- continue;
- }
- case "paragraph": {
- out += this.renderer.paragraph(token);
- continue;
- }
- case "text": {
- let textToken = token;
- let body = this.renderer.text(textToken);
- while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
- textToken = tokens[++i];
- body += "\n" + this.renderer.text(textToken);
- }
- if (top) {
- out += this.renderer.paragraph({
- type: "paragraph",
- raw: body,
- text: body,
- tokens: [{ type: "text", raw: body, text: body, escaped: true }]
- });
- } else {
- out += body;
- }
- continue;
- }
- default: {
- const errMsg = 'Token with "' + token.type + '" type was not found.';
- if (this.options.silent) {
- console.error(errMsg);
- return "";
- } else {
- throw new Error(errMsg);
- }
- }
- }
- }
- return out;
- }
- /**
- * Parse Inline Tokens
- */
- parseInline(tokens, renderer2 = this.renderer) {
- let out = "";
- for (let i = 0; i < tokens.length; i++) {
- const anyToken = tokens[i];
- if (this.options.extensions?.renderers?.[anyToken.type]) {
- const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
- if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
- out += ret || "";
- continue;
- }
- }
- const token = anyToken;
- switch (token.type) {
- case "escape": {
- out += renderer2.text(token);
- break;
- }
- case "html": {
- out += renderer2.html(token);
- break;
- }
- case "link": {
- out += renderer2.link(token);
- break;
- }
- case "image": {
- out += renderer2.image(token);
- break;
- }
- case "strong": {
- out += renderer2.strong(token);
- break;
- }
- case "em": {
- out += renderer2.em(token);
- break;
- }
- case "codespan": {
- out += renderer2.codespan(token);
- break;
- }
- case "br": {
- out += renderer2.br(token);
- break;
- }
- case "del": {
- out += renderer2.del(token);
- break;
- }
- case "text": {
- out += renderer2.text(token);
- break;
- }
- default: {
- const errMsg = 'Token with "' + token.type + '" type was not found.';
- if (this.options.silent) {
- console.error(errMsg);
- return "";
- } else {
- throw new Error(errMsg);
- }
- }
- }
- }
- return out;
- }
-}
-class _Hooks {
- options;
- block;
- constructor(options) {
- this.options = options || _defaults;
- }
- static passThroughHooks = /* @__PURE__ */ new Set([
- "preprocess",
- "postprocess",
- "processAllTokens"
- ]);
- /**
- * Process markdown before marked
- */
- preprocess(markdown) {
- return markdown;
- }
- /**
- * Process HTML after marked is finished
- */
- postprocess(html2) {
- return html2;
- }
- /**
- * Process all tokens before walk tokens
- */
- processAllTokens(tokens) {
- return tokens;
- }
- /**
- * Provide function to tokenize markdown
- */
- provideLexer() {
- return this.block ? _Lexer.lex : _Lexer.lexInline;
- }
- /**
- * Provide function to parse tokens
- */
- provideParser() {
- return this.block ? _Parser.parse : _Parser.parseInline;
- }
-}
-class Marked {
- defaults = _getDefaults();
- options = this.setOptions;
- parse = this.parseMarkdown(true);
- parseInline = this.parseMarkdown(false);
- Parser = _Parser;
- Renderer = _Renderer;
- TextRenderer = _TextRenderer;
- Lexer = _Lexer;
- Tokenizer = _Tokenizer;
- Hooks = _Hooks;
- constructor(...args) {
- this.use(...args);
- }
- /**
- * Run callback for every token
- */
- walkTokens(tokens, callback) {
- let values = [];
- for (const token of tokens) {
- values = values.concat(callback.call(this, token));
- switch (token.type) {
- case "table": {
- const tableToken = token;
- for (const cell of tableToken.header) {
- values = values.concat(this.walkTokens(cell.tokens, callback));
- }
- for (const row of tableToken.rows) {
- for (const cell of row) {
- values = values.concat(this.walkTokens(cell.tokens, callback));
- }
- }
- break;
- }
- case "list": {
- const listToken = token;
- values = values.concat(this.walkTokens(listToken.items, callback));
- break;
- }
- default: {
- const genericToken = token;
- if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
- this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
- const tokens2 = genericToken[childTokens].flat(Infinity);
- values = values.concat(this.walkTokens(tokens2, callback));
- });
- } else if (genericToken.tokens) {
- values = values.concat(this.walkTokens(genericToken.tokens, callback));
- }
- }
- }
- }
- return values;
- }
- use(...args) {
- const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
- args.forEach((pack) => {
- const opts = { ...pack };
- opts.async = this.defaults.async || opts.async || false;
- if (pack.extensions) {
- pack.extensions.forEach((ext) => {
- if (!ext.name) {
- throw new Error("extension name required");
- }
- if ("renderer" in ext) {
- const prevRenderer = extensions.renderers[ext.name];
- if (prevRenderer) {
- extensions.renderers[ext.name] = function(...args2) {
- let ret = ext.renderer.apply(this, args2);
- if (ret === false) {
- ret = prevRenderer.apply(this, args2);
- }
- return ret;
- };
- } else {
- extensions.renderers[ext.name] = ext.renderer;
- }
- }
- if ("tokenizer" in ext) {
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
- throw new Error("extension level must be 'block' or 'inline'");
- }
- const extLevel = extensions[ext.level];
- if (extLevel) {
- extLevel.unshift(ext.tokenizer);
- } else {
- extensions[ext.level] = [ext.tokenizer];
- }
- if (ext.start) {
- if (ext.level === "block") {
- if (extensions.startBlock) {
- extensions.startBlock.push(ext.start);
- } else {
- extensions.startBlock = [ext.start];
- }
- } else if (ext.level === "inline") {
- if (extensions.startInline) {
- extensions.startInline.push(ext.start);
- } else {
- extensions.startInline = [ext.start];
- }
- }
- }
- }
- if ("childTokens" in ext && ext.childTokens) {
- extensions.childTokens[ext.name] = ext.childTokens;
- }
- });
- opts.extensions = extensions;
- }
- if (pack.renderer) {
- const renderer2 = this.defaults.renderer || new _Renderer(this.defaults);
- for (const prop in pack.renderer) {
- if (!(prop in renderer2)) {
- throw new Error(`renderer '${prop}' does not exist`);
- }
- if (["options", "parser"].includes(prop)) {
- continue;
- }
- const rendererProp = prop;
- const rendererFunc = pack.renderer[rendererProp];
- const prevRenderer = renderer2[rendererProp];
- renderer2[rendererProp] = (...args2) => {
- let ret = rendererFunc.apply(renderer2, args2);
- if (ret === false) {
- ret = prevRenderer.apply(renderer2, args2);
- }
- return ret || "";
- };
- }
- opts.renderer = renderer2;
- }
- if (pack.tokenizer) {
- const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
- for (const prop in pack.tokenizer) {
- if (!(prop in tokenizer)) {
- throw new Error(`tokenizer '${prop}' does not exist`);
- }
- if (["options", "rules", "lexer"].includes(prop)) {
- continue;
- }
- const tokenizerProp = prop;
- const tokenizerFunc = pack.tokenizer[tokenizerProp];
- const prevTokenizer = tokenizer[tokenizerProp];
- tokenizer[tokenizerProp] = (...args2) => {
- let ret = tokenizerFunc.apply(tokenizer, args2);
- if (ret === false) {
- ret = prevTokenizer.apply(tokenizer, args2);
- }
- return ret;
- };
- }
- opts.tokenizer = tokenizer;
- }
- if (pack.hooks) {
- const hooks = this.defaults.hooks || new _Hooks();
- for (const prop in pack.hooks) {
- if (!(prop in hooks)) {
- throw new Error(`hook '${prop}' does not exist`);
- }
- if (["options", "block"].includes(prop)) {
- continue;
- }
- const hooksProp = prop;
- const hooksFunc = pack.hooks[hooksProp];
- const prevHook = hooks[hooksProp];
- if (_Hooks.passThroughHooks.has(prop)) {
- hooks[hooksProp] = (arg) => {
- if (this.defaults.async) {
- return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
- return prevHook.call(hooks, ret2);
- });
- }
- const ret = hooksFunc.call(hooks, arg);
- return prevHook.call(hooks, ret);
- };
- } else {
- hooks[hooksProp] = (...args2) => {
- let ret = hooksFunc.apply(hooks, args2);
- if (ret === false) {
- ret = prevHook.apply(hooks, args2);
- }
- return ret;
- };
- }
- }
- opts.hooks = hooks;
- }
- if (pack.walkTokens) {
- const walkTokens = this.defaults.walkTokens;
- const packWalktokens = pack.walkTokens;
- opts.walkTokens = function(token) {
- let values = [];
- values.push(packWalktokens.call(this, token));
- if (walkTokens) {
- values = values.concat(walkTokens.call(this, token));
- }
- return values;
- };
- }
- this.defaults = { ...this.defaults, ...opts };
- });
- return this;
- }
- setOptions(opt) {
- this.defaults = { ...this.defaults, ...opt };
- return this;
- }
- lexer(src, options) {
- return _Lexer.lex(src, options ?? this.defaults);
- }
- parser(tokens, options) {
- return _Parser.parse(tokens, options ?? this.defaults);
- }
- parseMarkdown(blockType) {
- const parse = (src, options) => {
- const origOpt = { ...options };
- const opt = { ...this.defaults, ...origOpt };
- const throwError2 = this.onError(!!opt.silent, !!opt.async);
- if (this.defaults.async === true && origOpt.async === false) {
- return throwError2(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
- }
- if (typeof src === "undefined" || src === null) {
- return throwError2(new Error("marked(): input parameter is undefined or null"));
- }
- if (typeof src !== "string") {
- return throwError2(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
- }
- if (opt.hooks) {
- opt.hooks.options = opt;
- opt.hooks.block = blockType;
- }
- const lexer = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
- const parser = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
- if (opt.async) {
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError2);
- }
- try {
- if (opt.hooks) {
- src = opt.hooks.preprocess(src);
- }
- let tokens = lexer(src, opt);
- if (opt.hooks) {
- tokens = opt.hooks.processAllTokens(tokens);
- }
- if (opt.walkTokens) {
- this.walkTokens(tokens, opt.walkTokens);
- }
- let html2 = parser(tokens, opt);
- if (opt.hooks) {
- html2 = opt.hooks.postprocess(html2);
- }
- return html2;
- } catch (e) {
- return throwError2(e);
- }
- };
- return parse;
- }
- onError(silent, async) {
- return (e) => {
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
- if (silent) {
- const msg2 = "An error occurred:
" + escape(e.message + "", true) + "
";
- if (async) {
- return Promise.resolve(msg2);
- }
- return msg2;
- }
- if (async) {
- return Promise.reject(e);
- }
- throw e;
- };
- }
-}
-const markedInstance = new Marked();
-function marked(src, opt) {
- return markedInstance.parse(src, opt);
-}
-marked.options = marked.setOptions = function(options) {
- markedInstance.setOptions(options);
- marked.defaults = markedInstance.defaults;
- changeDefaults(marked.defaults);
- return marked;
-};
-marked.getDefaults = _getDefaults;
-marked.defaults = _defaults;
-marked.use = function(...args) {
- markedInstance.use(...args);
- marked.defaults = markedInstance.defaults;
- changeDefaults(marked.defaults);
- return marked;
-};
-marked.walkTokens = function(tokens, callback) {
- return markedInstance.walkTokens(tokens, callback);
-};
-marked.parseInline = markedInstance.parseInline;
-marked.Parser = _Parser;
-marked.parser = _Parser.parse;
-marked.Renderer = _Renderer;
-marked.TextRenderer = _TextRenderer;
-marked.Lexer = _Lexer;
-marked.lexer = _Lexer.lex;
-marked.Tokenizer = _Tokenizer;
-marked.Hooks = _Hooks;
-marked.parse = marked;
-marked.options;
-marked.setOptions;
-marked.use;
-marked.walkTokens;
-marked.parseInline;
-_Parser.parse;
-_Lexer.lex;
-const _hoisted_1$2 = { class: "modal-content" };
-const _hoisted_2$2 = { class: "modal-header" };
-const _hoisted_3$1 = { class: "app-info" };
-const _hoisted_4$1 = { class: "app-name" };
-const _hoisted_5 = { class: "app-desc mb-2" };
-const _hoisted_6 = { class: "update-info" };
-const _hoisted_7 = ["innerHTML"];
-const _hoisted_8 = { class: "modal-actions" };
-const _sfc_main$3 = /* @__PURE__ */ defineComponent({
- __name: "UpdateModal",
- setup(__props) {
- marked.setOptions({
- breaks: true,
- // 支持 GitHub 风格的换行
- gfm: true
- // 启用 GitHub 风格的 Markdown
- });
- const showModal = ref(false);
- const noPrompt = ref(false);
- const updateInfo = ref({
- hasUpdate: false,
- latestVersion: "",
- currentVersion: config.version,
- releaseInfo: null
- });
- const parsedReleaseNotes = computed(() => {
- if (!updateInfo.value.releaseInfo?.body) return "";
- try {
- return marked.parse(updateInfo.value.releaseInfo.body);
- } catch (error) {
- console.error("Error parsing markdown:", error);
- return updateInfo.value.releaseInfo.body;
- }
- });
- const closeModal = () => {
- showModal.value = false;
- if (noPrompt.value) {
- localStorage.setItem("updatePromptDismissed", "true");
- }
- };
- const checkForUpdates = async () => {
- try {
- const result = await checkUpdate();
- updateInfo.value = result;
- if (result.hasUpdate && localStorage.getItem("updatePromptDismissed") !== "true") {
- showModal.value = true;
- }
- } catch (error) {
- console.error("检查更新失败:", error);
- }
- };
- const handleUpdate = async () => {
- const { userAgent } = navigator;
- const isMac = userAgent.includes("Mac");
- const isWindows = userAgent.includes("Win");
- const isARM = userAgent.includes("ARM") || userAgent.includes("arm") || userAgent.includes("OS X");
- const isX64 = userAgent.includes("x86_64") || userAgent.includes("Win64") || userAgent.includes("WOW64");
- const isX86 = !isX64 && (userAgent.includes("i686") || userAgent.includes("i386") || userAgent.includes("Win32"));
- const getDownloadUrl = (os, arch) => {
- const version2 = updateInfo.value.latestVersion;
- const setup = os !== "mac" ? "Setup_" : "";
- return `https://gh.llkk.cc/https://github.com/algerkong/AlgerMusicPlayer/releases/download/v${version2}/AlgerMusic_${version2}_${setup}${arch}.${os === "mac" ? "dmg" : "exe"}`;
- };
- const osType = isMac ? "mac" : isWindows ? "windows" : null;
- const archType = isARM ? "arm64" : isX64 ? "x64" : isX86 ? "x86" : null;
- const downloadUrl = osType && archType ? getDownloadUrl(osType, archType) : null;
- window.open(downloadUrl || "https://github.com/algerkong/AlgerMusicPlayer/releases/latest", "_blank");
- closeModal();
- };
- onMounted(() => {
- checkForUpdates();
- });
- return (_ctx, _cache) => {
- const _component_n_checkbox = __unplugin_components_0$2;
- const _component_n_scrollbar = Scrollbar;
- const _component_n_button = Button;
- const _component_n_modal = __unplugin_components_3;
- return openBlock(), createBlock(_component_n_modal, {
- show: showModal.value,
- "onUpdate:show": _cache[1] || (_cache[1] = ($event) => showModal.value = $event),
- preset: "dialog",
- "show-icon": false,
- "mask-closable": true,
- class: "update-app-modal",
- style: { "width": "800px", "max-width": "90vw" }
- }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_1$2, [
- createBaseVNode("div", _hoisted_2$2, [
- _cache[3] || (_cache[3] = createBaseVNode("div", { class: "app-icon" }, [
- createBaseVNode("img", {
- src: _imports_0,
- alt: "App Icon"
- })
- ], -1)),
- createBaseVNode("div", _hoisted_3$1, [
- createBaseVNode("h2", _hoisted_4$1, "发现新版本 " + toDisplayString(updateInfo.value.latestVersion), 1),
- createBaseVNode("p", _hoisted_5, "当前版本 " + toDisplayString(updateInfo.value.currentVersion), 1),
- createVNode(_component_n_checkbox, {
- checked: noPrompt.value,
- "onUpdate:checked": _cache[0] || (_cache[0] = ($event) => noPrompt.value = $event)
- }, {
- default: withCtx(() => _cache[2] || (_cache[2] = [
- createTextVNode("不再提示")
- ])),
- _: 1
- }, 8, ["checked"])
- ])
- ]),
- createBaseVNode("div", _hoisted_6, [
- _cache[4] || (_cache[4] = createBaseVNode("div", { class: "update-title" }, "更新内容:", -1)),
- createVNode(_component_n_scrollbar, { style: { "max-height": "300px" } }, {
- default: withCtx(() => [
- createBaseVNode("div", {
- class: "update-body",
- innerHTML: parsedReleaseNotes.value
- }, null, 8, _hoisted_7)
- ]),
- _: 1
- })
- ]),
- createBaseVNode("div", _hoisted_8, [
- createVNode(_component_n_button, {
- class: "cancel-btn",
- onClick: closeModal
- }, {
- default: withCtx(() => _cache[5] || (_cache[5] = [
- createTextVNode("暂不更新")
- ])),
- _: 1
- }),
- createVNode(_component_n_button, {
- type: "primary",
- class: "update-btn",
- onClick: handleUpdate
- }, {
- default: withCtx(() => _cache[6] || (_cache[6] = [
- createTextVNode("立即更新")
- ])),
- _: 1
- })
- ]),
- _cache[7] || (_cache[7] = createBaseVNode("div", { class: "modal-desc mt-4 text-center" }, [
- createBaseVNode("p", { class: "text-xs text-gray-400" }, [
- createTextVNode(" 下载遇到问题?去 "),
- createBaseVNode("a", {
- class: "text-green-500",
- target: "_blank",
- href: "https://github.com/algerkong/AlgerMusicPlayer/releases"
- }, "GitHub"),
- createTextVNode(" 下载最新版本 ")
- ])
- ], -1))
- ])
- ]),
- _: 1
- }, 8, ["show"]);
- };
- }
-});
-const UpdateModal = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-f3abdbb7"]]);
-const _hoisted_1$1 = { class: "layout-page" };
-const _hoisted_2$1 = {
- id: "layout-main",
- class: "layout-main"
-};
-const _hoisted_3 = { class: "main" };
-const _hoisted_4 = {
- class: "main-content",
- "native-scrollbar": false
-};
-const _sfc_main$2 = /* @__PURE__ */ defineComponent({
- __name: "AppLayout",
- setup(__props) {
- const keepAliveInclude = computed(
- () => layoutRouter.filter((item) => {
- return item.meta.keepAlive;
- }).map((item) => {
- return item.name.charAt(0).toUpperCase() + item.name.slice(1);
- })
- );
- const AppMenu = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./AppMenu-CbDXL_JE.js"), true ? __vite__mapDeps([33,34]) : void 0, import.meta.url));
- const PlayBar = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./PlayBar-BNzUvTGp.js"), true ? __vite__mapDeps([35,3,4,5,6,7,20,8,18,36]) : void 0, import.meta.url));
- const SearchBar = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./SearchBar-Cx7zzS9t.js"), true ? __vite__mapDeps([37,1,38,4,5,17,31,9,10,39]) : void 0, import.meta.url));
- const TitleBar = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./TitleBar-Bl1cFyS0.js"), true ? __vite__mapDeps([40,41]) : void 0, import.meta.url));
- const store2 = useStore();
- const isPlay = computed(() => store2.state.isPlay);
- const { menus } = store2.state;
- const route = useRoute();
- onMounted(() => {
- store2.dispatch("initializeSettings");
- store2.dispatch("initializeTheme");
- });
- return (_ctx, _cache) => {
- const _component_router_view = resolveComponent("router-view");
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
- createBaseVNode("div", _hoisted_2$1, [
- unref(isElectron) ? (openBlock(), createBlock(unref(TitleBar), { key: 0 })) : createCommentVNode("", true),
- createBaseVNode("div", {
- class: normalizeClass(["layout-main-page", unref(isElectron) ? "" : "pt-6"])
- }, [
- !unref(isMobile) ? (openBlock(), createBlock(unref(AppMenu), {
- key: 0,
- class: "menu",
- menus: unref(menus)
- }, null, 8, ["menus"])) : createCommentVNode("", true),
- createBaseVNode("div", _hoisted_3, [
- createVNode(unref(SearchBar)),
- createBaseVNode("div", _hoisted_4, [
- createVNode(_component_router_view, {
- class: normalizeClass(["main-page", unref(route).meta.noScroll && !unref(isMobile) ? "pr-3" : ""])
- }, {
- default: withCtx(({ Component }) => [
- (openBlock(), createBlock(KeepAlive, { include: keepAliveInclude.value }, [
- (openBlock(), createBlock(resolveDynamicComponent(Component)))
- ], 1032, ["include"]))
- ]),
- _: 1
- }, 8, ["class"])
- ]),
- createVNode(PlayBottom, { height: "5rem" }),
- unref(isMobile) ? (openBlock(), createBlock(unref(AppMenu), {
- key: 0,
- class: "menu",
- menus: unref(menus)
- }, null, 8, ["menus"])) : createCommentVNode("", true)
- ])
- ], 2),
- isPlay.value ? (openBlock(), createBlock(unref(PlayBar), { key: 1 })) : createCommentVNode("", true)
- ]),
- createVNode(InstallAppModal),
- createVNode(UpdateModal)
- ]);
- };
- }
-});
-const AppLayout = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-f03a9852"]]);
-const loginRouter = {
- path: "/login",
- name: "login",
- mate: {
- keepAlive: true,
- title: "登录",
- icon: "icon-Home"
- },
- component: () => __vitePreload(() => import("./index-Dn0J0Jmw.js"), true ? __vite__mapDeps([42,38,43]) : void 0, import.meta.url)
-};
-const setRouter = {
- path: "/set",
- name: "set",
- mate: {
- keepAlive: true,
- title: "设置",
- icon: "icon-Home"
- },
- component: () => __vitePreload(() => import("./index-RCxsGzpS.js"), true ? __vite__mapDeps([30,31,5,10,18,32]) : void 0, import.meta.url)
-};
-const routes = [
- {
- path: "/",
- component: AppLayout,
- children: [...layoutRouter, loginRouter, setRouter]
- },
- {
- path: "/lyric",
- component: () => __vitePreload(() => import("./index-BCv4VDKm.js"), true ? __vite__mapDeps([44,45]) : void 0, import.meta.url)
- }
-];
-const router = createRouter({
- routes,
- history: createWebHashHistory()
-});
-const _sfc_main$1 = /* @__PURE__ */ defineComponent({
- __name: "App",
- setup(__props) {
- const theme = computed(() => {
- return store.state.theme;
- });
- onMounted(() => {
- store.dispatch("initializeSettings");
- store.dispatch("initializeTheme");
- if (isMobile.value) {
- store.commit(
- "setMenus",
- layoutRouter.filter((item) => item.meta.isMobile)
- );
- console.log(
- "qqq ",
- layoutRouter.filter((item) => item.meta.isMobile)
- );
- }
- });
- return (_ctx, _cache) => {
- const _component_router_view = resolveComponent("router-view");
- const _component_n_message_provider = __unplugin_components_0$1;
- const _component_n_dialog_provider = NDialogProvider;
- const _component_n_config_provider = __unplugin_components_2;
- return openBlock(), createElementBlock("div", {
- class: normalizeClass(["app-container", { mobile: unref(isMobile), noElectron: !unref(isElectron) }])
- }, [
- createVNode(_component_n_config_provider, {
- theme: unref(theme) === "dark" ? unref(darkTheme) : unref(lightTheme)
- }, {
- default: withCtx(() => [
- createVNode(_component_n_dialog_provider, null, {
- default: withCtx(() => [
- createVNode(_component_n_message_provider, null, {
- default: withCtx(() => [
- createVNode(_component_router_view)
- ]),
- _: 1
- })
- ]),
- _: 1
- })
- ]),
- _: 1
- }, 8, ["theme"])
- ], 2);
- };
- }
-});
-const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-49a312c0"]]);
-const _hoisted_1 = {
- key: 0,
- class: "loading-box"
-};
-const _hoisted_2 = { class: "loading-content-box" };
-const _sfc_main = /* @__PURE__ */ defineComponent({
- __name: "index",
- props: {
- tip: {
- type: String,
- default() {
- return "加载中...";
- }
- },
- maskBackground: {
- type: String,
- default() {
- return "rgba(0, 0, 0, 0.05)";
- }
- },
- loadingColor: {
- type: String,
- default() {
- return "rgba(255, 255, 255, 1)";
- }
- },
- textColor: {
- type: String,
- default() {
- return "rgba(255, 255, 255, 1)";
- }
- }
- },
- setup(__props, { expose: __expose }) {
- const isShow = ref(false);
- const show = () => {
- isShow.value = true;
- };
- const hide = () => {
- isShow.value = false;
- };
- __expose({
- show,
- hide,
- isShow
- });
- return (_ctx, _cache) => {
- return isShow.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
- _cache[0] || (_cache[0] = createBaseVNode("div", { class: "mask" }, null, -1)),
- createBaseVNode("div", _hoisted_2, [
- createVNode(unref(__unplugin_components_0), { size: "small" }),
- createBaseVNode("div", {
- style: normalizeStyle({ color: __props.textColor }),
- class: "tip"
- }, toDisplayString(__props.tip), 5)
- ])
- ])) : createCommentVNode("", true);
- };
- }
-});
-const Loading = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d776f97a"]]);
-const vnode = createVNode(Loading);
-const vLoading = {
- // 在绑定元素的父组件 及他自己的所有子节点都挂载完成后调用
- mounted: (el) => {
- render$2(vnode, el);
- },
- // 在绑定元素的父组件 及他自己的所有子节点都更新后调用
- updated: (el, binding) => {
- if (binding.value) {
- vnode?.component?.exposed?.show();
- } else {
- vnode?.component?.exposed?.hide();
- }
- formatterClass(el, binding);
- },
- // 绑定元素的父组件卸载后调用
- unmounted: () => {
- vnode?.component?.exposed?.hide();
- }
-};
-function formatterClass(el, binding) {
- const classStr = el.getAttribute("class");
- const tagetClass = classStr?.indexOf("loading-parent");
- if (binding.value) {
- if (tagetClass === -1) {
- el.setAttribute("class", `${classStr} loading-parent`);
- }
- } else if (tagetClass > -1) {
- const classArray = classStr?.split("");
- classArray.splice(tagetClass - 1, tagetClass + 15);
- el.setAttribute("class", classArray?.join(""));
- }
-}
-const directives = {
- loading: vLoading
-};
-const app = createApp(App);
-Object.keys(directives).forEach((key) => {
- app.directive(key, directives[key]);
-});
-app.use(router);
-app.use(store);
-app.mount("#app");
-export {
- provide as $,
- toRef as A,
- Button as B,
- useMergedState as C,
- useMemo as D,
- watch as E,
- useRtl as F,
- computed as G,
- rgba as H,
- resolveWrappedSlot as I,
- on as J,
- resolveSlot as K,
- call as L,
- nextTick as M,
- NBaseIcon as N,
- createBlock as O,
- checkUpdate as P,
- config as Q,
- isElectron as R,
- Scrollbar as S,
- createCommentVNode as T,
- PlayBottom as U,
- cNotM as V,
- cM as W,
- XButton as X,
- cE as Y,
- useStyle as Z,
- _export_sfc as _,
- onBeforeUnmount as a,
- fadeInTransition as a$,
- buttonGroupInjectionKey as a0,
- onUnmounted as a1,
- normalizeStyle as a2,
- Fragment as a3,
- renderList as a4,
- setAnimationDelay as a5,
- vShow as a6,
- getImgUrl as a7,
- watchEffect as a8,
- setBackgroundImg as a9,
- store as aA,
- getTextColors as aB,
- getHoverBackgroundColor as aC,
- animateGradient as aD,
- useDebounceFn as aE,
- useThrottleFn as aF,
- useTemplateRef as aG,
- secondToMinute as aH,
- layoutLight as aI,
- useReactivated as aJ,
- Scrollbar$1 as aK,
- createInjectionKey as aL,
- fadeInScaleUpTransition as aM,
- insideModal as aN,
- insidePopover as aO,
- onBeforeUpdate as aP,
- sliderLight as aQ,
- isMounted as aR,
- off as aS,
- clickoutside as aT,
- useLockHtmlScroll as aU,
- FocusTrap as aV,
- drawerInjectionKey as aW,
- drawerBodyInjectionKey as aX,
- popoverBodyInjectionKey as aY,
- modalBodyInjectionKey as aZ,
- commonVariables$n as a_,
- router as aa,
- resolveDirective as ab,
- isMobile as ac,
- request$1 as ad,
- audioService as ae,
- useRoute as af,
- useDateFormat as ag,
- withModifiers as ah,
- formatNumber as ai,
- __unplugin_components_0 as aj,
- Transition as ak,
- useMusicHistory as al,
- getMusicDetail as am,
- emptyLight as an,
- createKey as ao,
- useThemeClass as ap,
- onActivated as aq,
- resolveComponent as ar,
- inject as as,
- useSsrAdapter as at,
- onDeactivated as au,
- depx as av,
- pxfy as aw,
- mergeProps as ax,
- VResizeObserver as ay,
- XScrollbar as az,
- createBaseVNode as b,
- cCB as b$,
- useIsComposing as b0,
- LazyTeleport as b1,
- drawerLight as b2,
- eventEffectNotPerformed as b3,
- zindexable as b4,
- getImageBackground as b5,
- useMergedClsPrefix as b6,
- ellipsisLight as b7,
- reactive as b8,
- hasInstance as b9,
- getNative as bA,
- root as bB,
- overArg as bC,
- isPrototype as bD,
- isArrayLike as bE,
- arrayLikeKeys as bF,
- isArray$1 as bG,
- isSymbol as bH,
- MapCache as bI,
- toString$2 as bJ,
- toSource as bK,
- Map$1 as bL,
- baseGetTag as bM,
- Symbol$1 as bN,
- eq as bO,
- Uint8Array$1 as bP,
- isBuffer$1 as bQ,
- Stack as bR,
- isTypedArray$1 as bS,
- isObjectLike as bT,
- isObject$2 as bU,
- isLength as bV,
- isIndex as bW,
- isArguments as bX,
- identity as bY,
- baseFor as bZ,
- arrayMap as b_,
- onBeforeMount as ba,
- readonly as bb,
- render as bc,
- warn as bd,
- dropdownLight as be,
- keep as bf,
- renderSlot as bg,
- withKeys as bh,
- throwError as bi,
- messageApiInjectionKey as bj,
- replaceable as bk,
- iconSwitchTransition as bl,
- NIconSwitchTransition as bm,
- NBaseLoading as bn,
- resolveSlotWithProps as bo,
- inputLight as bp,
- isSafari as bq,
- getCurrentInstance as br,
- getMargin as bs,
- switchLight as bt,
- isSlotEmpty as bu,
- iconLight as bv,
- avatarLight as bw,
- color2Class as bx,
- tagLight as by,
- NBaseClose as bz,
- createElementBlock as c,
- popoverLight as c0,
- getPreciseEventTarget as c1,
- useCompitable as c2,
- getFirstSlotVNode as c3,
- cloneVNode as c4,
- Text as c5,
- isBrowser$1 as c6,
- tooltipLight as c7,
- imageLight as c8,
- isBrowser$2 as c9,
- getSlot as ca,
- getFirstVNode as cb,
- CssRender as cc,
- configProviderInjectionKey as cd,
- dialogApiInjectionKey as ce,
- defineComponent as d,
- createVNode as e,
- withCtx as f,
- useStore as g,
- useRouter as h,
- isRef as i,
- openBlock as j,
- createTextVNode as k,
- h as l,
- c as m,
- normalizeClass as n,
- onMounted as o,
- cB as p,
- useTheme as q,
- ref as r,
- setAnimationClass as s,
- toDisplayString as t,
- unref as u,
- vModelText as v,
- withDirectives as w,
- useConfig as x,
- inputNumberLight as y,
- useFormItem as z
-};
diff --git a/out/renderer/assets/index-DKaFsuse.js.gz b/out/renderer/assets/index-DKaFsuse.js.gz
deleted file mode 100644
index a85bc24..0000000
Binary files a/out/renderer/assets/index-DKaFsuse.js.gz and /dev/null differ
diff --git a/out/renderer/assets/index-DSilVM87.js b/out/renderer/assets/index-DSilVM87.js
deleted file mode 100644
index 7369825..0000000
--- a/out/renderer/assets/index-DSilVM87.js
+++ /dev/null
@@ -1,424 +0,0 @@
-import { d as defineComponent, r as ref, G as computed, a5 as setAnimationDelay, E as watch, h as useRouter, o as onMounted, j as openBlock, c as createElementBlock, b as createBaseVNode, n as normalizeClass, u as unref, s as setAnimationClass, a3 as Fragment, a4 as renderList, w as withDirectives, a6 as vShow, a2 as normalizeStyle, t as toDisplayString, _ as _export_sfc, e as createVNode, a7 as getImgUrl, T as createCommentVNode, g as useStore, a8 as watchEffect, O as createBlock, f as withCtx, a9 as setBackgroundImg, k as createTextVNode, aa as router, S as Scrollbar, ab as resolveDirective, ac as isMobile } from "./index-DKaFsuse.js";
-import { g as getPlaylistCategory, a as getNewAlbum, b as getHotSinger, c as getDayRecommend, d as getRecommendMusic } from "./home-BXGE9AqN.js";
-import { M as MusicList, g as getAlbum } from "./MusicList-s-QHu-iA.js";
-import { N as NImage } from "./Image-DXClIklC.js";
-import { S as SongItem } from "./SongItem-CoswpGn6.js";
-import { F as Favorite } from "./index-JJypdZPY.js";
-import "./Drawer-BEJ8Ydua.js";
-import "./Avatar-rQ2og-6c.js";
-import "./Tag-C0oC92WF.js";
-import "./Ellipsis-D4R5dIX2.js";
-import "./use-locale-DLWAOXez.js";
-const _hoisted_1$4 = { class: "play-list-type" };
-const _hoisted_2$3 = ["onClick"];
-const DELAY_TIME = 40;
-const _sfc_main$4 = /* @__PURE__ */ defineComponent({
- __name: "PlaylistType",
- setup(__props) {
- const playlistCategory = ref();
- const isShowAllPlaylistCategory = ref(false);
- const getAnimationDelay = computed(() => {
- return (index2) => {
- if (index2 <= 19) {
- return setAnimationDelay(index2, DELAY_TIME);
- }
- if (!isShowAllPlaylistCategory.value) {
- const nowIndex = (playlistCategory.value?.sub.length || 0) - index2;
- return setAnimationDelay(nowIndex, DELAY_TIME);
- }
- return setAnimationDelay(index2 - 19, DELAY_TIME);
- };
- });
- watch(isShowAllPlaylistCategory, (newVal) => {
- if (!newVal) {
- const elements = playlistCategory.value?.sub.map(
- (_, index2) => document.querySelector(`.type-item-${index2}`)
- );
- elements.slice(20).reverse().forEach((element, index2) => {
- if (element) {
- setTimeout(
- () => {
- element.style.position = "absolute";
- },
- index2 * DELAY_TIME + 400
- );
- }
- });
- setTimeout(
- () => {
- isHiding.value = false;
- document.querySelectorAll(".play-list-type-item").forEach((element) => {
- if (element) {
- console.log("element", element);
- element.style.position = "none";
- }
- });
- },
- (playlistCategory.value?.sub.length || 0 - 19) * DELAY_TIME
- );
- } else {
- document.querySelectorAll(".play-list-type-item").forEach((element) => {
- if (element) {
- element.style.position = "none";
- }
- });
- }
- });
- const loadPlaylistCategory = async () => {
- const { data } = await getPlaylistCategory();
- playlistCategory.value = data;
- };
- const router2 = useRouter();
- const handleClickPlaylistType = (type) => {
- router2.push({
- path: "/list",
- query: {
- type
- }
- });
- };
- const isHiding = ref(false);
- const handleToggleShowAllPlaylistCategory = () => {
- isShowAllPlaylistCategory.value = !isShowAllPlaylistCategory.value;
- if (!isShowAllPlaylistCategory.value) {
- isHiding.value = true;
- }
- };
- onMounted(() => {
- loadPlaylistCategory();
- });
- return (_ctx, _cache) => {
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
- createBaseVNode("div", {
- class: normalizeClass(["title", unref(setAnimationClass)("animate__fadeInLeft")])
- }, "歌单分类", 2),
- createBaseVNode("div", null, [
- (openBlock(true), createElementBlock(Fragment, null, renderList(playlistCategory.value?.sub, (item, index2) => {
- return withDirectives((openBlock(), createElementBlock("span", {
- key: item.name,
- class: normalizeClass([
- "play-list-type-item",
- unref(setAnimationClass)(
- index2 <= 19 ? "animate__bounceIn" : !isShowAllPlaylistCategory.value ? "animate__backOutLeft" : "animate__bounceIn"
- ) + " type-item-" + index2
- ]),
- style: normalizeStyle(getAnimationDelay.value(index2)),
- onClick: ($event) => handleClickPlaylistType(item.name)
- }, toDisplayString(item.name), 15, _hoisted_2$3)), [
- [vShow, isShowAllPlaylistCategory.value || index2 <= 19 || isHiding.value]
- ]);
- }), 128)),
- createBaseVNode("div", {
- class: normalizeClass(["play-list-type-showall", unref(setAnimationClass)("animate__bounceIn")]),
- style: normalizeStyle(
- unref(setAnimationDelay)(
- !isShowAllPlaylistCategory.value ? 25 : playlistCategory.value?.sub.length || 100 + 30
- )
- ),
- onClick: handleToggleShowAllPlaylistCategory
- }, toDisplayString(!isShowAllPlaylistCategory.value ? "显示全部" : "隐藏一些"), 7)
- ])
- ]);
- };
- }
-});
-const PlaylistType = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-686a7f41"]]);
-const _hoisted_1$3 = { class: "recommend-album" };
-const _hoisted_2$2 = { class: "recommend-album-list" };
-const _hoisted_3$1 = ["onClick"];
-const _hoisted_4$1 = { class: "recommend-album-list-item-content" };
-const _sfc_main$3 = /* @__PURE__ */ defineComponent({
- __name: "RecommendAlbum",
- setup(__props) {
- const albumData = ref();
- const loadAlbumList = async () => {
- const { data } = await getNewAlbum();
- albumData.value = data;
- };
- const showMusic = ref(false);
- const songList = ref([]);
- const albumName = ref("");
- const loadingList = ref(false);
- const albumInfo = ref({});
- const handleClick = async (item) => {
- songList.value = [];
- albumInfo.value = {};
- albumName.value = item.name;
- loadingList.value = true;
- showMusic.value = true;
- const res = await getAlbum(item.id);
- songList.value = res.data.songs.map((song) => {
- song.al.picUrl = song.al.picUrl || item.picUrl;
- return song;
- });
- albumInfo.value = {
- ...res.data.album,
- creator: {
- avatarUrl: res.data.album.artist.img1v1Url,
- nickname: `${res.data.album.artist.name} - ${res.data.album.company}`
- },
- description: res.data.album.description
- };
- loadingList.value = false;
- };
- onMounted(() => {
- loadAlbumList();
- });
- return (_ctx, _cache) => {
- const _component_n_image = NImage;
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
- createBaseVNode("div", {
- class: normalizeClass(["title", unref(setAnimationClass)("animate__fadeInRight")])
- }, "最新专辑", 2),
- createBaseVNode("div", _hoisted_2$2, [
- (openBlock(true), createElementBlock(Fragment, null, renderList(albumData.value?.albums, (item, index2) => {
- return openBlock(), createElementBlock(Fragment, {
- key: item.id
- }, [
- index2 < 6 ? (openBlock(), createElementBlock("div", {
- key: 0,
- class: normalizeClass(["recommend-album-list-item", unref(setAnimationClass)("animate__backInUp")]),
- style: normalizeStyle(unref(setAnimationDelay)(index2, 100)),
- onClick: ($event) => handleClick(item)
- }, [
- createVNode(_component_n_image, {
- class: "recommend-album-list-item-img",
- src: unref(getImgUrl)(item.blurPicUrl, "200y200"),
- lazy: "",
- "preview-disabled": ""
- }, null, 8, ["src"]),
- createBaseVNode("div", _hoisted_4$1, toDisplayString(item.name), 1)
- ], 14, _hoisted_3$1)) : createCommentVNode("", true)
- ], 64);
- }), 128))
- ]),
- createVNode(MusicList, {
- show: showMusic.value,
- "onUpdate:show": _cache[0] || (_cache[0] = ($event) => showMusic.value = $event),
- name: albumName.value,
- "song-list": songList.value,
- cover: false,
- loading: loadingList.value,
- "list-info": albumInfo.value
- }, null, 8, ["show", "name", "song-list", "loading", "list-info"])
- ]);
- };
- }
-});
-const RecommendAlbum = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-1df7dbee"]]);
-const _hoisted_1$2 = { class: "recommend-singer" };
-const _hoisted_2$1 = { class: "recommend-singer-list" };
-const _hoisted_3 = { class: "mt-2" };
-const _hoisted_4 = { class: "recommend-singer-item-count p-2 text-base text-gray-200 z-10" };
-const _hoisted_5 = { class: "recommend-singer-item-info z-10" };
-const _hoisted_6 = ["onClick"];
-const _hoisted_7 = { class: "ml-4" };
-const _hoisted_8 = { class: "recommend-singer-item-info-name text-el" };
-const _hoisted_9 = { class: "recommend-singer-item-info-name text-el" };
-const _sfc_main$2 = /* @__PURE__ */ defineComponent({
- __name: "RecommendSinger",
- setup(__props) {
- const store = useStore();
- const hotSingerData = ref();
- const dayRecommendData = ref();
- const showMusic = ref(false);
- onMounted(async () => {
- await loadData();
- });
- const loadData = async () => {
- try {
- const { data: singerData } = await getHotSinger({ offset: 0, limit: 5 });
- try {
- const {
- data: { data: dayRecommend }
- } = await getDayRecommend();
- if (dayRecommend) {
- singerData.artists = singerData.artists.slice(0, 4);
- }
- dayRecommendData.value = dayRecommend;
- } catch (error) {
- console.error("error", error);
- }
- hotSingerData.value = singerData;
- } catch (error) {
- console.error("error", error);
- }
- };
- const toSearchSinger = (keyword) => {
- router.push({
- path: "/search",
- query: {
- keyword
- }
- });
- };
- watchEffect(() => {
- if (store.state.user) {
- loadData();
- }
- });
- return (_ctx, _cache) => {
- const _component_n_scrollbar = Scrollbar;
- return openBlock(), createBlock(_component_n_scrollbar, {
- size: 100,
- "x-scrollable": true
- }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_1$2, [
- createBaseVNode("div", _hoisted_2$1, [
- dayRecommendData.value ? (openBlock(), createElementBlock("div", {
- key: 0,
- class: normalizeClass(["recommend-singer-item relative", unref(setAnimationClass)("animate__backInRight")]),
- style: normalizeStyle(unref(setAnimationDelay)(0, 100))
- }, [
- createBaseVNode("div", {
- style: normalizeStyle(
- unref(setBackgroundImg)(unref(getImgUrl)(dayRecommendData.value?.dailySongs[0].al.picUrl, "500y500"))
- ),
- class: "recommend-singer-item-bg"
- }, null, 4),
- createBaseVNode("div", {
- class: "recommend-singer-item-count p-2 text-base text-gray-200 z-10 cursor-pointer",
- onClick: _cache[0] || (_cache[0] = ($event) => showMusic.value = true)
- }, [
- _cache[3] || (_cache[3] = createBaseVNode("div", { class: "font-bold text-xl" }, "每日推荐", -1)),
- createBaseVNode("div", _hoisted_3, [
- (openBlock(true), createElementBlock(Fragment, null, renderList(dayRecommendData.value?.dailySongs.slice(0, 5), (item) => {
- return openBlock(), createElementBlock("p", {
- key: item.id,
- class: "text-el"
- }, [
- createTextVNode(toDisplayString(item.name) + " ", 1),
- _cache[2] || (_cache[2] = createBaseVNode("br", null, null, -1))
- ]);
- }), 128))
- ])
- ])
- ], 6)) : createCommentVNode("", true),
- (openBlock(true), createElementBlock(Fragment, null, renderList(hotSingerData.value?.artists, (item, index2) => {
- return openBlock(), createElementBlock("div", {
- key: item.id,
- class: normalizeClass(["recommend-singer-item relative", unref(setAnimationClass)("animate__backInRight")]),
- style: normalizeStyle(unref(setAnimationDelay)(index2 + 1, 100))
- }, [
- createBaseVNode("div", {
- style: normalizeStyle(unref(setBackgroundImg)(unref(getImgUrl)(item.picUrl, "500y500"))),
- class: "recommend-singer-item-bg"
- }, null, 4),
- createBaseVNode("div", _hoisted_4, toDisplayString(item.musicSize) + "首 ", 1),
- createBaseVNode("div", _hoisted_5, [
- createBaseVNode("div", {
- class: "recommend-singer-item-info-play",
- onClick: ($event) => toSearchSinger(item.name)
- }, _cache[4] || (_cache[4] = [
- createBaseVNode("i", { class: "iconfont icon-playfill text-xl" }, null, -1)
- ]), 8, _hoisted_6),
- createBaseVNode("div", _hoisted_7, [
- createBaseVNode("div", _hoisted_8, toDisplayString(item.name), 1),
- createBaseVNode("div", _hoisted_9, toDisplayString(item.name), 1)
- ])
- ])
- ], 6);
- }), 128))
- ]),
- dayRecommendData.value?.dailySongs.length ? (openBlock(), createBlock(MusicList, {
- key: 0,
- show: showMusic.value,
- "onUpdate:show": _cache[1] || (_cache[1] = ($event) => showMusic.value = $event),
- name: "每日推荐列表",
- "song-list": dayRecommendData.value?.dailySongs,
- cover: false
- }, null, 8, ["show", "song-list"])) : createCommentVNode("", true)
- ])
- ]),
- _: 1
- });
- };
- }
-});
-const RecommendSinger = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-f8da161d"]]);
-const _hoisted_1$1 = { class: "recommend-music" };
-const _sfc_main$1 = /* @__PURE__ */ defineComponent({
- __name: "RecommendSonglist",
- setup(__props) {
- const store = useStore();
- const recommendMusic = ref();
- const loading = ref(false);
- const loadRecommendMusic = async () => {
- loading.value = true;
- const { data } = await getRecommendMusic({ limit: 10 });
- recommendMusic.value = data;
- loading.value = false;
- };
- onMounted(() => {
- loadRecommendMusic();
- });
- const handlePlay = () => {
- store.commit("setPlayList", recommendMusic.value?.result);
- };
- return (_ctx, _cache) => {
- const _directive_loading = resolveDirective("loading");
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
- createBaseVNode("div", {
- class: normalizeClass(["title", unref(setAnimationClass)("animate__fadeInLeft")])
- }, "本周最热音乐", 2),
- withDirectives((openBlock(), createElementBlock("div", {
- class: normalizeClass(["recommend-music-list", unref(setAnimationClass)("animate__bounceInUp")])
- }, [
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(recommendMusic)?.result, (item, index2) => {
- return openBlock(), createElementBlock("div", {
- key: item.id,
- class: normalizeClass(unref(setAnimationClass)("animate__bounceInUp")),
- style: normalizeStyle(unref(setAnimationDelay)(index2, 100))
- }, [
- createVNode(SongItem, {
- item,
- onPlay: handlePlay
- }, null, 8, ["item"])
- ], 6);
- }), 128))
- ], 2)), [
- [vShow, unref(recommendMusic)?.result],
- [_directive_loading, unref(loading)]
- ])
- ]);
- };
- }
-});
-const RecommendSonglist = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-ae2da107"]]);
-const _hoisted_1 = { class: "main-page" };
-const _hoisted_2 = { class: "main-content" };
-const _sfc_main = /* @__PURE__ */ defineComponent({
- ...{
- name: "Home"
- },
- __name: "index",
- setup(__props) {
- return (_ctx, _cache) => {
- const _component_n_scrollbar = Scrollbar;
- return openBlock(), createBlock(_component_n_scrollbar, {
- size: 100,
- "x-scrollable": false
- }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_1, [
- createVNode(RecommendSinger),
- createBaseVNode("div", _hoisted_2, [
- !unref(isMobile) ? (openBlock(), createBlock(PlaylistType, { key: 0 })) : createCommentVNode("", true),
- createVNode(RecommendSonglist),
- createBaseVNode("div", null, [
- createVNode(Favorite, { "is-component": "" }),
- createVNode(RecommendAlbum)
- ])
- ])
- ])
- ]),
- _: 1
- });
- };
- }
-});
-const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b0ca1b97"]]);
-export {
- index as default
-};
diff --git a/out/renderer/assets/index-DSilVM87.js.gz b/out/renderer/assets/index-DSilVM87.js.gz
deleted file mode 100644
index 418d6f5..0000000
Binary files a/out/renderer/assets/index-DSilVM87.js.gz and /dev/null differ
diff --git a/out/renderer/assets/index-DVDStqOk.css b/out/renderer/assets/index-DVDStqOk.css
deleted file mode 100644
index 9ad6dea..0000000
--- a/out/renderer/assets/index-DVDStqOk.css
+++ /dev/null
@@ -1,120 +0,0 @@
-.set-page[data-v-0331ad9e] {
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
-
- padding: 1rem
-}
-.set-page[data-v-0331ad9e]:is(.dark *) {
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1))
-}
-.set-item[data-v-0331ad9e] {
-
- margin-bottom: 1rem;
-
- display: flex;
-
- align-items: center;
-
- justify-content: space-between;
-
- border-radius: 0.5rem;
-
- padding: 1rem;
-
- transition-property: all;
-
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
-
- transition-duration: 150ms;
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
-
- --tw-text-opacity: 1;
-
- color: rgb(17 24 39 / var(--tw-text-opacity, 1))
-}
-.set-item[data-v-0331ad9e]:is(.dark *) {
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
-
- --tw-text-opacity: 1;
-
- color: rgb(255 255 255 / var(--tw-text-opacity, 1))
-}
-.set-item[data-v-0331ad9e] {
-
- border-width: 1px;
-
- --tw-border-opacity: 1;
-
- border-color: rgb(229 231 235 / var(--tw-border-opacity, 1))
-}
-.set-item[data-v-0331ad9e]:is(.dark *) {
-
- --tw-border-opacity: 1;
-
- border-color: rgb(55 65 81 / var(--tw-border-opacity, 1))
-}
-.set-item-title[data-v-0331ad9e] {
-
- margin-bottom: 0.25rem;
-
- font-size: 1rem;
-
- line-height: 1.5rem;
-
- font-weight: 500
-}
-.set-item-content[data-v-0331ad9e] {
-
- font-size: 0.875rem;
-
- line-height: 1.25rem;
-
- --tw-text-opacity: 1;
-
- color: rgb(107 114 128 / var(--tw-text-opacity, 1))
-}
-.set-item-content[data-v-0331ad9e]:is(.dark *) {
-
- --tw-text-opacity: 1;
-
- color: rgb(156 163 175 / var(--tw-text-opacity, 1))
-}
-.set-item[data-v-0331ad9e]:hover {
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1))
-}
-.set-item[data-v-0331ad9e]:hover:is(.dark *) {
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1))
-}
-.set-item.cursor-pointer[data-v-0331ad9e]:hover {
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(240 253 244 / var(--tw-bg-opacity, 1));
-
- --tw-text-opacity: 1;
-
- color: rgb(34 197 94 / var(--tw-text-opacity, 1))
-}
-.set-item.cursor-pointer[data-v-0331ad9e]:hover:is(.dark *) {
-
- --tw-bg-opacity: 1;
-
- background-color: rgb(20 83 45 / var(--tw-bg-opacity, 1))
-}
\ No newline at end of file
diff --git a/out/renderer/assets/index-DVDStqOk.css.gz b/out/renderer/assets/index-DVDStqOk.css.gz
deleted file mode 100644
index e705153..0000000
Binary files a/out/renderer/assets/index-DVDStqOk.css.gz and /dev/null differ
diff --git a/out/renderer/assets/index-DcmHQdN6.css b/out/renderer/assets/index-DcmHQdN6.css
deleted file mode 100644
index de2bad0..0000000
--- a/out/renderer/assets/index-DcmHQdN6.css
+++ /dev/null
@@ -1,189 +0,0 @@
-.login-page[data-v-baab8304] {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 5rem;
- padding-top: 5rem;
- --tw-bg-opacity: 1;
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
-}.login-page[data-v-baab8304]:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
-}
-.login-title[data-v-baab8304] {
- margin-bottom: 1.5rem;
- font-size: 1.5rem;
- line-height: 2rem;
- font-weight: 700;
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.text[data-v-baab8304] {
- margin-top: 1rem;
- font-size: 0.75rem;
- line-height: 1rem;
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.phone-login[data-v-baab8304] {
- width: 350px;
- height: 550px;
- position: relative;
- overflow: hidden;
- border-radius: 1rem;
- border-bottom-right-radius: 0px;
- border-bottom-left-radius: 0px;
- background-size: cover;
- background-repeat: no-repeat;
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' version='1.1' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:svgjs='http://svgjs.dev/svgjs' width='400' height='560' preserveAspectRatio='none' viewBox='0 0 400 560'%3e%3cg mask='url(%26quot%3b%23SvgjsMask1066%26quot%3b)' fill='none'%3e%3crect width='400' height='560' x='0' y='0' fill='rgba(24%2c 106%2c 59%2c 1)'%3e%3c/rect%3e%3cpath d='M0%2c234.738C43.535%2c236.921%2c80.103%2c205.252%2c116.272%2c180.923C151.738%2c157.067%2c188.295%2c132.929%2c207.855%2c94.924C227.898%2c55.979%2c233.386%2c10.682%2c226.119%2c-32.511C218.952%2c-75.107%2c199.189%2c-115.793%2c167.469%2c-145.113C137.399%2c-172.909%2c92.499%2c-171.842%2c55.779%2c-189.967C8.719%2c-213.196%2c-28.344%2c-282.721%2c-78.217%2c-266.382C-128.725%2c-249.834%2c-111.35%2c-166.696%2c-143.781%2c-124.587C-173.232%2c-86.348%2c-244.72%2c-83.812%2c-255.129%2c-36.682C-265.368%2c9.678%2c-217.952%2c48.26%2c-190.512%2c87.004C-167.691%2c119.226%2c-140.216%2c145.431%2c-109.013%2c169.627C-74.874%2c196.1%2c-43.147%2c232.575%2c0%2c234.738' fill='%23114b2a'%3e%3c/path%3e%3cpath d='M400 800.9010000000001C443.973 795.023 480.102 765.6 513.011 735.848 541.923 709.71 561.585 676.6320000000001 577.037 640.85 592.211 605.712 606.958 568.912 601.458 531.035 595.962 493.182 568.394 464.36400000000003 546.825 432.775 522.317 396.88300000000004 507.656 347.475 466.528 333.426 425.366 319.366 384.338 352.414 342.111 362.847 297.497 373.869 242.385 362.645 211.294 396.486 180.212 430.318 192.333 483.83299999999997 188.872 529.644 185.656 572.218 178.696 614.453 191.757 655.101 205.885 699.068 227.92 742.4110000000001 265.75 768.898 304.214 795.829 353.459 807.1220000000001 400 800.9010000000001' fill='%231f894c'%3e%3c/path%3e%3c/g%3e%3cdefs%3e%3cmask id='SvgjsMask1066'%3e%3crect width='400' height='560' fill='white'%3e%3c/rect%3e%3c/mask%3e%3c/defs%3e%3c/svg%3e");
- box-shadow: inset 0px 0px 20px 5px rgba(0, 0, 0, 0.37);
-}
-.phone-login .bg[data-v-baab8304] {
- position: absolute;
- height: 100%;
- width: 100%;
- --tw-bg-opacity: 1;
- background-color: rgb(248 249 250 / var(--tw-bg-opacity, 1));
- opacity: 0.2;
-}
-.phone-login .bg[data-v-baab8304]:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(22 22 22 / var(--tw-bg-opacity, 1));
-}
-.phone-login .bottom[data-v-baab8304] {
- width: 200%;
- height: 250px;
- bottom: -180px;
- border-radius: 50%;
- left: 50%;
- padding: 10px;
- transform: translateX(-50%);
- position: absolute;
- display: flex;
- cursor: pointer;
- justify-content: center;
- --tw-bg-opacity: 1;
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
- font-size: 1.125rem;
- line-height: 1.75rem;
- font-weight: 700;
-}
-.phone-login .bottom[data-v-baab8304]:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
-}
-.phone-login .bottom[data-v-baab8304] {
- --tw-text-opacity: 1;
- color: rgb(156 163 175 / var(--tw-text-opacity, 1));
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- transition-duration: 150ms;
-}
-.phone-login .bottom[data-v-baab8304]:hover {
- --tw-text-opacity: 1;
- color: rgb(31 41 55 / var(--tw-text-opacity, 1));
-}
-.phone-login .bottom[data-v-baab8304]:is(.dark *):hover {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.phone-login .bottom[data-v-baab8304] {
- box-shadow: 10px 0px 20px rgba(0, 0, 0, 0.66);
-}
-.phone-login .content[data-v-baab8304] {
- position: absolute;
- display: flex;
- height: 100%;
- width: 100%;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 1rem;
- padding-bottom: 5rem;
- text-align: center;
-}
-.phone-login .content .qr-img[data-v-baab8304] {
- cursor: pointer;
- border-radius: 1rem;
- transition-property: opacity;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- transition-duration: 150ms;
-}
-.phone-login .content .phone[data-v-baab8304] {
- animation-duration: 0.5s;
-}
-.phone-login .content .phone-page[data-v-baab8304] {
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
- --tw-bg-opacity: 0.9;
-}
-.phone-login .content .phone-page[data-v-baab8304]:is(.dark *) {
- background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
- --tw-bg-opacity: 0.9;
-}
-.phone-login .content .phone-page[data-v-baab8304] {
- width: 250px;
- overflow: hidden;
- border-radius: 1rem;
-}
-.phone-login .content .phone-input[data-v-baab8304] {
- height: 40px;
- width: 100%;
- padding-left: 1rem;
- padding-right: 1rem;
- outline: 2px solid transparent;
- outline-offset: 2px;
- background-color: transparent;
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304] {
- border-bottom-width: 1px;
- --tw-border-opacity: 1;
- border-color: rgb(229 231 235 / var(--tw-border-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304]:is(.dark *) {
- --tw-border-opacity: 1;
- border-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304]::-moz-placeholder {
- --tw-placeholder-opacity: 1;
- color: rgb(107 114 128 / var(--tw-placeholder-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304]::placeholder {
- --tw-placeholder-opacity: 1;
- color: rgb(107 114 128 / var(--tw-placeholder-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304]:is(.dark *)::-moz-placeholder {
- --tw-placeholder-opacity: 1;
- color: rgb(156 163 175 / var(--tw-placeholder-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304]:is(.dark *)::placeholder {
- --tw-placeholder-opacity: 1;
- color: rgb(156 163 175 / var(--tw-placeholder-opacity, 1));
-}
-.phone-login .content .phone-input[data-v-baab8304]:focus {
- --tw-border-opacity: 1;
- border-color: rgb(34 197 94 / var(--tw-border-opacity, 1));
-}
-.phone-login .content .btn-login[data-v-baab8304] {
- width: 250px;
- height: 40px;
- margin-top: 2.5rem;
- border-radius: 0.75rem;
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
- --tw-bg-opacity: 1;
- background-color: rgb(22 163 74 / var(--tw-bg-opacity, 1));
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- transition-duration: 150ms;
-}
-.phone-login .content .btn-login[data-v-baab8304]:hover {
- --tw-bg-opacity: 1;
- background-color: rgb(21 128 61 / var(--tw-bg-opacity, 1));
-}
\ No newline at end of file
diff --git a/out/renderer/assets/index-DcmHQdN6.css.gz b/out/renderer/assets/index-DcmHQdN6.css.gz
deleted file mode 100644
index 2d08a0f..0000000
Binary files a/out/renderer/assets/index-DcmHQdN6.css.gz and /dev/null differ
diff --git a/out/renderer/assets/index-DhLgZEXT.js b/out/renderer/assets/index-DhLgZEXT.js
deleted file mode 100644
index 5318c50..0000000
--- a/out/renderer/assets/index-DhLgZEXT.js
+++ /dev/null
@@ -1,151 +0,0 @@
-import { F as Favorite } from "./index-JJypdZPY.js";
-import { d as defineComponent, al as useMusicHistory, r as ref, o as onMounted, c as createElementBlock, b as createBaseVNode, n as normalizeClass, u as unref, e as createVNode, f as withCtx, am as getMusicDetail, S as Scrollbar, g as useStore, j as openBlock, s as setAnimationClass, a3 as Fragment, a4 as renderList, a2 as normalizeStyle, a5 as setAnimationDelay, t as toDisplayString, T as createCommentVNode, aj as __unplugin_components_0, _ as _export_sfc } from "./index-DKaFsuse.js";
-import { S as SongItem } from "./SongItem-CoswpGn6.js";
-import "./use-locale-DLWAOXez.js";
-import "./Image-DXClIklC.js";
-import "./Ellipsis-D4R5dIX2.js";
-const _hoisted_1$1 = { class: "history-page" };
-const _hoisted_2 = { class: "history-item-count min-w-[60px]" };
-const _hoisted_3 = { class: "history-item-delete" };
-const _hoisted_4 = ["onClick"];
-const _hoisted_5 = {
- key: 0,
- class: "loading-wrapper"
-};
-const _hoisted_6 = {
- key: 1,
- class: "no-more-tip"
-};
-const pageSize = 20;
-const _sfc_main$1 = /* @__PURE__ */ defineComponent({
- ...{
- name: "History"
- },
- __name: "index",
- setup(__props) {
- const store = useStore();
- const { delMusic, musicList } = useMusicHistory();
- const scrollbarRef = ref();
- const loading = ref(false);
- const noMore = ref(false);
- const displayList = ref([]);
- const currentPage = ref(1);
- const getHistorySongs = async () => {
- if (musicList.value.length === 0) {
- displayList.value = [];
- return;
- }
- loading.value = true;
- try {
- const startIndex = (currentPage.value - 1) * pageSize;
- const endIndex = startIndex + pageSize;
- const currentPageItems = musicList.value.slice(startIndex, endIndex);
- const currentIds = currentPageItems.map((item) => item.id);
- const res = await getMusicDetail(currentIds);
- if (res.data.songs) {
- const newSongs = res.data.songs.map((song) => {
- const historyItem = currentPageItems.find((item) => item.id === song.id);
- return {
- ...song,
- picUrl: song.al?.picUrl || "",
- count: historyItem?.count || 0
- };
- });
- if (currentPage.value === 1) {
- displayList.value = newSongs;
- } else {
- displayList.value = [...displayList.value, ...newSongs];
- }
- noMore.value = displayList.value.length >= musicList.value.length;
- }
- } catch (error) {
- console.error("获取历史记录失败:", error);
- } finally {
- loading.value = false;
- }
- };
- const handleScroll = (e) => {
- const { scrollTop, scrollHeight, offsetHeight } = e.target;
- const threshold = 100;
- if (!loading.value && !noMore.value && scrollHeight - (scrollTop + offsetHeight) < threshold) {
- currentPage.value++;
- getHistorySongs();
- }
- };
- const handlePlay = () => {
- store.commit("setPlayList", displayList.value);
- };
- onMounted(() => {
- getHistorySongs();
- });
- const handleDelMusic = async (item) => {
- delMusic(item);
- musicList.value = musicList.value.filter((music) => music.id !== item.id);
- displayList.value = displayList.value.filter((music) => music.id !== item.id);
- };
- return (_ctx, _cache) => {
- const _component_n_spin = __unplugin_components_0;
- const _component_n_scrollbar = Scrollbar;
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
- createBaseVNode("div", {
- class: normalizeClass(["title", unref(setAnimationClass)("animate__fadeInRight")])
- }, "播放历史", 2),
- createVNode(_component_n_scrollbar, {
- ref_key: "scrollbarRef",
- ref: scrollbarRef,
- size: 100,
- onScroll: handleScroll
- }, {
- default: withCtx(() => [
- createBaseVNode("div", {
- class: normalizeClass(["history-list-content", unref(setAnimationClass)("animate__bounceInLeft")])
- }, [
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayList.value, (item, index2) => {
- return openBlock(), createElementBlock("div", {
- key: item.id,
- class: normalizeClass(["history-item", unref(setAnimationClass)("animate__bounceInRight")]),
- style: normalizeStyle(unref(setAnimationDelay)(index2, 30))
- }, [
- createVNode(SongItem, {
- class: "history-item-content",
- item,
- onPlay: handlePlay
- }, null, 8, ["item"]),
- createBaseVNode("div", _hoisted_2, toDisplayString(item.count), 1),
- createBaseVNode("div", _hoisted_3, [
- createBaseVNode("i", {
- class: "iconfont icon-close",
- onClick: ($event) => handleDelMusic(item)
- }, null, 8, _hoisted_4)
- ])
- ], 6);
- }), 128)),
- loading.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
- createVNode(_component_n_spin, { size: "large" })
- ])) : createCommentVNode("", true),
- noMore.value ? (openBlock(), createElementBlock("div", _hoisted_6, "没有更多了")) : createCommentVNode("", true)
- ], 2)
- ]),
- _: 1
- }, 512)
- ]);
- };
- }
-});
-const History = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-7e434221"]]);
-const _hoisted_1 = { class: "flex gap-4 h-full pb-4" };
-const _sfc_main = /* @__PURE__ */ defineComponent({
- __name: "index",
- setup(__props) {
- return (_ctx, _cache) => {
- return openBlock(), createElementBlock("div", _hoisted_1, [
- createVNode(Favorite, { class: "flex-item" }),
- createVNode(History, { class: "flex-item" })
- ]);
- };
- }
-});
-const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-36d023b3"]]);
-export {
- index as default
-};
diff --git a/out/renderer/assets/index-DhLgZEXT.js.gz b/out/renderer/assets/index-DhLgZEXT.js.gz
deleted file mode 100644
index 44989b0..0000000
Binary files a/out/renderer/assets/index-DhLgZEXT.js.gz and /dev/null differ
diff --git a/out/renderer/assets/index-Dn0J0Jmw.js b/out/renderer/assets/index-Dn0J0Jmw.js
deleted file mode 100644
index 86a88be..0000000
--- a/out/renderer/assets/index-Dn0J0Jmw.js
+++ /dev/null
@@ -1,155 +0,0 @@
-import { d as defineComponent, r as ref, o as onMounted, a as onBeforeUnmount, c as createElementBlock, b as createBaseVNode, u as unref, n as normalizeClass, w as withDirectives, v as vModelText, i as isRef, e as createVNode, f as withCtx, t as toDisplayString, g as useStore, h as useRouter, B as Button, j as openBlock, s as setAnimationClass, k as createTextVNode, _ as _export_sfc } from "./index-DKaFsuse.js";
-import { u as useMessage, g as getQrKey, c as createQr, a as checkQr, b as getUserDetail, l as loginByCellphone } from "./login-BsPxQYi6.js";
-const _hoisted_1 = { class: "login-page" };
-const _hoisted_2 = { class: "phone-login" };
-const _hoisted_3 = { class: "content" };
-const _hoisted_4 = ["src"];
-const _hoisted_5 = { class: "phone-page" };
-const _hoisted_6 = { class: "bottom" };
-const _sfc_main = /* @__PURE__ */ defineComponent({
- ...{
- name: "Login"
- },
- __name: "index",
- setup(__props) {
- const message = useMessage();
- const store = useStore();
- const router = useRouter();
- const isQr = ref(false);
- const qrUrl = ref();
- onMounted(() => {
- loadLogin();
- });
- const timerRef = ref(null);
- const loadLogin = async () => {
- try {
- if (timerRef.value) {
- clearInterval(timerRef.value);
- timerRef.value = null;
- }
- if (!isQr.value) return;
- const qrKey = await getQrKey();
- const key = qrKey.data.data.unikey;
- const { data } = await createQr(key);
- qrUrl.value = data.data.qrimg;
- const timer = timerIsQr(key);
- timerRef.value = timer;
- } catch (error) {
- console.error("加载登录信息时出错:", error);
- }
- };
- const timerIsQr = (key) => {
- const timer = setInterval(async () => {
- try {
- const { data } = await checkQr(key);
- if (data.code === 800) {
- clearInterval(timer);
- timerRef.value = null;
- }
- if (data.code === 803) {
- localStorage.setItem("token", data.cookie);
- const user = await getUserDetail();
- store.state.user = user.data.profile;
- localStorage.setItem("user", JSON.stringify(store.state.user));
- message.success("登录成功");
- clearInterval(timer);
- timerRef.value = null;
- router.push("/user");
- }
- } catch (error) {
- console.error("检查二维码状态时出错:", error);
- clearInterval(timer);
- timerRef.value = null;
- }
- }, 3e3);
- return timer;
- };
- onBeforeUnmount(() => {
- if (timerRef.value) {
- clearInterval(timerRef.value);
- timerRef.value = null;
- }
- });
- const chooseQr = () => {
- isQr.value = !isQr.value;
- loadLogin();
- };
- const phone = ref("");
- const password = ref("");
- const loginPhone = async () => {
- const { data } = await loginByCellphone(phone.value, password.value);
- if (data.code === 200) {
- message.success("登录成功");
- store.state.user = data.profile;
- localStorage.setItem("token", data.cookie);
- setTimeout(() => {
- router.push("/user");
- }, 1e3);
- }
- };
- return (_ctx, _cache) => {
- const _component_n_button = Button;
- return openBlock(), createElementBlock("div", _hoisted_1, [
- createBaseVNode("div", _hoisted_2, [
- _cache[9] || (_cache[9] = createBaseVNode("div", { class: "bg" }, null, -1)),
- createBaseVNode("div", _hoisted_3, [
- unref(isQr) ? (openBlock(), createElementBlock("div", {
- key: 0,
- class: normalizeClass(["phone", unref(setAnimationClass)("animate__fadeInUp")])
- }, [
- _cache[4] || (_cache[4] = createBaseVNode("div", { class: "login-title" }, "扫码登陆", -1)),
- createBaseVNode("img", {
- class: "qr-img",
- src: unref(qrUrl)
- }, null, 8, _hoisted_4),
- _cache[5] || (_cache[5] = createBaseVNode("div", { class: "text" }, "使用网易云APP扫码登录", -1))
- ], 2)) : (openBlock(), createElementBlock("div", {
- key: 1,
- class: normalizeClass(["phone", unref(setAnimationClass)("animate__fadeInUp")])
- }, [
- _cache[7] || (_cache[7] = createBaseVNode("div", { class: "login-title" }, "手机号登录", -1)),
- createBaseVNode("div", _hoisted_5, [
- withDirectives(createBaseVNode("input", {
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(phone) ? phone.value = $event : null),
- class: "phone-input",
- type: "text",
- placeholder: "手机号"
- }, null, 512), [
- [vModelText, unref(phone)]
- ]),
- withDirectives(createBaseVNode("input", {
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(password) ? password.value = $event : null),
- class: "phone-input",
- type: "password",
- placeholder: "密码"
- }, null, 512), [
- [vModelText, unref(password)]
- ])
- ]),
- _cache[8] || (_cache[8] = createBaseVNode("div", { class: "text" }, "使用网易云账号登录", -1)),
- createVNode(_component_n_button, {
- class: "btn-login",
- onClick: _cache[2] || (_cache[2] = ($event) => loginPhone())
- }, {
- default: withCtx(() => _cache[6] || (_cache[6] = [
- createTextVNode("登录")
- ])),
- _: 1
- })
- ], 2))
- ]),
- createBaseVNode("div", _hoisted_6, [
- createBaseVNode("div", {
- class: "title",
- onClick: _cache[3] || (_cache[3] = ($event) => chooseQr())
- }, toDisplayString(unref(isQr) ? "手机号登录" : "扫码登录"), 1)
- ])
- ])
- ]);
- };
- }
-});
-const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-baab8304"]]);
-export {
- index as default
-};
diff --git a/out/renderer/assets/index-Dn0J0Jmw.js.gz b/out/renderer/assets/index-Dn0J0Jmw.js.gz
deleted file mode 100644
index 0f7a1c1..0000000
Binary files a/out/renderer/assets/index-Dn0J0Jmw.js.gz and /dev/null differ
diff --git a/out/renderer/assets/index-JJypdZPY.js b/out/renderer/assets/index-JJypdZPY.js
deleted file mode 100644
index a863787..0000000
--- a/out/renderer/assets/index-JJypdZPY.js
+++ /dev/null
@@ -1,320 +0,0 @@
-import { d as defineComponent, l as h, p as cB, Y as cE, m as c, q as useTheme, x as useConfig, an as emptyLight, G as computed, ao as createKey, ap as useThemeClass, N as NBaseIcon, r as ref, o as onMounted, E as watch, c as createElementBlock, b as createBaseVNode, t as toDisplayString, n as normalizeClass, u as unref, e as createVNode, f as withCtx, T as createCommentVNode, am as getMusicDetail, S as Scrollbar, g as useStore, h as useRouter, j as openBlock, s as setAnimationClass, a3 as Fragment, a4 as renderList, O as createBlock, a2 as normalizeStyle, k as createTextVNode, a5 as setAnimationDelay, B as Button, aj as __unplugin_components_0$1, _ as _export_sfc } from "./index-DKaFsuse.js";
-import { S as SongItem } from "./SongItem-CoswpGn6.js";
-import { u as useLocale } from "./use-locale-DLWAOXez.js";
-const EmptyIcon = defineComponent({
- name: "Empty",
- render() {
- return h("svg", {
- viewBox: "0 0 28 28",
- fill: "none",
- xmlns: "http://www.w3.org/2000/svg"
- }, h("path", {
- d: "M26 7.5C26 11.0899 23.0899 14 19.5 14C15.9101 14 13 11.0899 13 7.5C13 3.91015 15.9101 1 19.5 1C23.0899 1 26 3.91015 26 7.5ZM16.8536 4.14645C16.6583 3.95118 16.3417 3.95118 16.1464 4.14645C15.9512 4.34171 15.9512 4.65829 16.1464 4.85355L18.7929 7.5L16.1464 10.1464C15.9512 10.3417 15.9512 10.6583 16.1464 10.8536C16.3417 11.0488 16.6583 11.0488 16.8536 10.8536L19.5 8.20711L22.1464 10.8536C22.3417 11.0488 22.6583 11.0488 22.8536 10.8536C23.0488 10.6583 23.0488 10.3417 22.8536 10.1464L20.2071 7.5L22.8536 4.85355C23.0488 4.65829 23.0488 4.34171 22.8536 4.14645C22.6583 3.95118 22.3417 3.95118 22.1464 4.14645L19.5 6.79289L16.8536 4.14645Z",
- fill: "currentColor"
- }), h("path", {
- d: "M25 22.75V12.5991C24.5572 13.0765 24.053 13.4961 23.5 13.8454V16H17.5L17.3982 16.0068C17.0322 16.0565 16.75 16.3703 16.75 16.75C16.75 18.2688 15.5188 19.5 14 19.5C12.4812 19.5 11.25 18.2688 11.25 16.75L11.2432 16.6482C11.1935 16.2822 10.8797 16 10.5 16H4.5V7.25C4.5 6.2835 5.2835 5.5 6.25 5.5H12.2696C12.4146 4.97463 12.6153 4.47237 12.865 4H6.25C4.45507 4 3 5.45507 3 7.25V22.75C3 24.5449 4.45507 26 6.25 26H21.75C23.5449 26 25 24.5449 25 22.75ZM4.5 22.75V17.5H9.81597L9.85751 17.7041C10.2905 19.5919 11.9808 21 14 21L14.215 20.9947C16.2095 20.8953 17.842 19.4209 18.184 17.5H23.5V22.75C23.5 23.7165 22.7165 24.5 21.75 24.5H6.25C5.2835 24.5 4.5 23.7165 4.5 22.75Z",
- fill: "currentColor"
- }));
- }
-});
-const style = cB("empty", `
- display: flex;
- flex-direction: column;
- align-items: center;
- font-size: var(--n-font-size);
-`, [cE("icon", `
- width: var(--n-icon-size);
- height: var(--n-icon-size);
- font-size: var(--n-icon-size);
- line-height: var(--n-icon-size);
- color: var(--n-icon-color);
- transition:
- color .3s var(--n-bezier);
- `, [c("+", [cE("description", `
- margin-top: 8px;
- `)])]), cE("description", `
- transition: color .3s var(--n-bezier);
- color: var(--n-text-color);
- `), cE("extra", `
- text-align: center;
- transition: color .3s var(--n-bezier);
- margin-top: 12px;
- color: var(--n-extra-text-color);
- `)]);
-const emptyProps = Object.assign(Object.assign({}, useTheme.props), {
- description: String,
- showDescription: {
- type: Boolean,
- default: true
- },
- showIcon: {
- type: Boolean,
- default: true
- },
- size: {
- type: String,
- default: "medium"
- },
- renderIcon: Function
-});
-const __unplugin_components_0 = defineComponent({
- name: "Empty",
- props: emptyProps,
- setup(props) {
- const {
- mergedClsPrefixRef,
- inlineThemeDisabled,
- mergedComponentPropsRef
- } = useConfig(props);
- const themeRef = useTheme("Empty", "-empty", style, emptyLight, props, mergedClsPrefixRef);
- const {
- localeRef
- } = useLocale("Empty");
- const mergedDescriptionRef = computed(() => {
- var _a, _b, _c;
- return (_a = props.description) !== null && _a !== void 0 ? _a : (_c = (_b = mergedComponentPropsRef === null || mergedComponentPropsRef === void 0 ? void 0 : mergedComponentPropsRef.value) === null || _b === void 0 ? void 0 : _b.Empty) === null || _c === void 0 ? void 0 : _c.description;
- });
- const mergedRenderIconRef = computed(() => {
- var _a, _b;
- return ((_b = (_a = mergedComponentPropsRef === null || mergedComponentPropsRef === void 0 ? void 0 : mergedComponentPropsRef.value) === null || _a === void 0 ? void 0 : _a.Empty) === null || _b === void 0 ? void 0 : _b.renderIcon) || (() => h(EmptyIcon, null));
- });
- const cssVarsRef = computed(() => {
- const {
- size
- } = props;
- const {
- common: {
- cubicBezierEaseInOut
- },
- self: {
- [createKey("iconSize", size)]: iconSize,
- [createKey("fontSize", size)]: fontSize,
- textColor,
- iconColor,
- extraTextColor
- }
- } = themeRef.value;
- return {
- "--n-icon-size": iconSize,
- "--n-font-size": fontSize,
- "--n-bezier": cubicBezierEaseInOut,
- "--n-text-color": textColor,
- "--n-icon-color": iconColor,
- "--n-extra-text-color": extraTextColor
- };
- });
- const themeClassHandle = inlineThemeDisabled ? useThemeClass("empty", computed(() => {
- let hash = "";
- const {
- size
- } = props;
- hash += size[0];
- return hash;
- }), cssVarsRef, props) : void 0;
- return {
- mergedClsPrefix: mergedClsPrefixRef,
- mergedRenderIcon: mergedRenderIconRef,
- localizedDescription: computed(() => {
- return mergedDescriptionRef.value || localeRef.value.description;
- }),
- cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
- themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
- onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
- };
- },
- render() {
- const {
- $slots,
- mergedClsPrefix,
- onRender
- } = this;
- onRender === null || onRender === void 0 ? void 0 : onRender();
- return h("div", {
- class: [`${mergedClsPrefix}-empty`, this.themeClass],
- style: this.cssVars
- }, this.showIcon ? h("div", {
- class: `${mergedClsPrefix}-empty__icon`
- }, $slots.icon ? $slots.icon() : h(NBaseIcon, {
- clsPrefix: mergedClsPrefix
- }, {
- default: this.mergedRenderIcon
- })) : null, this.showDescription ? h("div", {
- class: `${mergedClsPrefix}-empty__description`
- }, $slots.default ? $slots.default() : this.localizedDescription) : null, $slots.extra ? h("div", {
- class: `${mergedClsPrefix}-empty__extra`
- }, $slots.extra()) : null);
- }
-});
-const _hoisted_1 = {
- key: 0,
- class: "favorite-page"
-};
-const _hoisted_2 = { class: "favorite-count" };
-const _hoisted_3 = {
- key: 0,
- class: "empty-tip"
-};
-const _hoisted_4 = {
- key: 1,
- class: "favorite-list"
-};
-const _hoisted_5 = {
- key: 0,
- class: "favorite-list-more text-center"
-};
-const _hoisted_6 = {
- key: 1,
- class: "loading-wrapper"
-};
-const _hoisted_7 = {
- key: 2,
- class: "no-more-tip"
-};
-const pageSize = 16;
-const _sfc_main = /* @__PURE__ */ defineComponent({
- __name: "index",
- props: {
- isComponent: {
- type: Boolean,
- default: false
- }
- },
- setup(__props) {
- const store = useStore();
- const favoriteList = computed(() => store.state.favoriteList);
- const favoriteSongs = ref([]);
- const loading = ref(false);
- const noMore = ref(false);
- const scrollbarRef = ref();
- const currentPage = ref(1);
- const props = __props;
- const getCurrentPageIds = () => {
- const reversedList = [...favoriteList.value];
- const startIndex = (currentPage.value - 1) * pageSize;
- const endIndex = startIndex + pageSize;
- return reversedList.slice(startIndex, endIndex);
- };
- const getFavoriteSongs = async () => {
- if (favoriteList.value.length === 0) {
- favoriteSongs.value = [];
- return;
- }
- if (props.isComponent && favoriteSongs.value.length >= 16) {
- return;
- }
- loading.value = true;
- try {
- const currentIds = getCurrentPageIds();
- const res = await getMusicDetail(currentIds);
- if (res.data.songs) {
- const newSongs = res.data.songs.map((song) => ({
- ...song,
- picUrl: song.al?.picUrl || ""
- }));
- if (currentPage.value === 1) {
- favoriteSongs.value = newSongs;
- } else {
- favoriteSongs.value = [...favoriteSongs.value, ...newSongs];
- }
- noMore.value = favoriteSongs.value.length >= favoriteList.value.length;
- }
- } catch (error) {
- console.error("获取收藏歌曲失败:", error);
- } finally {
- loading.value = false;
- }
- };
- const handleScroll = (e) => {
- const { scrollTop, scrollHeight, offsetHeight } = e.target;
- const threshold = 100;
- if (!loading.value && !noMore.value && scrollHeight - (scrollTop + offsetHeight) < threshold) {
- currentPage.value++;
- getFavoriteSongs();
- }
- };
- onMounted(() => {
- getFavoriteSongs();
- });
- watch(
- favoriteList,
- () => {
- currentPage.value = 1;
- noMore.value = false;
- getFavoriteSongs();
- },
- { deep: true, immediate: true }
- );
- const handlePlay = () => {
- store.commit("setPlayList", favoriteSongs.value);
- };
- const getItemAnimationDelay = (index) => {
- return setAnimationDelay(index, 30);
- };
- const router = useRouter();
- const handleMore = () => {
- router.push("/favorite");
- };
- return (_ctx, _cache) => {
- const _component_n_empty = __unplugin_components_0;
- const _component_n_button = Button;
- const _component_n_spin = __unplugin_components_0$1;
- const _component_n_scrollbar = Scrollbar;
- return (__props.isComponent ? favoriteSongs.value.length : true) ? (openBlock(), createElementBlock("div", _hoisted_1, [
- createBaseVNode("div", {
- class: normalizeClass(["favorite-header", unref(setAnimationClass)("animate__fadeInLeft")])
- }, [
- _cache[0] || (_cache[0] = createBaseVNode("h2", null, "我的收藏", -1)),
- createBaseVNode("div", _hoisted_2, "共 " + toDisplayString(favoriteList.value.length) + " 首", 1)
- ], 2),
- createBaseVNode("div", {
- class: normalizeClass(["favorite-main", unref(setAnimationClass)("animate__bounceInRight")])
- }, [
- createVNode(_component_n_scrollbar, {
- ref_key: "scrollbarRef",
- ref: scrollbarRef,
- class: "favorite-content",
- onScroll: handleScroll
- }, {
- default: withCtx(() => [
- favoriteList.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_3, [
- createVNode(_component_n_empty, { description: "还没有收藏歌曲" })
- ])) : (openBlock(), createElementBlock("div", _hoisted_4, [
- (openBlock(true), createElementBlock(Fragment, null, renderList(favoriteSongs.value, (song, index) => {
- return openBlock(), createBlock(SongItem, {
- key: song.id,
- item: song,
- favorite: !__props.isComponent,
- class: normalizeClass(unref(setAnimationClass)("animate__bounceInLeft")),
- style: normalizeStyle(getItemAnimationDelay(index)),
- onPlay: handlePlay
- }, null, 8, ["item", "favorite", "class", "style"]);
- }), 128)),
- __props.isComponent ? (openBlock(), createElementBlock("div", _hoisted_5, [
- createVNode(_component_n_button, {
- text: "",
- type: "primary",
- onClick: handleMore
- }, {
- default: withCtx(() => _cache[1] || (_cache[1] = [
- createTextVNode("查看更多")
- ])),
- _: 1
- })
- ])) : createCommentVNode("", true),
- loading.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
- createVNode(_component_n_spin, { size: "large" })
- ])) : createCommentVNode("", true),
- noMore.value ? (openBlock(), createElementBlock("div", _hoisted_7, "没有更多了")) : createCommentVNode("", true)
- ]))
- ]),
- _: 1
- }, 512)
- ], 2)
- ])) : createCommentVNode("", true);
- };
- }
-});
-const Favorite = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2d1a7423"]]);
-export {
- Favorite as F
-};
diff --git a/out/renderer/assets/index-JJypdZPY.js.gz b/out/renderer/assets/index-JJypdZPY.js.gz
deleted file mode 100644
index d2bb6dd..0000000
Binary files a/out/renderer/assets/index-JJypdZPY.js.gz and /dev/null differ
diff --git a/out/renderer/assets/index-RCxsGzpS.js b/out/renderer/assets/index-RCxsGzpS.js
deleted file mode 100644
index dc2971d..0000000
--- a/out/renderer/assets/index-RCxsGzpS.js
+++ /dev/null
@@ -1,944 +0,0 @@
-import { d as defineComponent, l as h, m as c, p as cB, q as useTheme, x as useConfig, y as inputNumberLight, z as useFormItem, r as ref, A as toRef, C as useMergedState, D as useMemo, E as watch, F as useRtl, G as computed, H as rgba, I as resolveWrappedSlot, J as on, K as resolveSlot, N as NBaseIcon, X as XButton, L as call, M as nextTick, o as onMounted, O as createBlock, f as withCtx, P as checkUpdate, S as Scrollbar, g as useStore, Q as config, j as openBlock, b as createBaseVNode, e as createVNode, u as unref, R as isElectron, c as createElementBlock, T as createCommentVNode, t as toDisplayString, k as createTextVNode, U as PlayBottom, B as Button, _ as _export_sfc } from "./index-DKaFsuse.js";
-import { _ as __unplugin_components_1$1, a as __unplugin_components_3 } from "./Switch-D3Z_Vg3u.js";
-import { u as useLocale } from "./use-locale-DLWAOXez.js";
-import { _ as __unplugin_components_4 } from "./Tag-C0oC92WF.js";
-import { _ as __unplugin_components_0 } from "./Slider-BA6NituQ.js";
-const AddIcon = defineComponent({
- name: "Add",
- render() {
- return h("svg", {
- width: "512",
- height: "512",
- viewBox: "0 0 512 512",
- fill: "none",
- xmlns: "http://www.w3.org/2000/svg"
- }, h("path", {
- d: "M256 112V400M400 256H112",
- stroke: "currentColor",
- "stroke-width": "32",
- "stroke-linecap": "round",
- "stroke-linejoin": "round"
- }));
- }
-});
-const RemoveIcon = defineComponent({
- name: "Remove",
- render() {
- return h("svg", {
- xmlns: "http://www.w3.org/2000/svg",
- viewBox: "0 0 512 512"
- }, h("line", {
- x1: "400",
- y1: "256",
- x2: "112",
- y2: "256",
- style: "\n fill: none;\n stroke: currentColor;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke-width: 32px;\n "
- }));
- }
-});
-const style = c([cB("input-number-suffix", `
- display: inline-block;
- margin-right: 10px;
- `), cB("input-number-prefix", `
- display: inline-block;
- margin-left: 10px;
- `)]);
-function parse(value) {
- if (value === void 0 || value === null || typeof value === "string" && value.trim() === "") {
- return null;
- }
- return Number(value);
-}
-function isWipValue(value) {
- return value.includes(".") && (/^(-)?\d+.*(\.|0)$/.test(value) || /^-?\d*$/.test(value)) || value === "-" || value === "-0";
-}
-function validator(value) {
- if (value === void 0 || value === null) return true;
- if (Number.isNaN(value)) return false;
- return true;
-}
-function format(value, precision) {
- if (typeof value !== "number") return "";
- return precision === void 0 ? String(value) : value.toFixed(precision);
-}
-function parseNumber(number) {
- if (number === null) return null;
- if (typeof number === "number") {
- return number;
- } else {
- const parsedNumber = Number(number);
- if (Number.isNaN(parsedNumber)) {
- return null;
- } else {
- return parsedNumber;
- }
- }
-}
-const HOLDING_CHANGE_THRESHOLD = 800;
-const HOLDING_CHANGE_INTERVAL = 100;
-const inputNumberProps = Object.assign(Object.assign({}, useTheme.props), {
- autofocus: Boolean,
- loading: {
- type: Boolean,
- default: void 0
- },
- placeholder: String,
- defaultValue: {
- type: Number,
- default: null
- },
- value: Number,
- step: {
- type: [Number, String],
- default: 1
- },
- min: [Number, String],
- max: [Number, String],
- size: String,
- disabled: {
- type: Boolean,
- default: void 0
- },
- validator: Function,
- bordered: {
- type: Boolean,
- default: void 0
- },
- showButton: {
- type: Boolean,
- default: true
- },
- buttonPlacement: {
- type: String,
- default: "right"
- },
- inputProps: Object,
- readonly: Boolean,
- clearable: Boolean,
- keyboard: {
- type: Object,
- default: {}
- },
- updateValueOnInput: {
- type: Boolean,
- default: true
- },
- round: {
- type: Boolean,
- default: void 0
- },
- parse: Function,
- format: Function,
- precision: Number,
- status: String,
- "onUpdate:value": [Function, Array],
- onUpdateValue: [Function, Array],
- onFocus: [Function, Array],
- onBlur: [Function, Array],
- onClear: [Function, Array],
- // deprecated
- onChange: [Function, Array]
-});
-const __unplugin_components_1 = defineComponent({
- name: "InputNumber",
- props: inputNumberProps,
- setup(props) {
- const {
- mergedBorderedRef,
- mergedClsPrefixRef,
- mergedRtlRef
- } = useConfig(props);
- const themeRef = useTheme("InputNumber", "-input-number", style, inputNumberLight, props, mergedClsPrefixRef);
- const {
- localeRef
- } = useLocale("InputNumber");
- const formItem = useFormItem(props);
- const {
- mergedSizeRef,
- mergedDisabledRef,
- mergedStatusRef
- } = formItem;
- const inputInstRef = ref(null);
- const minusButtonInstRef = ref(null);
- const addButtonInstRef = ref(null);
- const uncontrolledValueRef = ref(props.defaultValue);
- const controlledValueRef = toRef(props, "value");
- const mergedValueRef = useMergedState(controlledValueRef, uncontrolledValueRef);
- const displayedValueRef = ref("");
- const getPrecision = (value) => {
- const fraction = String(value).split(".")[1];
- return fraction ? fraction.length : 0;
- };
- const getMaxPrecision = (currentValue) => {
- const precisions = [props.min, props.max, props.step, currentValue].map((value) => {
- if (value === void 0) return 0;
- return getPrecision(value);
- });
- return Math.max(...precisions);
- };
- const mergedPlaceholderRef = useMemo(() => {
- const {
- placeholder
- } = props;
- if (placeholder !== void 0) return placeholder;
- return localeRef.value.placeholder;
- });
- const mergedStepRef = useMemo(() => {
- const parsedNumber = parseNumber(props.step);
- if (parsedNumber !== null) {
- return parsedNumber === 0 ? 1 : Math.abs(parsedNumber);
- }
- return 1;
- });
- const mergedMinRef = useMemo(() => {
- const parsedNumber = parseNumber(props.min);
- if (parsedNumber !== null) return parsedNumber;
- else return null;
- });
- const mergedMaxRef = useMemo(() => {
- const parsedNumber = parseNumber(props.max);
- if (parsedNumber !== null) return parsedNumber;
- else return null;
- });
- const deriveDisplayedValueFromValue = () => {
- const {
- value: mergedValue
- } = mergedValueRef;
- if (validator(mergedValue)) {
- const {
- format: formatProp,
- precision
- } = props;
- if (formatProp) {
- displayedValueRef.value = formatProp(mergedValue);
- } else {
- if (mergedValue === null || precision === void 0 || getPrecision(mergedValue) > precision) {
- displayedValueRef.value = format(mergedValue, void 0);
- } else {
- displayedValueRef.value = format(mergedValue, precision);
- }
- }
- } else {
- displayedValueRef.value = String(mergedValue);
- }
- };
- deriveDisplayedValueFromValue();
- const doUpdateValue = (value) => {
- const {
- value: mergedValue
- } = mergedValueRef;
- if (value === mergedValue) {
- deriveDisplayedValueFromValue();
- return;
- }
- const {
- "onUpdate:value": _onUpdateValue,
- onUpdateValue,
- onChange
- } = props;
- const {
- nTriggerFormInput,
- nTriggerFormChange
- } = formItem;
- if (onChange) call(onChange, value);
- if (onUpdateValue) call(onUpdateValue, value);
- if (_onUpdateValue) call(_onUpdateValue, value);
- uncontrolledValueRef.value = value;
- nTriggerFormInput();
- nTriggerFormChange();
- };
- const deriveValueFromDisplayedValue = ({
- offset,
- doUpdateIfValid,
- fixPrecision,
- isInputing
- }) => {
- const {
- value: displayedValue
- } = displayedValueRef;
- if (isInputing && isWipValue(displayedValue)) {
- return false;
- }
- const parsedValue = (props.parse || parse)(displayedValue);
- if (parsedValue === null) {
- if (doUpdateIfValid) doUpdateValue(null);
- return null;
- }
- if (validator(parsedValue)) {
- const currentPrecision = getPrecision(parsedValue);
- const {
- precision
- } = props;
- if (precision !== void 0 && precision < currentPrecision && !fixPrecision) {
- return false;
- }
- let nextValue = Number.parseFloat((parsedValue + offset).toFixed(precision !== null && precision !== void 0 ? precision : getMaxPrecision(parsedValue)));
- if (validator(nextValue)) {
- const {
- value: mergedMax
- } = mergedMaxRef;
- const {
- value: mergedMin
- } = mergedMinRef;
- if (mergedMax !== null && nextValue > mergedMax) {
- if (!doUpdateIfValid || isInputing) return false;
- nextValue = mergedMax;
- }
- if (mergedMin !== null && nextValue < mergedMin) {
- if (!doUpdateIfValid || isInputing) return false;
- nextValue = mergedMin;
- }
- if (props.validator && !props.validator(nextValue)) return false;
- if (doUpdateIfValid) doUpdateValue(nextValue);
- return nextValue;
- }
- }
- return false;
- };
- const displayedValueInvalidRef = useMemo(() => {
- const derivedValue = deriveValueFromDisplayedValue({
- offset: 0,
- doUpdateIfValid: false,
- isInputing: false,
- fixPrecision: false
- });
- return derivedValue === false;
- });
- const minusableRef = useMemo(() => {
- const {
- value: mergedValue
- } = mergedValueRef;
- if (props.validator && mergedValue === null) {
- return false;
- }
- const {
- value: mergedStep
- } = mergedStepRef;
- const derivedNextValue = deriveValueFromDisplayedValue({
- offset: -mergedStep,
- doUpdateIfValid: false,
- isInputing: false,
- fixPrecision: false
- });
- return derivedNextValue !== false;
- });
- const addableRef = useMemo(() => {
- const {
- value: mergedValue
- } = mergedValueRef;
- if (props.validator && mergedValue === null) {
- return false;
- }
- const {
- value: mergedStep
- } = mergedStepRef;
- const derivedNextValue = deriveValueFromDisplayedValue({
- offset: +mergedStep,
- doUpdateIfValid: false,
- isInputing: false,
- fixPrecision: false
- });
- return derivedNextValue !== false;
- });
- function doFocus(e) {
- const {
- onFocus
- } = props;
- const {
- nTriggerFormFocus
- } = formItem;
- if (onFocus) call(onFocus, e);
- nTriggerFormFocus();
- }
- function doBlur(e) {
- var _a, _b;
- if (e.target === ((_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.wrapperElRef)) {
- return;
- }
- const value = deriveValueFromDisplayedValue({
- offset: 0,
- doUpdateIfValid: true,
- isInputing: false,
- fixPrecision: true
- });
- if (value !== false) {
- const inputElRef = (_b = inputInstRef.value) === null || _b === void 0 ? void 0 : _b.inputElRef;
- if (inputElRef) {
- inputElRef.value = String(value || "");
- }
- if (mergedValueRef.value === value) {
- deriveDisplayedValueFromValue();
- }
- } else {
- deriveDisplayedValueFromValue();
- }
- const {
- onBlur
- } = props;
- const {
- nTriggerFormBlur
- } = formItem;
- if (onBlur) call(onBlur, e);
- nTriggerFormBlur();
- void nextTick(() => {
- deriveDisplayedValueFromValue();
- });
- }
- function doClear(e) {
- const {
- onClear
- } = props;
- if (onClear) call(onClear, e);
- }
- function doAdd() {
- const {
- value: addable
- } = addableRef;
- if (!addable) {
- clearAddHoldTimeout();
- return;
- }
- const {
- value: mergedValue
- } = mergedValueRef;
- if (mergedValue === null) {
- if (!props.validator) {
- doUpdateValue(createValidValue());
- }
- } else {
- const {
- value: mergedStep
- } = mergedStepRef;
- deriveValueFromDisplayedValue({
- offset: mergedStep,
- doUpdateIfValid: true,
- isInputing: false,
- fixPrecision: true
- });
- }
- }
- function doMinus() {
- const {
- value: minusable
- } = minusableRef;
- if (!minusable) {
- clearMinusHoldTimeout();
- return;
- }
- const {
- value: mergedValue
- } = mergedValueRef;
- if (mergedValue === null) {
- if (!props.validator) {
- doUpdateValue(createValidValue());
- }
- } else {
- const {
- value: mergedStep
- } = mergedStepRef;
- deriveValueFromDisplayedValue({
- offset: -mergedStep,
- doUpdateIfValid: true,
- isInputing: false,
- fixPrecision: true
- });
- }
- }
- const handleFocus = doFocus;
- const handleBlur = doBlur;
- function createValidValue() {
- if (props.validator) return null;
- const {
- value: mergedMin
- } = mergedMinRef;
- const {
- value: mergedMax
- } = mergedMaxRef;
- if (mergedMin !== null) {
- return Math.max(0, mergedMin);
- } else if (mergedMax !== null) {
- return Math.min(0, mergedMax);
- } else {
- return 0;
- }
- }
- function handleClear(e) {
- doClear(e);
- doUpdateValue(null);
- }
- function handleMouseDown(e) {
- var _a, _b, _c;
- if ((_a = addButtonInstRef.value) === null || _a === void 0 ? void 0 : _a.$el.contains(e.target)) {
- e.preventDefault();
- }
- if ((_b = minusButtonInstRef.value) === null || _b === void 0 ? void 0 : _b.$el.contains(e.target)) {
- e.preventDefault();
- }
- (_c = inputInstRef.value) === null || _c === void 0 ? void 0 : _c.activate();
- }
- let minusHoldStateIntervalId = null;
- let addHoldStateIntervalId = null;
- let firstMinusMousedownId = null;
- function clearMinusHoldTimeout() {
- if (firstMinusMousedownId) {
- window.clearTimeout(firstMinusMousedownId);
- firstMinusMousedownId = null;
- }
- if (minusHoldStateIntervalId) {
- window.clearInterval(minusHoldStateIntervalId);
- minusHoldStateIntervalId = null;
- }
- }
- let firstAddMousedownId = null;
- function clearAddHoldTimeout() {
- if (firstAddMousedownId) {
- window.clearTimeout(firstAddMousedownId);
- firstAddMousedownId = null;
- }
- if (addHoldStateIntervalId) {
- window.clearInterval(addHoldStateIntervalId);
- addHoldStateIntervalId = null;
- }
- }
- function handleMinusMousedown() {
- clearMinusHoldTimeout();
- firstMinusMousedownId = window.setTimeout(() => {
- minusHoldStateIntervalId = window.setInterval(() => {
- doMinus();
- }, HOLDING_CHANGE_INTERVAL);
- }, HOLDING_CHANGE_THRESHOLD);
- on("mouseup", document, clearMinusHoldTimeout, {
- once: true
- });
- }
- function handleAddMousedown() {
- clearAddHoldTimeout();
- firstAddMousedownId = window.setTimeout(() => {
- addHoldStateIntervalId = window.setInterval(() => {
- doAdd();
- }, HOLDING_CHANGE_INTERVAL);
- }, HOLDING_CHANGE_THRESHOLD);
- on("mouseup", document, clearAddHoldTimeout, {
- once: true
- });
- }
- const handleAddClick = () => {
- if (addHoldStateIntervalId) return;
- doAdd();
- };
- const handleMinusClick = () => {
- if (minusHoldStateIntervalId) return;
- doMinus();
- };
- function handleKeyDown(e) {
- var _a, _b;
- if (e.key === "Enter") {
- if (e.target === ((_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.wrapperElRef)) {
- return;
- }
- const value = deriveValueFromDisplayedValue({
- offset: 0,
- doUpdateIfValid: true,
- isInputing: false,
- fixPrecision: true
- });
- if (value !== false) {
- (_b = inputInstRef.value) === null || _b === void 0 ? void 0 : _b.deactivate();
- }
- } else if (e.key === "ArrowUp") {
- if (!addableRef.value) return;
- if (props.keyboard.ArrowUp === false) return;
- e.preventDefault();
- const value = deriveValueFromDisplayedValue({
- offset: 0,
- doUpdateIfValid: true,
- isInputing: false,
- fixPrecision: true
- });
- if (value !== false) {
- doAdd();
- }
- } else if (e.key === "ArrowDown") {
- if (!minusableRef.value) return;
- if (props.keyboard.ArrowDown === false) return;
- e.preventDefault();
- const value = deriveValueFromDisplayedValue({
- offset: 0,
- doUpdateIfValid: true,
- isInputing: false,
- fixPrecision: true
- });
- if (value !== false) {
- doMinus();
- }
- }
- }
- function handleUpdateDisplayedValue(value) {
- displayedValueRef.value = value;
- if (props.updateValueOnInput && !props.format && !props.parse && props.precision === void 0) {
- deriveValueFromDisplayedValue({
- offset: 0,
- doUpdateIfValid: true,
- isInputing: true,
- fixPrecision: false
- });
- }
- }
- watch(mergedValueRef, () => {
- deriveDisplayedValueFromValue();
- });
- const exposedMethods = {
- focus: () => {
- var _a;
- return (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.focus();
- },
- blur: () => {
- var _a;
- return (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.blur();
- },
- select: () => {
- var _a;
- return (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.select();
- }
- };
- const rtlEnabledRef = useRtl("InputNumber", mergedRtlRef, mergedClsPrefixRef);
- return Object.assign(Object.assign({}, exposedMethods), {
- rtlEnabled: rtlEnabledRef,
- inputInstRef,
- minusButtonInstRef,
- addButtonInstRef,
- mergedClsPrefix: mergedClsPrefixRef,
- mergedBordered: mergedBorderedRef,
- uncontrolledValue: uncontrolledValueRef,
- mergedValue: mergedValueRef,
- mergedPlaceholder: mergedPlaceholderRef,
- displayedValueInvalid: displayedValueInvalidRef,
- mergedSize: mergedSizeRef,
- mergedDisabled: mergedDisabledRef,
- displayedValue: displayedValueRef,
- addable: addableRef,
- minusable: minusableRef,
- mergedStatus: mergedStatusRef,
- handleFocus,
- handleBlur,
- handleClear,
- handleMouseDown,
- handleAddClick,
- handleMinusClick,
- handleAddMousedown,
- handleMinusMousedown,
- handleKeyDown,
- handleUpdateDisplayedValue,
- // theme
- mergedTheme: themeRef,
- inputThemeOverrides: {
- paddingSmall: "0 8px 0 10px",
- paddingMedium: "0 8px 0 12px",
- paddingLarge: "0 8px 0 14px"
- },
- buttonThemeOverrides: computed(() => {
- const {
- self: {
- iconColorDisabled
- }
- } = themeRef.value;
- const [r, g, b, a] = rgba(iconColorDisabled);
- return {
- textColorTextDisabled: `rgb(${r}, ${g}, ${b})`,
- opacityDisabled: `${a}`
- };
- })
- });
- },
- render() {
- const {
- mergedClsPrefix,
- $slots
- } = this;
- const renderMinusButton = () => {
- return h(XButton, {
- text: true,
- disabled: !this.minusable || this.mergedDisabled || this.readonly,
- focusable: false,
- theme: this.mergedTheme.peers.Button,
- themeOverrides: this.mergedTheme.peerOverrides.Button,
- builtinThemeOverrides: this.buttonThemeOverrides,
- onClick: this.handleMinusClick,
- onMousedown: this.handleMinusMousedown,
- ref: "minusButtonInstRef"
- }, {
- icon: () => resolveSlot($slots["minus-icon"], () => [h(NBaseIcon, {
- clsPrefix: mergedClsPrefix
- }, {
- default: () => h(RemoveIcon, null)
- })])
- });
- };
- const renderAddButton = () => {
- return h(XButton, {
- text: true,
- disabled: !this.addable || this.mergedDisabled || this.readonly,
- focusable: false,
- theme: this.mergedTheme.peers.Button,
- themeOverrides: this.mergedTheme.peerOverrides.Button,
- builtinThemeOverrides: this.buttonThemeOverrides,
- onClick: this.handleAddClick,
- onMousedown: this.handleAddMousedown,
- ref: "addButtonInstRef"
- }, {
- icon: () => resolveSlot($slots["add-icon"], () => [h(NBaseIcon, {
- clsPrefix: mergedClsPrefix
- }, {
- default: () => h(AddIcon, null)
- })])
- });
- };
- return h("div", {
- class: [`${mergedClsPrefix}-input-number`, this.rtlEnabled && `${mergedClsPrefix}-input-number--rtl`]
- }, h(__unplugin_components_1$1, {
- ref: "inputInstRef",
- autofocus: this.autofocus,
- status: this.mergedStatus,
- bordered: this.mergedBordered,
- loading: this.loading,
- value: this.displayedValue,
- onUpdateValue: this.handleUpdateDisplayedValue,
- theme: this.mergedTheme.peers.Input,
- themeOverrides: this.mergedTheme.peerOverrides.Input,
- builtinThemeOverrides: this.inputThemeOverrides,
- size: this.mergedSize,
- placeholder: this.mergedPlaceholder,
- disabled: this.mergedDisabled,
- readonly: this.readonly,
- round: this.round,
- textDecoration: this.displayedValueInvalid ? "line-through" : void 0,
- onFocus: this.handleFocus,
- onBlur: this.handleBlur,
- onKeydown: this.handleKeyDown,
- onMousedown: this.handleMouseDown,
- onClear: this.handleClear,
- clearable: this.clearable,
- inputProps: this.inputProps,
- internalLoadingBeforeSuffix: true
- }, {
- prefix: () => {
- var _a;
- return this.showButton && this.buttonPlacement === "both" ? [renderMinusButton(), resolveWrappedSlot($slots.prefix, (children) => {
- if (children) {
- return h("span", {
- class: `${mergedClsPrefix}-input-number-prefix`
- }, children);
- }
- return null;
- })] : (_a = $slots.prefix) === null || _a === void 0 ? void 0 : _a.call($slots);
- },
- suffix: () => {
- var _a;
- return this.showButton ? [resolveWrappedSlot($slots.suffix, (children) => {
- if (children) {
- return h("span", {
- class: `${mergedClsPrefix}-input-number-suffix`
- }, children);
- }
- return null;
- }), this.buttonPlacement === "right" ? renderMinusButton() : null, renderAddButton()] : (_a = $slots.suffix) === null || _a === void 0 ? void 0 : _a.call($slots);
- }
- }));
- }
-});
-const _hoisted_1 = { class: "set-page" };
-const _hoisted_2 = { class: "set-item" };
-const _hoisted_3 = {
- key: 0,
- class: "set-item"
-};
-const _hoisted_4 = { class: "set-item" };
-const _hoisted_5 = { class: "flex items-center gap-2" };
-const _hoisted_6 = { class: "text-sm text-gray-400" };
-const _hoisted_7 = { class: "w-40" };
-const _hoisted_8 = { class: "set-item" };
-const _hoisted_9 = { class: "set-item-content" };
-const _hoisted_10 = { class: "flex items-center gap-2" };
-const _hoisted_11 = { class: "set-item" };
-const _sfc_main = /* @__PURE__ */ defineComponent({
- __name: "index",
- setup(__props) {
- const store = useStore();
- const checking = ref(false);
- const updateInfo = ref({
- hasUpdate: false,
- latestVersion: "",
- currentVersion: config.version,
- releaseInfo: null
- });
- const setData = computed(() => store.state.setData);
- watch(() => setData.value, (newVal) => {
- store.commit("setSetData", newVal);
- }, { deep: true });
- const isDarkTheme = computed({
- get: () => store.state.theme === "dark",
- set: () => store.commit("toggleTheme")
- });
- const openAuthor = () => {
- window.open(setData.value.authorUrl);
- };
- const restartApp = () => {
- window.electron.ipcRenderer.send("restart");
- };
- const checkForUpdates = async () => {
- checking.value = true;
- try {
- const result = await checkUpdate();
- updateInfo.value = result;
- } finally {
- checking.value = false;
- }
- };
- const openReleasePage = () => {
- window.open("https://github.com/algerkong/AlgerMusicPlayer/releases/latest");
- };
- onMounted(() => {
- checkForUpdates();
- });
- return (_ctx, _cache) => {
- const _component_n_switch = __unplugin_components_3;
- const _component_n_input_number = __unplugin_components_1;
- const _component_n_slider = __unplugin_components_0;
- const _component_n_tag = __unplugin_components_4;
- const _component_n_button = Button;
- const _component_n_scrollbar = Scrollbar;
- return openBlock(), createBlock(_component_n_scrollbar, null, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_1, [
- createBaseVNode("div", _hoisted_2, [
- _cache[5] || (_cache[5] = createBaseVNode("div", null, [
- createBaseVNode("div", { class: "set-item-title" }, "主题模式"),
- createBaseVNode("div", { class: "set-item-content" }, "切换日间/夜间主题")
- ], -1)),
- createVNode(_component_n_switch, {
- value: isDarkTheme.value,
- "onUpdate:value": _cache[0] || (_cache[0] = ($event) => isDarkTheme.value = $event)
- }, {
- checked: withCtx(() => _cache[3] || (_cache[3] = [
- createBaseVNode("i", { class: "ri-moon-line" }, null, -1)
- ])),
- unchecked: withCtx(() => _cache[4] || (_cache[4] = [
- createBaseVNode("i", { class: "ri-sun-line" }, null, -1)
- ])),
- _: 1
- }, 8, ["value"])
- ]),
- unref(isElectron) ? (openBlock(), createElementBlock("div", _hoisted_3, [
- _cache[6] || (_cache[6] = createBaseVNode("div", null, [
- createBaseVNode("div", { class: "set-item-title" }, "音乐API端口"),
- createBaseVNode("div", { class: "set-item-content" }, " 修改后需要重启应用 ")
- ], -1)),
- createVNode(_component_n_input_number, {
- value: setData.value.musicApiPort,
- "onUpdate:value": _cache[1] || (_cache[1] = ($event) => setData.value.musicApiPort = $event)
- }, null, 8, ["value"])
- ])) : createCommentVNode("", true),
- createBaseVNode("div", _hoisted_4, [
- _cache[7] || (_cache[7] = createBaseVNode("div", null, [
- createBaseVNode("div", { class: "set-item-title" }, "动画速度"),
- createBaseVNode("div", { class: "set-item-content" }, "调节动画播放速度")
- ], -1)),
- createBaseVNode("div", _hoisted_5, [
- createBaseVNode("span", _hoisted_6, toDisplayString(setData.value.animationSpeed) + "x", 1),
- createBaseVNode("div", _hoisted_7, [
- createVNode(_component_n_slider, {
- value: setData.value.animationSpeed,
- "onUpdate:value": _cache[2] || (_cache[2] = ($event) => setData.value.animationSpeed = $event),
- min: 0.1,
- max: 3,
- step: 0.1,
- marks: {
- 0.1: "极慢",
- 1: "正常",
- 3: "极快"
- },
- disabled: setData.value.noAnimate,
- class: "w-40"
- }, null, 8, ["value", "disabled"])
- ])
- ])
- ]),
- createBaseVNode("div", _hoisted_8, [
- createBaseVNode("div", null, [
- _cache[8] || (_cache[8] = createBaseVNode("div", { class: "set-item-title" }, "版本", -1)),
- createBaseVNode("div", _hoisted_9, [
- createTextVNode(toDisplayString(updateInfo.value.currentVersion) + " ", 1),
- updateInfo.value.hasUpdate ? (openBlock(), createBlock(_component_n_tag, {
- key: 0,
- type: "success",
- class: "ml-2"
- }, {
- default: withCtx(() => [
- createTextVNode("发现新版本 " + toDisplayString(updateInfo.value.latestVersion), 1)
- ]),
- _: 1
- })) : createCommentVNode("", true)
- ])
- ]),
- createBaseVNode("div", _hoisted_10, [
- createVNode(_component_n_button, {
- type: updateInfo.value.hasUpdate ? "primary" : "default",
- size: "small",
- loading: checking.value,
- onClick: checkForUpdates
- }, {
- default: withCtx(() => [
- createTextVNode(toDisplayString(checking.value ? "检查中..." : "检查更新"), 1)
- ]),
- _: 1
- }, 8, ["type", "loading"]),
- updateInfo.value.hasUpdate ? (openBlock(), createBlock(_component_n_button, {
- key: 0,
- type: "success",
- size: "small",
- onClick: openReleasePage
- }, {
- default: withCtx(() => _cache[9] || (_cache[9] = [
- createTextVNode(" 前往更新 ")
- ])),
- _: 1
- })) : createCommentVNode("", true)
- ])
- ]),
- createBaseVNode("div", {
- class: "set-item cursor-pointer hover:text-green-500 hover:bg-green-950 transition-all",
- onClick: openAuthor
- }, [
- _cache[10] || (_cache[10] = createBaseVNode("div", null, [
- createBaseVNode("div", { class: "set-item-title" }, "作者"),
- createBaseVNode("div", { class: "set-item-content" }, "algerkong github")
- ], -1)),
- createBaseVNode("div", null, toDisplayString(setData.value.author), 1)
- ]),
- createBaseVNode("div", _hoisted_11, [
- _cache[12] || (_cache[12] = createBaseVNode("div", null, [
- createBaseVNode("div", { class: "set-item-title" }, "重启"),
- createBaseVNode("div", { class: "set-item-content" }, "重启应用")
- ], -1)),
- createVNode(_component_n_button, {
- type: "primary",
- onClick: restartApp
- }, {
- default: withCtx(() => _cache[11] || (_cache[11] = [
- createTextVNode("重启")
- ])),
- _: 1
- })
- ])
- ]),
- createVNode(PlayBottom)
- ]),
- _: 1
- });
- };
- }
-});
-const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-0331ad9e"]]);
-export {
- index as default
-};
diff --git a/out/renderer/assets/index-RCxsGzpS.js.gz b/out/renderer/assets/index-RCxsGzpS.js.gz
deleted file mode 100644
index 4229d8a..0000000
Binary files a/out/renderer/assets/index-RCxsGzpS.js.gz and /dev/null differ
diff --git a/out/renderer/assets/index-SvIREzLs.js b/out/renderer/assets/index-SvIREzLs.js
deleted file mode 100644
index 866b6be..0000000
--- a/out/renderer/assets/index-SvIREzLs.js
+++ /dev/null
@@ -1,216 +0,0 @@
-import { d as defineComponent, r as ref, E as watch, o as onMounted, G as computed, c as createElementBlock, b as createBaseVNode, e as createVNode, f as withCtx, S as Scrollbar, g as useStore, ae as audioService, ab as resolveDirective, j as openBlock, a3 as Fragment, a4 as renderList, n as normalizeClass, u as unref, s as setAnimationClass, a2 as normalizeStyle, t as toDisplayString, w as withDirectives, a7 as getImgUrl, ai as formatNumber, T as createCommentVNode, a5 as setAnimationDelay, _ as _export_sfc } from "./index-DKaFsuse.js";
-import { g as getTopMv, a as getAllMv, M as MvPlayer } from "./MvPlayer-I4IDK1xL.js";
-import { N as NImage } from "./Image-DXClIklC.js";
-import "./Icon-DucaliTK.js";
-import "./Slider-BA6NituQ.js";
-import "./use-locale-DLWAOXez.js";
-import "./Drawer-BEJ8Ydua.js";
-import "./Ellipsis-D4R5dIX2.js";
-const _hoisted_1 = { class: "mv-list" };
-const _hoisted_2 = { class: "play-list-type" };
-const _hoisted_3 = { class: "categories-wrapper" };
-const _hoisted_4 = ["onClick"];
-const _hoisted_5 = ["onClick"];
-const _hoisted_6 = { class: "top" };
-const _hoisted_7 = { class: "play-count" };
-const _hoisted_8 = { class: "mv-item-title" };
-const _hoisted_9 = {
- key: 0,
- class: "loading-more"
-};
-const _hoisted_10 = {
- key: 1,
- class: "no-more"
-};
-const _sfc_main = /* @__PURE__ */ defineComponent({
- ...{
- name: "Mv"
- },
- __name: "index",
- setup(__props) {
- const showMv = ref(false);
- const mvList = ref([]);
- const playMvItem = ref();
- const store = useStore();
- const initLoading = ref(false);
- const loadingMore = ref(false);
- const currentIndex = ref(0);
- const offset = ref(0);
- const limit = ref(42);
- const hasMore = ref(true);
- const categories = [
- { label: "全部", value: "全部" },
- { label: "内地", value: "内地" },
- { label: "港台", value: "港台" },
- { label: "欧美", value: "欧美" },
- { label: "日本", value: "日本" },
- { label: "韩国", value: "韩国" }
- ];
- const selectedCategory = ref("全部");
- watch(selectedCategory, async () => {
- offset.value = 0;
- mvList.value = [];
- hasMore.value = true;
- await loadMvList();
- });
- const getAnimationDelay = (index2) => {
- const currentPageIndex = index2 % limit.value;
- return setAnimationDelay(currentPageIndex, 30);
- };
- onMounted(async () => {
- await loadMvList();
- });
- const handleShowMv = async (item, index2) => {
- store.commit("setIsPlay", false);
- store.commit("setPlayMusic", false);
- audioService.getCurrentSound()?.pause();
- showMv.value = true;
- currentIndex.value = index2;
- playMvItem.value = item;
- };
- const playPrevMv = async (setLoading) => {
- try {
- if (currentIndex.value > 0) {
- const prevItem = mvList.value[currentIndex.value - 1];
- await handleShowMv(prevItem, currentIndex.value - 1);
- }
- } finally {
- setLoading(false);
- }
- };
- const playNextMv = async (setLoading) => {
- try {
- if (currentIndex.value < mvList.value.length - 1) {
- const nextItem = mvList.value[currentIndex.value + 1];
- await handleShowMv(nextItem, currentIndex.value + 1);
- } else if (hasMore.value) {
- await loadMvList();
- if (mvList.value.length > currentIndex.value + 1) {
- const nextItem = mvList.value[currentIndex.value + 1];
- await handleShowMv(nextItem, currentIndex.value + 1);
- } else {
- showMv.value = false;
- }
- } else {
- showMv.value = false;
- }
- } catch (error) {
- console.error("加载更多MV失败:", error);
- showMv.value = false;
- } finally {
- setLoading(false);
- }
- };
- const loadMvList = async () => {
- try {
- if (!hasMore.value || loadingMore.value) return;
- if (offset.value === 0) {
- initLoading.value = true;
- } else {
- loadingMore.value = true;
- }
- const params = {
- limit: limit.value,
- offset: offset.value,
- area: selectedCategory.value === "全部" ? "" : selectedCategory.value
- };
- const res = selectedCategory.value === "全部" ? await getTopMv(params) : await getAllMv(params);
- const { data } = res.data;
- mvList.value.push(...data);
- hasMore.value = data.length === limit.value;
- offset.value += limit.value;
- } finally {
- initLoading.value = false;
- loadingMore.value = false;
- }
- };
- const handleScroll = (e) => {
- const target = e.target;
- const { scrollTop, clientHeight, scrollHeight } = target;
- const threshold = 100;
- if (scrollHeight - (scrollTop + clientHeight) < threshold) {
- loadMvList();
- }
- };
- const isPrevDisabled = computed(() => currentIndex.value === 0);
- return (_ctx, _cache) => {
- const _component_n_scrollbar = Scrollbar;
- const _component_n_image = NImage;
- const _directive_loading = resolveDirective("loading");
- return openBlock(), createElementBlock("div", _hoisted_1, [
- createBaseVNode("div", _hoisted_2, [
- createVNode(_component_n_scrollbar, { "x-scrollable": "" }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_3, [
- (openBlock(), createElementBlock(Fragment, null, renderList(categories, (category, index2) => {
- return createBaseVNode("span", {
- key: category.value,
- class: normalizeClass(["play-list-type-item", [
- unref(setAnimationClass)("animate__bounceIn"),
- { active: selectedCategory.value === category.value }
- ]]),
- style: normalizeStyle(getAnimationDelay(index2)),
- onClick: ($event) => selectedCategory.value = category.value
- }, toDisplayString(category.label), 15, _hoisted_4);
- }), 64))
- ])
- ]),
- _: 1
- })
- ]),
- createVNode(_component_n_scrollbar, {
- size: 100,
- onScroll: handleScroll
- }, {
- default: withCtx(() => [
- withDirectives((openBlock(), createElementBlock("div", {
- class: normalizeClass(["mv-list-content", unref(setAnimationClass)("animate__bounceInLeft")])
- }, [
- (openBlock(true), createElementBlock(Fragment, null, renderList(mvList.value, (item, index2) => {
- return openBlock(), createElementBlock("div", {
- key: item.id,
- class: normalizeClass(["mv-item", unref(setAnimationClass)("animate__bounceIn")]),
- style: normalizeStyle(getAnimationDelay(index2))
- }, [
- createBaseVNode("div", {
- class: "mv-item-img",
- onClick: ($event) => handleShowMv(item, index2)
- }, [
- createVNode(_component_n_image, {
- class: "mv-item-img-img",
- src: unref(getImgUrl)(item.cover, "320y180"),
- lazy: "",
- "preview-disabled": ""
- }, null, 8, ["src"]),
- createBaseVNode("div", _hoisted_6, [
- createBaseVNode("div", _hoisted_7, toDisplayString(unref(formatNumber)(item.playCount)), 1),
- _cache[1] || (_cache[1] = createBaseVNode("i", { class: "iconfont icon-videofill" }, null, -1))
- ])
- ], 8, _hoisted_5),
- createBaseVNode("div", _hoisted_8, toDisplayString(item.name), 1)
- ], 6);
- }), 128)),
- loadingMore.value ? (openBlock(), createElementBlock("div", _hoisted_9, "加载中...")) : createCommentVNode("", true),
- !hasMore.value && !initLoading.value ? (openBlock(), createElementBlock("div", _hoisted_10, "没有更多了")) : createCommentVNode("", true)
- ], 2)), [
- [_directive_loading, initLoading.value]
- ])
- ]),
- _: 1
- }),
- createVNode(MvPlayer, {
- show: showMv.value,
- "onUpdate:show": _cache[0] || (_cache[0] = ($event) => showMv.value = $event),
- "current-mv": playMvItem.value,
- "is-prev-disabled": isPrevDisabled.value,
- onNext: playNextMv,
- onPrev: playPrevMv
- }, null, 8, ["show", "current-mv", "is-prev-disabled"])
- ]);
- };
- }
-});
-const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7366dc5a"]]);
-export {
- index as default
-};
diff --git a/out/renderer/assets/index-SvIREzLs.js.gz b/out/renderer/assets/index-SvIREzLs.js.gz
deleted file mode 100644
index 12f4ff8..0000000
Binary files a/out/renderer/assets/index-SvIREzLs.js.gz and /dev/null differ
diff --git a/out/renderer/assets/index-b8HibJP6.css b/out/renderer/assets/index-b8HibJP6.css
deleted file mode 100644
index db907d8..0000000
--- a/out/renderer/assets/index-b8HibJP6.css
+++ /dev/null
@@ -1,214 +0,0 @@
-.mv-list[data-v-7366dc5a] {
- display: flex;
- height: 100%;
- flex: 1 1 0%;
- flex-direction: column;
- overflow: hidden;
-}
-.mv-list-title[data-v-7366dc5a] {
- padding-bottom: 0.5rem;
- font-size: 1.25rem;
- line-height: 1.75rem;
- font-weight: 700;
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1));
-}
-.mv-list-title[data-v-7366dc5a]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.mv-list .play-list-type .title[data-v-7366dc5a] {
- margin-bottom: 0.5rem;
- font-size: 1.125rem;
- line-height: 1.75rem;
- font-weight: 700;
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1));
-}
-.mv-list .play-list-type .title[data-v-7366dc5a]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.mv-list .play-list-type .categories-wrapper[data-v-7366dc5a] {
- display: flex;
- align-items: center;
- padding-top: 0.5rem;
- padding-bottom: 0.5rem;
- white-space: nowrap;
-}
-.mv-list .play-list-type-item[data-v-7366dc5a] {
- margin-right: 0.75rem;
- display: inline-block;
- cursor: pointer;
- border-radius: 0.75rem;
- padding-top: 0.5rem;
- padding-bottom: 0.5rem;
- padding-left: 0.75rem;
- padding-right: 0.75rem;
- transition-property: all;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- transition-duration: 300ms;
- --tw-bg-opacity: 1;
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1));
-}
-.mv-list .play-list-type-item[data-v-7366dc5a]:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.mv-list .play-list-type-item[data-v-7366dc5a] {
- border-width: 1px;
- --tw-border-opacity: 1;
- border-color: rgb(229 231 235 / var(--tw-border-opacity, 1));
-}
-.mv-list .play-list-type-item[data-v-7366dc5a]:is(.dark *) {
- --tw-border-opacity: 1;
- border-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
-}
-.mv-list .play-list-type-item[data-v-7366dc5a]:hover {
- --tw-bg-opacity: 1;
- background-color: rgb(240 253 244 / var(--tw-bg-opacity, 1));
-}
-.mv-list .play-list-type-item[data-v-7366dc5a]:hover:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(20 83 45 / var(--tw-bg-opacity, 1));
-}
-.mv-list .play-list-type-item.active[data-v-7366dc5a] {
- --tw-border-opacity: 1;
- border-color: rgb(34 197 94 / var(--tw-border-opacity, 1));
- --tw-bg-opacity: 1;
- background-color: rgb(34 197 94 / var(--tw-bg-opacity, 1));
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.mv-list-content[data-v-7366dc5a] {
- margin-top: 0.5rem;
- display: grid;
- gap: 1rem;
- padding-bottom: 7rem;
- padding-right: 1rem;
- grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
-}
-.mv-list .mv-item[data-v-7366dc5a] {
- border-radius: 0.5rem;
- padding: 0.5rem;
- --tw-bg-opacity: 1;
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
-}
-.mv-list .mv-item[data-v-7366dc5a]:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
-}
-.mv-list .mv-item[data-v-7366dc5a] {
- border-width: 1px;
- --tw-border-opacity: 1;
- border-color: rgb(229 231 235 / var(--tw-border-opacity, 1));
-}
-.mv-list .mv-item[data-v-7366dc5a]:is(.dark *) {
- --tw-border-opacity: 1;
- border-color: rgb(55 65 81 / var(--tw-border-opacity, 1));
-}
-.mv-list .mv-item-img[data-v-7366dc5a] {
- position: relative;
- overflow: hidden;
- border-radius: 0.5rem;
- aspect-ratio: 16/9;
- line-height: 0;
-}
-.mv-list .mv-item-img:hover img[data-v-7366dc5a] {
- -o-object-position: top;
- object-position: top;
- transition-property: all;
- transition-duration: 300ms;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
-}
-.mv-list .mv-item-img:hover img[data-v-7366dc5a]:hover {
- --tw-scale-x: 1.1;
- --tw-scale-y: 1.1;
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
-}
-.mv-list .mv-item-img-img[data-v-7366dc5a] {
- height: 100%;
- width: 100%;
- overflow: hidden;
- border-radius: 0.5rem;
- -o-object-fit: cover;
- object-fit: cover;
-}
-.mv-list .mv-item-img .top[data-v-7366dc5a] {
- position: absolute;
- top: 0px;
- left: 0px;
- display: flex;
- height: 100%;
- width: 100%;
- cursor: pointer;
- align-items: center;
- justify-content: center;
- transition-property: all;
- transition-duration: 300ms;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
- --tw-bg-opacity: 0.6;
- opacity: 0;
-}
-.mv-list .mv-item-img .top i[data-v-7366dc5a] {
- font-size: 2.25rem;
- line-height: 2.5rem;
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.mv-list .mv-item-img .top .play-count[data-v-7366dc5a] {
- position: absolute;
- top: 0.5rem;
- right: 0.5rem;
- font-size: 0.875rem;
- line-height: 1.25rem;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
- --tw-text-opacity: 0.9;
-}
-.mv-list .mv-item-img .top[data-v-7366dc5a]:hover {
- opacity: 1;
-}
-.mv-list .mv-item-title[data-v-7366dc5a] {
- margin-top: 0.5rem;
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- font-size: 0.875rem;
- line-height: 1.25rem;
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1));
-}
-.mv-list .mv-item-title[data-v-7366dc5a]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
-}
-.loading-more[data-v-7366dc5a] {
- grid-column: 1 / -1;
- padding-top: 1rem;
- padding-bottom: 1rem;
- text-align: center;
- --tw-text-opacity: 1;
- color: rgb(107 114 128 / var(--tw-text-opacity, 1));
-}
-.loading-more[data-v-7366dc5a]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(156 163 175 / var(--tw-text-opacity, 1));
-}
-.no-more[data-v-7366dc5a] {
- grid-column: 1 / -1;
- padding-top: 1rem;
- padding-bottom: 1rem;
- text-align: center;
- --tw-text-opacity: 1;
- color: rgb(107 114 128 / var(--tw-text-opacity, 1));
-}
-.no-more[data-v-7366dc5a]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(156 163 175 / var(--tw-text-opacity, 1));
-}
\ No newline at end of file
diff --git a/out/renderer/assets/index-b8HibJP6.css.gz b/out/renderer/assets/index-b8HibJP6.css.gz
deleted file mode 100644
index 1099eaa..0000000
Binary files a/out/renderer/assets/index-b8HibJP6.css.gz and /dev/null differ
diff --git a/out/renderer/assets/index-s6QFASec.css b/out/renderer/assets/index-s6QFASec.css
deleted file mode 100644
index edc79b7..0000000
--- a/out/renderer/assets/index-s6QFASec.css
+++ /dev/null
@@ -1,228 +0,0 @@
-.list-page[data-v-f9f1189c] {
- position: relative;
- height: 100%;
- width: 100%;
- --tw-bg-opacity: 1;
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1))
-}.list-page[data-v-f9f1189c]:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1))
-}
-.recommend[data-v-f9f1189c] {
- height: 100%;
- width: 100%
-}
-.recommend-title[data-v-f9f1189c] {
- padding-bottom: 0.5rem;
- font-size: 1.125rem;
- line-height: 1.75rem;
- font-weight: 700;
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1))
-}
-.recommend-title[data-v-f9f1189c]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1))
-}
-.recommend-list[data-v-f9f1189c] {
- display: grid;
- -moz-column-gap: 2rem;
- column-gap: 2rem;
- row-gap: 1.5rem;
- padding-bottom: 7rem;
- padding-right: 1rem;
- grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
-}
-.recommend-item[data-v-f9f1189c] {
- display: flex;
- flex-direction: column
-}
-.recommend-item-img[data-v-f9f1189c] {
- position: relative;
- aspect-ratio: 1 / 1;
- width: 100%;
- overflow: hidden;
- border-radius: 0.75rem
-}
-.recommend-item-img-img[data-v-f9f1189c] {
- display: block;
- height: 100%;
- width: 100%
-}
-.recommend-item-img img[data-v-f9f1189c] {
- position: absolute;
- top: 0px;
- left: 0px;
- height: 100%;
- width: 100%;
- border-radius: 0.75rem;
- -o-object-fit: cover;
- object-fit: cover
-}
-.recommend-item-img:hover img[data-v-f9f1189c] {
- transition-property: all;
- transition-duration: 300ms;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1)
-}
-.recommend-item-img:hover img[data-v-f9f1189c]:hover {
- --tw-scale-x: 1.1;
- --tw-scale-y: 1.1;
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
-}
-.recommend-item-img .top[data-v-f9f1189c] {
- position: absolute;
- top: 0px;
- left: 0px;
- display: flex;
- height: 100%;
- width: 100%;
- cursor: pointer;
- align-items: center;
- justify-content: center;
- transition-property: all;
- transition-duration: 300ms;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
- --tw-bg-opacity: 0.5;
- opacity: 0
-}
-.recommend-item-img .top i[data-v-f9f1189c] {
- font-size: 3rem;
- line-height: 1;
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1));
- opacity: 0;
- transition-property: all;
- transition-duration: 500ms;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1)
-}
-.recommend-item-img .top[data-v-f9f1189c]:hover {
- opacity: 1
-}
-.recommend-item-img .top:hover i[data-v-f9f1189c] {
- --tw-scale-x: 1.5;
- --tw-scale-y: 1.5;
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
- opacity: 1
-}
-.recommend-item-img .top .play-count[data-v-f9f1189c] {
- position: absolute;
- top: 0.5rem;
- left: 0.5rem;
- font-size: 0.875rem;
- line-height: 1.25rem;
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1))
-}
-.recommend-item-title[data-v-f9f1189c] {
- margin-top: 0.5rem;
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- font-size: 0.875rem;
- line-height: 1.25rem;
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1))
-}
-.recommend-item-title[data-v-f9f1189c]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1))
-}
-.loading-more[data-v-f9f1189c] {
- display: flex;
- align-items: center;
- justify-content: center;
- padding-top: 1rem;
- padding-bottom: 1rem;
- --tw-text-opacity: 1;
- color: rgb(107 114 128 / var(--tw-text-opacity, 1))
-}
-.loading-more[data-v-f9f1189c]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(156 163 175 / var(--tw-text-opacity, 1))
-}
-.no-more[data-v-f9f1189c] {
- padding-top: 1rem;
- padding-bottom: 1rem;
- text-align: center;
- --tw-text-opacity: 1;
- color: rgb(107 114 128 / var(--tw-text-opacity, 1))
-}
-.no-more[data-v-f9f1189c]:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(156 163 175 / var(--tw-text-opacity, 1))
-}
-.mobile .recommend-title[data-v-f9f1189c] {
- padding-left: 1rem;
- padding-right: 1rem;
- font-size: 1.25rem;
- line-height: 1.75rem;
- font-weight: 700
-}
-.mobile .recommend-list[data-v-f9f1189c] {
- gap: 1rem;
- padding-left: 1rem;
- padding-right: 1rem;
- grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
-}
-.play-list-type .categories-wrapper[data-v-f9f1189c] {
- display: flex;
- align-items: center;
- padding-top: 0.5rem;
- padding-bottom: 0.5rem;
- white-space: nowrap
-}
-.play-list-type-item[data-v-f9f1189c] {
- margin-right: 0.75rem;
- display: inline-block;
- cursor: pointer;
- border-radius: 0.75rem;
- padding-top: 0.5rem;
- padding-bottom: 0.5rem;
- padding-left: 0.75rem;
- padding-right: 0.75rem;
- transition-property: all;
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- transition-duration: 300ms;
- --tw-bg-opacity: 1;
- background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
- --tw-text-opacity: 1;
- color: rgb(17 24 39 / var(--tw-text-opacity, 1))
-}
-.play-list-type-item[data-v-f9f1189c]:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1))
-}
-.play-list-type-item[data-v-f9f1189c] {
- border-width: 1px;
- --tw-border-opacity: 1;
- border-color: rgb(229 231 235 / var(--tw-border-opacity, 1))
-}
-.play-list-type-item[data-v-f9f1189c]:is(.dark *) {
- --tw-border-opacity: 1;
- border-color: rgb(55 65 81 / var(--tw-border-opacity, 1))
-}
-.play-list-type-item[data-v-f9f1189c]:hover {
- --tw-bg-opacity: 1;
- background-color: rgb(240 253 244 / var(--tw-bg-opacity, 1))
-}
-.play-list-type-item[data-v-f9f1189c]:hover:is(.dark *) {
- --tw-bg-opacity: 1;
- background-color: rgb(20 83 45 / var(--tw-bg-opacity, 1))
-}
-.play-list-type-item.active[data-v-f9f1189c] {
- --tw-border-opacity: 1;
- border-color: rgb(34 197 94 / var(--tw-border-opacity, 1));
- --tw-bg-opacity: 1;
- background-color: rgb(34 197 94 / var(--tw-bg-opacity, 1));
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity, 1))
-}
-.mobile .play-list-type[data-v-f9f1189c] {
- margin-left: 0px;
- margin-right: 0px;
- width: 100%
-}
\ No newline at end of file
diff --git a/out/renderer/assets/index-s6QFASec.css.gz b/out/renderer/assets/index-s6QFASec.css.gz
deleted file mode 100644
index c32b54c..0000000
Binary files a/out/renderer/assets/index-s6QFASec.css.gz and /dev/null differ
diff --git a/out/renderer/assets/login-BsPxQYi6.js b/out/renderer/assets/login-BsPxQYi6.js
deleted file mode 100644
index c9341fa..0000000
--- a/out/renderer/assets/login-BsPxQYi6.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import { as as inject, bi as throwError, bj as messageApiInjectionKey, ad as request } from "./index-DKaFsuse.js";
-function useMessage() {
- const api = inject(messageApiInjectionKey, null);
- if (api === null) {
- throwError("use-message", "No outer founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A.");
- }
- return api;
-}
-function getQrKey() {
- return request.get("/login/qr/key");
-}
-function createQr(key) {
- return request.get("/login/qr/create", { params: { key, qrimg: true } });
-}
-function checkQr(key) {
- return request.get("/login/qr/check", { params: { key } });
-}
-function getUserDetail() {
- return request.get("/user/account");
-}
-function logout() {
- return request.get("/logout");
-}
-function loginByCellphone(phone, password) {
- return request.post("/login/cellphone", {
- phone,
- password
- });
-}
-export {
- checkQr as a,
- getUserDetail as b,
- createQr as c,
- logout as d,
- getQrKey as g,
- loginByCellphone as l,
- useMessage as u
-};
diff --git a/out/renderer/assets/login-BsPxQYi6.js.gz b/out/renderer/assets/login-BsPxQYi6.js.gz
deleted file mode 100644
index dda92be..0000000
Binary files a/out/renderer/assets/login-BsPxQYi6.js.gz and /dev/null differ
diff --git a/out/renderer/assets/remixicon-BBpe-Xu7.woff b/out/renderer/assets/remixicon-BBpe-Xu7.woff
deleted file mode 100644
index 3195768..0000000
Binary files a/out/renderer/assets/remixicon-BBpe-Xu7.woff and /dev/null differ
diff --git a/out/renderer/assets/remixicon-BVJ9S1ev.eot b/out/renderer/assets/remixicon-BVJ9S1ev.eot
deleted file mode 100644
index acd1589..0000000
Binary files a/out/renderer/assets/remixicon-BVJ9S1ev.eot and /dev/null differ
diff --git a/out/renderer/assets/remixicon-BVvFtaex.woff2 b/out/renderer/assets/remixicon-BVvFtaex.woff2
deleted file mode 100644
index c6c8031..0000000
Binary files a/out/renderer/assets/remixicon-BVvFtaex.woff2 and /dev/null differ
diff --git a/out/renderer/assets/remixicon-C2wQ2gtc.svg b/out/renderer/assets/remixicon-C2wQ2gtc.svg
deleted file mode 100644
index 6e37973..0000000
--- a/out/renderer/assets/remixicon-C2wQ2gtc.svg
+++ /dev/null
@@ -1,9196 +0,0 @@
-
-
-
-
diff --git a/out/renderer/assets/remixicon-CfJD46dY.ttf b/out/renderer/assets/remixicon-CfJD46dY.ttf
deleted file mode 100644
index 1373ccd..0000000
Binary files a/out/renderer/assets/remixicon-CfJD46dY.ttf and /dev/null differ
diff --git a/out/renderer/assets/use-locale-DLWAOXez.js b/out/renderer/assets/use-locale-DLWAOXez.js
deleted file mode 100644
index 648f698..0000000
--- a/out/renderer/assets/use-locale-DLWAOXez.js
+++ /dev/null
@@ -1,1476 +0,0 @@
-import { o as onMounted, a as onBeforeUnmount, c9 as isBrowser, aL as createInjectionKey, as as inject, aZ as modalBodyInjectionKey, aX as drawerBodyInjectionKey, aY as popoverBodyInjectionKey, r as ref, J as on, aS as off, D as useMemo, d as defineComponent, $ as provide, br as getCurrentInstance, ca as getSlot, w as withDirectives, cb as getFirstVNode, cc as CssRender, at as useSsrAdapter, E as watch, A as toRef, aR as isMounted, l as h, b4 as zindexable, b1 as LazyTeleport, M as nextTick, cd as configProviderInjectionKey, G as computed } from "./index-DKaFsuse.js";
-let onceCbs = [];
-const paramsMap = /* @__PURE__ */ new WeakMap();
-function flushOnceCallbacks() {
- onceCbs.forEach((cb) => cb(...paramsMap.get(cb)));
- onceCbs = [];
-}
-function beforeNextFrameOnce(cb, ...params) {
- paramsMap.set(cb, params);
- if (onceCbs.includes(cb))
- return;
- onceCbs.push(cb) === 1 && requestAnimationFrame(flushOnceCallbacks);
-}
-let fontsReady;
-let isFontReady;
-const init = () => {
- var _a, _b;
- fontsReady = isBrowser ? (_b = (_a = document) === null || _a === void 0 ? void 0 : _a.fonts) === null || _b === void 0 ? void 0 : _b.ready : void 0;
- isFontReady = false;
- if (fontsReady !== void 0) {
- void fontsReady.then(() => {
- isFontReady = true;
- });
- } else {
- isFontReady = true;
- }
-};
-init();
-function onFontsReady(cb) {
- if (isFontReady)
- return;
- let deactivated = false;
- onMounted(() => {
- if (!isFontReady) {
- fontsReady === null || fontsReady === void 0 ? void 0 : fontsReady.then(() => {
- if (deactivated)
- return;
- cb();
- });
- }
- });
- onBeforeUnmount(() => {
- deactivated = true;
- });
-}
-const internalSelectionMenuBodyInjectionKey = createInjectionKey("n-internal-select-menu-body");
-const teleportDisabled = "__disabled__";
-function useAdjustedTo(props) {
- const modal = inject(modalBodyInjectionKey, null);
- const drawer = inject(drawerBodyInjectionKey, null);
- const popover = inject(popoverBodyInjectionKey, null);
- const selectMenu = inject(internalSelectionMenuBodyInjectionKey, null);
- const fullscreenElementRef = ref();
- if (typeof document !== "undefined") {
- fullscreenElementRef.value = document.fullscreenElement;
- const handleFullscreenChange = () => {
- fullscreenElementRef.value = document.fullscreenElement;
- };
- onMounted(() => {
- on("fullscreenchange", document, handleFullscreenChange);
- });
- onBeforeUnmount(() => {
- off("fullscreenchange", document, handleFullscreenChange);
- });
- }
- return useMemo(() => {
- var _a;
- const {
- to
- } = props;
- if (to !== void 0) {
- if (to === false) return teleportDisabled;
- if (to === true) return fullscreenElementRef.value || "body";
- return to;
- }
- if (modal === null || modal === void 0 ? void 0 : modal.value) {
- return (_a = modal.value.$el) !== null && _a !== void 0 ? _a : modal.value;
- }
- if (drawer === null || drawer === void 0 ? void 0 : drawer.value) return drawer.value;
- if (popover === null || popover === void 0 ? void 0 : popover.value) return popover.value;
- if (selectMenu === null || selectMenu === void 0 ? void 0 : selectMenu.value) return selectMenu.value;
- return to !== null && to !== void 0 ? to : fullscreenElementRef.value || "body";
- });
-}
-useAdjustedTo.tdkey = teleportDisabled;
-useAdjustedTo.propTo = {
- type: [String, Object, Boolean],
- default: void 0
-};
-let viewMeasurer = null;
-function ensureViewBoundingRect() {
- if (viewMeasurer === null) {
- viewMeasurer = document.getElementById("v-binder-view-measurer");
- if (viewMeasurer === null) {
- viewMeasurer = document.createElement("div");
- viewMeasurer.id = "v-binder-view-measurer";
- const { style: style2 } = viewMeasurer;
- style2.position = "fixed";
- style2.left = "0";
- style2.right = "0";
- style2.top = "0";
- style2.bottom = "0";
- style2.pointerEvents = "none";
- style2.visibility = "hidden";
- document.body.appendChild(viewMeasurer);
- }
- }
- return viewMeasurer.getBoundingClientRect();
-}
-function getPointRect(x, y) {
- const viewRect = ensureViewBoundingRect();
- return {
- top: y,
- left: x,
- height: 0,
- width: 0,
- right: viewRect.width - x,
- bottom: viewRect.height - y
- };
-}
-function getRect(el) {
- const elRect = el.getBoundingClientRect();
- const viewRect = ensureViewBoundingRect();
- return {
- left: elRect.left - viewRect.left,
- top: elRect.top - viewRect.top,
- bottom: viewRect.height + viewRect.top - elRect.bottom,
- right: viewRect.width + viewRect.left - elRect.right,
- width: elRect.width,
- height: elRect.height
- };
-}
-function getParentNode(node) {
- if (node.nodeType === 9) {
- return null;
- }
- return node.parentNode;
-}
-function getScrollParent(node) {
- if (node === null)
- return null;
- const parentNode = getParentNode(node);
- if (parentNode === null) {
- return null;
- }
- if (parentNode.nodeType === 9) {
- return document;
- }
- if (parentNode.nodeType === 1) {
- const { overflow, overflowX, overflowY } = getComputedStyle(parentNode);
- if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
- return parentNode;
- }
- }
- return getScrollParent(parentNode);
-}
-const Binder = defineComponent({
- name: "Binder",
- props: {
- syncTargetWithParent: Boolean,
- syncTarget: {
- type: Boolean,
- default: true
- }
- },
- setup(props) {
- var _a;
- provide("VBinder", (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy);
- const VBinder = inject("VBinder", null);
- const targetRef = ref(null);
- const setTargetRef = (el) => {
- targetRef.value = el;
- if (VBinder && props.syncTargetWithParent) {
- VBinder.setTargetRef(el);
- }
- };
- let scrollableNodes = [];
- const ensureScrollListener = () => {
- let cursor = targetRef.value;
- while (true) {
- cursor = getScrollParent(cursor);
- if (cursor === null)
- break;
- scrollableNodes.push(cursor);
- }
- for (const el of scrollableNodes) {
- on("scroll", el, onScroll, true);
- }
- };
- const removeScrollListeners = () => {
- for (const el of scrollableNodes) {
- off("scroll", el, onScroll, true);
- }
- scrollableNodes = [];
- };
- const followerScrollListeners = /* @__PURE__ */ new Set();
- const addScrollListener = (listener) => {
- if (followerScrollListeners.size === 0) {
- ensureScrollListener();
- }
- if (!followerScrollListeners.has(listener)) {
- followerScrollListeners.add(listener);
- }
- };
- const removeScrollListener = (listener) => {
- if (followerScrollListeners.has(listener)) {
- followerScrollListeners.delete(listener);
- }
- if (followerScrollListeners.size === 0) {
- removeScrollListeners();
- }
- };
- const onScroll = () => {
- beforeNextFrameOnce(onScrollRaf);
- };
- const onScrollRaf = () => {
- followerScrollListeners.forEach((listener) => listener());
- };
- const followerResizeListeners = /* @__PURE__ */ new Set();
- const addResizeListener = (listener) => {
- if (followerResizeListeners.size === 0) {
- on("resize", window, onResize);
- }
- if (!followerResizeListeners.has(listener)) {
- followerResizeListeners.add(listener);
- }
- };
- const removeResizeListener = (listener) => {
- if (followerResizeListeners.has(listener)) {
- followerResizeListeners.delete(listener);
- }
- if (followerResizeListeners.size === 0) {
- off("resize", window, onResize);
- }
- };
- const onResize = () => {
- followerResizeListeners.forEach((listener) => listener());
- };
- onBeforeUnmount(() => {
- off("resize", window, onResize);
- removeScrollListeners();
- });
- return {
- targetRef,
- setTargetRef,
- addScrollListener,
- removeScrollListener,
- addResizeListener,
- removeResizeListener
- };
- },
- render() {
- return getSlot("binder", this.$slots);
- }
-});
-const VTarget = defineComponent({
- name: "Target",
- setup() {
- const { setTargetRef, syncTarget } = inject("VBinder");
- const setTargetDirective = {
- mounted: setTargetRef,
- updated: setTargetRef
- };
- return {
- syncTarget,
- setTargetDirective
- };
- },
- render() {
- const { syncTarget, setTargetDirective } = this;
- if (syncTarget) {
- return withDirectives(getFirstVNode("follower", this.$slots), [
- [setTargetDirective]
- ]);
- }
- return getFirstVNode("follower", this.$slots);
- }
-});
-const { c } = CssRender();
-const cssrAnchorMetaName = "vueuc-style";
-const oppositionPositions = {
- top: "bottom",
- bottom: "top",
- left: "right",
- right: "left"
-};
-const oppositeAligns = {
- start: "end",
- center: "center",
- end: "start"
-};
-const propToCompare = {
- top: "height",
- bottom: "height",
- left: "width",
- right: "width"
-};
-const transformOrigins = {
- "bottom-start": "top left",
- bottom: "top center",
- "bottom-end": "top right",
- "top-start": "bottom left",
- top: "bottom center",
- "top-end": "bottom right",
- "right-start": "top left",
- right: "center left",
- "right-end": "bottom left",
- "left-start": "top right",
- left: "center right",
- "left-end": "bottom right"
-};
-const overlapTransformOrigin = {
- "bottom-start": "bottom left",
- bottom: "bottom center",
- "bottom-end": "bottom right",
- "top-start": "top left",
- top: "top center",
- "top-end": "top right",
- "right-start": "top right",
- right: "center right",
- "right-end": "bottom right",
- "left-start": "top left",
- left: "center left",
- "left-end": "bottom left"
-};
-const oppositeAlignCssPositionProps = {
- "bottom-start": "right",
- "bottom-end": "left",
- "top-start": "right",
- "top-end": "left",
- "right-start": "bottom",
- "right-end": "top",
- "left-start": "bottom",
- "left-end": "top"
-};
-const keepOffsetDirection = {
- top: true,
- bottom: false,
- left: true,
- right: false
- // left--
-};
-const cssPositionToOppositeAlign = {
- top: "end",
- bottom: "start",
- left: "end",
- right: "start"
-};
-function getPlacementAndOffsetOfFollower(placement, targetRect, followerRect, shift, flip, overlap) {
- if (!flip || overlap) {
- return { placement, top: 0, left: 0 };
- }
- const [position, align] = placement.split("-");
- let properAlign = align !== null && align !== void 0 ? align : "center";
- let properOffset = {
- top: 0,
- left: 0
- };
- const deriveOffset = (oppositeAlignCssSizeProp, alignCssPositionProp, offsetVertically2) => {
- let left = 0;
- let top = 0;
- const diff = followerRect[oppositeAlignCssSizeProp] - targetRect[alignCssPositionProp] - targetRect[oppositeAlignCssSizeProp];
- if (diff > 0 && shift) {
- if (offsetVertically2) {
- top = keepOffsetDirection[alignCssPositionProp] ? diff : -diff;
- } else {
- left = keepOffsetDirection[alignCssPositionProp] ? diff : -diff;
- }
- }
- return {
- left,
- top
- };
- };
- const offsetVertically = position === "left" || position === "right";
- if (properAlign !== "center") {
- const oppositeAlignCssPositionProp = oppositeAlignCssPositionProps[placement];
- const currentAlignCssPositionProp = oppositionPositions[oppositeAlignCssPositionProp];
- const oppositeAlignCssSizeProp = propToCompare[oppositeAlignCssPositionProp];
- if (followerRect[oppositeAlignCssSizeProp] > targetRect[oppositeAlignCssSizeProp]) {
- if (
- // current space is not enough
- // ----------[ target ]---------|
- // -------[ follower ]
- targetRect[oppositeAlignCssPositionProp] + targetRect[oppositeAlignCssSizeProp] < followerRect[oppositeAlignCssSizeProp]
- ) {
- const followerOverTargetSize = (followerRect[oppositeAlignCssSizeProp] - targetRect[oppositeAlignCssSizeProp]) / 2;
- if (targetRect[oppositeAlignCssPositionProp] < followerOverTargetSize || targetRect[currentAlignCssPositionProp] < followerOverTargetSize) {
- if (targetRect[oppositeAlignCssPositionProp] < targetRect[currentAlignCssPositionProp]) {
- properAlign = oppositeAligns[align];
- properOffset = deriveOffset(oppositeAlignCssSizeProp, currentAlignCssPositionProp, offsetVertically);
- } else {
- properOffset = deriveOffset(oppositeAlignCssSizeProp, oppositeAlignCssPositionProp, offsetVertically);
- }
- } else {
- properAlign = "center";
- }
- }
- } else if (followerRect[oppositeAlignCssSizeProp] < targetRect[oppositeAlignCssSizeProp]) {
- if (targetRect[currentAlignCssPositionProp] < 0 && // opposite align has larger space
- // ------------[ target ]
- // ----------------[follower]
- targetRect[oppositeAlignCssPositionProp] > targetRect[currentAlignCssPositionProp]) {
- properAlign = oppositeAligns[align];
- }
- }
- } else {
- const possibleAlternativeAlignCssPositionProp1 = position === "bottom" || position === "top" ? "left" : "top";
- const possibleAlternativeAlignCssPositionProp2 = oppositionPositions[possibleAlternativeAlignCssPositionProp1];
- const alternativeAlignCssSizeProp = propToCompare[possibleAlternativeAlignCssPositionProp1];
- const followerOverTargetSize = (followerRect[alternativeAlignCssSizeProp] - targetRect[alternativeAlignCssSizeProp]) / 2;
- if (
- // center is not enough
- // ----------- [ target ]--|
- // -------[ follower ]
- targetRect[possibleAlternativeAlignCssPositionProp1] < followerOverTargetSize || targetRect[possibleAlternativeAlignCssPositionProp2] < followerOverTargetSize
- ) {
- if (targetRect[possibleAlternativeAlignCssPositionProp1] > targetRect[possibleAlternativeAlignCssPositionProp2]) {
- properAlign = cssPositionToOppositeAlign[possibleAlternativeAlignCssPositionProp1];
- properOffset = deriveOffset(alternativeAlignCssSizeProp, possibleAlternativeAlignCssPositionProp1, offsetVertically);
- } else {
- properAlign = cssPositionToOppositeAlign[possibleAlternativeAlignCssPositionProp2];
- properOffset = deriveOffset(alternativeAlignCssSizeProp, possibleAlternativeAlignCssPositionProp2, offsetVertically);
- }
- }
- }
- let properPosition = position;
- if (
- // space is not enough
- targetRect[position] < followerRect[propToCompare[position]] && // opposite position's space is larger
- targetRect[position] < targetRect[oppositionPositions[position]]
- ) {
- properPosition = oppositionPositions[position];
- }
- return {
- placement: properAlign !== "center" ? `${properPosition}-${properAlign}` : properPosition,
- left: properOffset.left,
- top: properOffset.top
- };
-}
-function getProperTransformOrigin(placement, overlap) {
- if (overlap)
- return overlapTransformOrigin[placement];
- return transformOrigins[placement];
-}
-function getOffset(placement, offsetRect, targetRect, offsetTopToStandardPlacement, offsetLeftToStandardPlacement, overlap) {
- if (overlap) {
- switch (placement) {
- case "bottom-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left)}px`,
- transform: "translateY(-100%)"
- };
- case "bottom-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
- transform: "translateX(-100%) translateY(-100%)"
- };
- case "top-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left)}px`,
- transform: ""
- };
- case "top-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
- transform: "translateX(-100%)"
- };
- case "right-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
- transform: "translateX(-100%)"
- };
- case "right-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
- transform: "translateX(-100%) translateY(-100%)"
- };
- case "left-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left)}px`,
- transform: ""
- };
- case "left-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left)}px`,
- transform: "translateY(-100%)"
- };
- case "top":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2)}px`,
- transform: "translateX(-50%)"
- };
- case "right":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
- transform: "translateX(-100%) translateY(-50%)"
- };
- case "left":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left)}px`,
- transform: "translateY(-50%)"
- };
- case "bottom":
- default:
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2)}px`,
- transform: "translateX(-50%) translateY(-100%)"
- };
- }
- }
- switch (placement) {
- case "bottom-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
- transform: ""
- };
- case "bottom-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
- transform: "translateX(-100%)"
- };
- case "top-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
- transform: "translateY(-100%)"
- };
- case "top-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
- transform: "translateX(-100%) translateY(-100%)"
- };
- case "right-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
- transform: ""
- };
- case "right-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
- transform: "translateY(-100%)"
- };
- case "left-start":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
- transform: "translateX(-100%)"
- };
- case "left-end":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
- transform: "translateX(-100%) translateY(-100%)"
- };
- case "top":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2 + offsetLeftToStandardPlacement)}px`,
- transform: "translateY(-100%) translateX(-50%)"
- };
- case "right":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2 + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
- transform: "translateY(-50%)"
- };
- case "left":
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2 + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
- transform: "translateY(-50%) translateX(-100%)"
- };
- case "bottom":
- default:
- return {
- top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
- left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2 + offsetLeftToStandardPlacement)}px`,
- transform: "translateX(-50%)"
- };
- }
-}
-const style = c([
- c(".v-binder-follower-container", {
- position: "absolute",
- left: "0",
- right: "0",
- top: "0",
- height: "0",
- pointerEvents: "none",
- zIndex: "auto"
- }),
- c(".v-binder-follower-content", {
- position: "absolute",
- zIndex: "auto"
- }, [
- c("> *", {
- pointerEvents: "all"
- })
- ])
-]);
-const VFollower = defineComponent({
- name: "Follower",
- inheritAttrs: false,
- props: {
- show: Boolean,
- enabled: {
- type: Boolean,
- default: void 0
- },
- placement: {
- type: String,
- default: "bottom"
- },
- syncTrigger: {
- type: Array,
- default: ["resize", "scroll"]
- },
- to: [String, Object],
- flip: {
- type: Boolean,
- default: true
- },
- internalShift: Boolean,
- x: Number,
- y: Number,
- width: String,
- minWidth: String,
- containerClass: String,
- teleportDisabled: Boolean,
- zindexable: {
- type: Boolean,
- default: true
- },
- zIndex: Number,
- overlap: Boolean
- },
- setup(props) {
- const VBinder = inject("VBinder");
- const mergedEnabledRef = useMemo(() => {
- return props.enabled !== void 0 ? props.enabled : props.show;
- });
- const followerRef = ref(null);
- const offsetContainerRef = ref(null);
- const ensureListeners = () => {
- const { syncTrigger } = props;
- if (syncTrigger.includes("scroll")) {
- VBinder.addScrollListener(syncPosition);
- }
- if (syncTrigger.includes("resize")) {
- VBinder.addResizeListener(syncPosition);
- }
- };
- const removeListeners = () => {
- VBinder.removeScrollListener(syncPosition);
- VBinder.removeResizeListener(syncPosition);
- };
- onMounted(() => {
- if (mergedEnabledRef.value) {
- syncPosition();
- ensureListeners();
- }
- });
- const ssrAdapter = useSsrAdapter();
- style.mount({
- id: "vueuc/binder",
- head: true,
- anchorMetaName: cssrAnchorMetaName,
- ssr: ssrAdapter
- });
- onBeforeUnmount(() => {
- removeListeners();
- });
- onFontsReady(() => {
- if (mergedEnabledRef.value) {
- syncPosition();
- }
- });
- const syncPosition = () => {
- if (!mergedEnabledRef.value) {
- return;
- }
- const follower = followerRef.value;
- if (follower === null)
- return;
- const target = VBinder.targetRef;
- const { x, y, overlap } = props;
- const targetRect = x !== void 0 && y !== void 0 ? getPointRect(x, y) : getRect(target);
- follower.style.setProperty("--v-target-width", `${Math.round(targetRect.width)}px`);
- follower.style.setProperty("--v-target-height", `${Math.round(targetRect.height)}px`);
- const { width, minWidth, placement, internalShift, flip } = props;
- follower.setAttribute("v-placement", placement);
- if (overlap) {
- follower.setAttribute("v-overlap", "");
- } else {
- follower.removeAttribute("v-overlap");
- }
- const { style: style2 } = follower;
- if (width === "target") {
- style2.width = `${targetRect.width}px`;
- } else if (width !== void 0) {
- style2.width = width;
- } else {
- style2.width = "";
- }
- if (minWidth === "target") {
- style2.minWidth = `${targetRect.width}px`;
- } else if (minWidth !== void 0) {
- style2.minWidth = minWidth;
- } else {
- style2.minWidth = "";
- }
- const followerRect = getRect(follower);
- const offsetContainerRect = getRect(offsetContainerRef.value);
- const { left: offsetLeftToStandardPlacement, top: offsetTopToStandardPlacement, placement: properPlacement } = getPlacementAndOffsetOfFollower(placement, targetRect, followerRect, internalShift, flip, overlap);
- const properTransformOrigin = getProperTransformOrigin(properPlacement, overlap);
- const { left, top, transform } = getOffset(properPlacement, offsetContainerRect, targetRect, offsetTopToStandardPlacement, offsetLeftToStandardPlacement, overlap);
- follower.setAttribute("v-placement", properPlacement);
- follower.style.setProperty("--v-offset-left", `${Math.round(offsetLeftToStandardPlacement)}px`);
- follower.style.setProperty("--v-offset-top", `${Math.round(offsetTopToStandardPlacement)}px`);
- follower.style.transform = `translateX(${left}) translateY(${top}) ${transform}`;
- follower.style.setProperty("--v-transform-origin", properTransformOrigin);
- follower.style.transformOrigin = properTransformOrigin;
- };
- watch(mergedEnabledRef, (value) => {
- if (value) {
- ensureListeners();
- syncOnNextTick();
- } else {
- removeListeners();
- }
- });
- const syncOnNextTick = () => {
- nextTick().then(syncPosition).catch((e) => console.error(e));
- };
- [
- "placement",
- "x",
- "y",
- "internalShift",
- "flip",
- "width",
- "overlap",
- "minWidth"
- ].forEach((prop) => {
- watch(toRef(props, prop), syncPosition);
- });
- ["teleportDisabled"].forEach((prop) => {
- watch(toRef(props, prop), syncOnNextTick);
- });
- watch(toRef(props, "syncTrigger"), (value) => {
- if (!value.includes("resize")) {
- VBinder.removeResizeListener(syncPosition);
- } else {
- VBinder.addResizeListener(syncPosition);
- }
- if (!value.includes("scroll")) {
- VBinder.removeScrollListener(syncPosition);
- } else {
- VBinder.addScrollListener(syncPosition);
- }
- });
- const isMountedRef = isMounted();
- const mergedToRef = useMemo(() => {
- const { to } = props;
- if (to !== void 0)
- return to;
- if (isMountedRef.value) {
- return void 0;
- }
- return void 0;
- });
- return {
- VBinder,
- mergedEnabled: mergedEnabledRef,
- offsetContainerRef,
- followerRef,
- mergedTo: mergedToRef,
- syncPosition
- };
- },
- render() {
- return h(LazyTeleport, {
- show: this.show,
- to: this.mergedTo,
- disabled: this.teleportDisabled
- }, {
- default: () => {
- var _a, _b;
- const vNode = h("div", {
- class: ["v-binder-follower-container", this.containerClass],
- ref: "offsetContainerRef"
- }, [
- h("div", {
- class: "v-binder-follower-content",
- ref: "followerRef"
- }, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a))
- ]);
- if (this.zindexable) {
- return withDirectives(vNode, [
- [
- zindexable,
- {
- enabled: this.mergedEnabled,
- zIndex: this.zIndex
- }
- ]
- ]);
- }
- return vNode;
- }
- });
- }
-});
-const enUS$1 = {
- name: "en-US",
- global: {
- undo: "Undo",
- redo: "Redo",
- confirm: "Confirm",
- clear: "Clear"
- },
- Popconfirm: {
- positiveText: "Confirm",
- negativeText: "Cancel"
- },
- Cascader: {
- placeholder: "Please Select",
- loading: "Loading",
- loadingRequiredMessage: (label) => `Please load all ${label}'s descendants before checking it.`
- },
- Time: {
- dateFormat: "yyyy-MM-dd",
- dateTimeFormat: "yyyy-MM-dd HH:mm:ss"
- },
- DatePicker: {
- yearFormat: "yyyy",
- monthFormat: "MMM",
- dayFormat: "eeeeee",
- yearTypeFormat: "yyyy",
- monthTypeFormat: "yyyy-MM",
- dateFormat: "yyyy-MM-dd",
- dateTimeFormat: "yyyy-MM-dd HH:mm:ss",
- quarterFormat: "yyyy-qqq",
- weekFormat: "YYYY-w",
- clear: "Clear",
- now: "Now",
- confirm: "Confirm",
- selectTime: "Select Time",
- selectDate: "Select Date",
- datePlaceholder: "Select Date",
- datetimePlaceholder: "Select Date and Time",
- monthPlaceholder: "Select Month",
- yearPlaceholder: "Select Year",
- quarterPlaceholder: "Select Quarter",
- weekPlaceholder: "Select Week",
- startDatePlaceholder: "Start Date",
- endDatePlaceholder: "End Date",
- startDatetimePlaceholder: "Start Date and Time",
- endDatetimePlaceholder: "End Date and Time",
- startMonthPlaceholder: "Start Month",
- endMonthPlaceholder: "End Month",
- monthBeforeYear: true,
- firstDayOfWeek: 6,
- today: "Today"
- },
- DataTable: {
- checkTableAll: "Select all in the table",
- uncheckTableAll: "Unselect all in the table",
- confirm: "Confirm",
- clear: "Clear"
- },
- LegacyTransfer: {
- sourceTitle: "Source",
- targetTitle: "Target"
- },
- Transfer: {
- selectAll: "Select all",
- unselectAll: "Unselect all",
- clearAll: "Clear",
- total: (num) => `Total ${num} items`,
- selected: (num) => `${num} items selected`
- },
- Empty: {
- description: "No Data"
- },
- Select: {
- placeholder: "Please Select"
- },
- TimePicker: {
- placeholder: "Select Time",
- positiveText: "OK",
- negativeText: "Cancel",
- now: "Now",
- clear: "Clear"
- },
- Pagination: {
- goto: "Goto",
- selectionSuffix: "page"
- },
- DynamicTags: {
- add: "Add"
- },
- Log: {
- loading: "Loading"
- },
- Input: {
- placeholder: "Please Input"
- },
- InputNumber: {
- placeholder: "Please Input"
- },
- DynamicInput: {
- create: "Create"
- },
- ThemeEditor: {
- title: "Theme Editor",
- clearAllVars: "Clear All Variables",
- clearSearch: "Clear Search",
- filterCompName: "Filter Component Name",
- filterVarName: "Filter Variable Name",
- import: "Import",
- export: "Export",
- restore: "Reset to Default"
- },
- Image: {
- tipPrevious: "Previous picture (←)",
- tipNext: "Next picture (→)",
- tipCounterclockwise: "Counterclockwise",
- tipClockwise: "Clockwise",
- tipZoomOut: "Zoom out",
- tipZoomIn: "Zoom in",
- tipDownload: "Download",
- tipClose: "Close (Esc)",
- // TODO: translation
- tipOriginalSize: "Zoom to original size"
- }
-};
-function buildFormatLongFn(args) {
- return (options = {}) => {
- const width = options.width ? String(options.width) : args.defaultWidth;
- const format = args.formats[width] || args.formats[args.defaultWidth];
- return format;
- };
-}
-function buildLocalizeFn(args) {
- return (value, options) => {
- const context = options?.context ? String(options.context) : "standalone";
- let valuesArray;
- if (context === "formatting" && args.formattingValues) {
- const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
- const width = options?.width ? String(options.width) : defaultWidth;
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
- } else {
- const defaultWidth = args.defaultWidth;
- const width = options?.width ? String(options.width) : args.defaultWidth;
- valuesArray = args.values[width] || args.values[defaultWidth];
- }
- const index = args.argumentCallback ? args.argumentCallback(value) : value;
- return valuesArray[index];
- };
-}
-function buildMatchFn(args) {
- return (string, options = {}) => {
- const width = options.width;
- const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
- const matchResult = string.match(matchPattern);
- if (!matchResult) {
- return null;
- }
- const matchedString = matchResult[0];
- const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
- const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
- findKey(parsePatterns, (pattern) => pattern.test(matchedString))
- );
- let value;
- value = args.valueCallback ? args.valueCallback(key) : key;
- value = options.valueCallback ? (
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
- options.valueCallback(value)
- ) : value;
- const rest = string.slice(matchedString.length);
- return { value, rest };
- };
-}
-function findKey(object, predicate) {
- for (const key in object) {
- if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
- return key;
- }
- }
- return void 0;
-}
-function findIndex(array, predicate) {
- for (let key = 0; key < array.length; key++) {
- if (predicate(array[key])) {
- return key;
- }
- }
- return void 0;
-}
-function buildMatchPatternFn(args) {
- return (string, options = {}) => {
- const matchResult = string.match(args.matchPattern);
- if (!matchResult) return null;
- const matchedString = matchResult[0];
- const parseResult = string.match(args.parsePattern);
- if (!parseResult) return null;
- let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
- value = options.valueCallback ? options.valueCallback(value) : value;
- const rest = string.slice(matchedString.length);
- return { value, rest };
- };
-}
-const formatDistanceLocale = {
- lessThanXSeconds: {
- one: "less than a second",
- other: "less than {{count}} seconds"
- },
- xSeconds: {
- one: "1 second",
- other: "{{count}} seconds"
- },
- halfAMinute: "half a minute",
- lessThanXMinutes: {
- one: "less than a minute",
- other: "less than {{count}} minutes"
- },
- xMinutes: {
- one: "1 minute",
- other: "{{count}} minutes"
- },
- aboutXHours: {
- one: "about 1 hour",
- other: "about {{count}} hours"
- },
- xHours: {
- one: "1 hour",
- other: "{{count}} hours"
- },
- xDays: {
- one: "1 day",
- other: "{{count}} days"
- },
- aboutXWeeks: {
- one: "about 1 week",
- other: "about {{count}} weeks"
- },
- xWeeks: {
- one: "1 week",
- other: "{{count}} weeks"
- },
- aboutXMonths: {
- one: "about 1 month",
- other: "about {{count}} months"
- },
- xMonths: {
- one: "1 month",
- other: "{{count}} months"
- },
- aboutXYears: {
- one: "about 1 year",
- other: "about {{count}} years"
- },
- xYears: {
- one: "1 year",
- other: "{{count}} years"
- },
- overXYears: {
- one: "over 1 year",
- other: "over {{count}} years"
- },
- almostXYears: {
- one: "almost 1 year",
- other: "almost {{count}} years"
- }
-};
-const formatDistance = (token, count, options) => {
- let result;
- const tokenValue = formatDistanceLocale[token];
- if (typeof tokenValue === "string") {
- result = tokenValue;
- } else if (count === 1) {
- result = tokenValue.one;
- } else {
- result = tokenValue.other.replace("{{count}}", count.toString());
- }
- if (options?.addSuffix) {
- if (options.comparison && options.comparison > 0) {
- return "in " + result;
- } else {
- return result + " ago";
- }
- }
- return result;
-};
-const formatRelativeLocale = {
- lastWeek: "'last' eeee 'at' p",
- yesterday: "'yesterday at' p",
- today: "'today at' p",
- tomorrow: "'tomorrow at' p",
- nextWeek: "eeee 'at' p",
- other: "P"
-};
-const formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
-const eraValues = {
- narrow: ["B", "A"],
- abbreviated: ["BC", "AD"],
- wide: ["Before Christ", "Anno Domini"]
-};
-const quarterValues = {
- narrow: ["1", "2", "3", "4"],
- abbreviated: ["Q1", "Q2", "Q3", "Q4"],
- wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
-};
-const monthValues = {
- narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
- abbreviated: [
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
- ],
- wide: [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
- ]
-};
-const dayValues = {
- narrow: ["S", "M", "T", "W", "T", "F", "S"],
- short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
- abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
- wide: [
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
- ]
-};
-const dayPeriodValues = {
- narrow: {
- am: "a",
- pm: "p",
- midnight: "mi",
- noon: "n",
- morning: "morning",
- afternoon: "afternoon",
- evening: "evening",
- night: "night"
- },
- abbreviated: {
- am: "AM",
- pm: "PM",
- midnight: "midnight",
- noon: "noon",
- morning: "morning",
- afternoon: "afternoon",
- evening: "evening",
- night: "night"
- },
- wide: {
- am: "a.m.",
- pm: "p.m.",
- midnight: "midnight",
- noon: "noon",
- morning: "morning",
- afternoon: "afternoon",
- evening: "evening",
- night: "night"
- }
-};
-const formattingDayPeriodValues = {
- narrow: {
- am: "a",
- pm: "p",
- midnight: "mi",
- noon: "n",
- morning: "in the morning",
- afternoon: "in the afternoon",
- evening: "in the evening",
- night: "at night"
- },
- abbreviated: {
- am: "AM",
- pm: "PM",
- midnight: "midnight",
- noon: "noon",
- morning: "in the morning",
- afternoon: "in the afternoon",
- evening: "in the evening",
- night: "at night"
- },
- wide: {
- am: "a.m.",
- pm: "p.m.",
- midnight: "midnight",
- noon: "noon",
- morning: "in the morning",
- afternoon: "in the afternoon",
- evening: "in the evening",
- night: "at night"
- }
-};
-const ordinalNumber = (dirtyNumber, _options) => {
- const number = Number(dirtyNumber);
- const rem100 = number % 100;
- if (rem100 > 20 || rem100 < 10) {
- switch (rem100 % 10) {
- case 1:
- return number + "st";
- case 2:
- return number + "nd";
- case 3:
- return number + "rd";
- }
- }
- return number + "th";
-};
-const localize = {
- ordinalNumber,
- era: buildLocalizeFn({
- values: eraValues,
- defaultWidth: "wide"
- }),
- quarter: buildLocalizeFn({
- values: quarterValues,
- defaultWidth: "wide",
- argumentCallback: (quarter) => quarter - 1
- }),
- month: buildLocalizeFn({
- values: monthValues,
- defaultWidth: "wide"
- }),
- day: buildLocalizeFn({
- values: dayValues,
- defaultWidth: "wide"
- }),
- dayPeriod: buildLocalizeFn({
- values: dayPeriodValues,
- defaultWidth: "wide",
- formattingValues: formattingDayPeriodValues,
- defaultFormattingWidth: "wide"
- })
-};
-const matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
-const parseOrdinalNumberPattern = /\d+/i;
-const matchEraPatterns = {
- narrow: /^(b|a)/i,
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
- wide: /^(before christ|before common era|anno domini|common era)/i
-};
-const parseEraPatterns = {
- any: [/^b/i, /^(a|c)/i]
-};
-const matchQuarterPatterns = {
- narrow: /^[1234]/i,
- abbreviated: /^q[1234]/i,
- wide: /^[1234](th|st|nd|rd)? quarter/i
-};
-const parseQuarterPatterns = {
- any: [/1/i, /2/i, /3/i, /4/i]
-};
-const matchMonthPatterns = {
- narrow: /^[jfmasond]/i,
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
-};
-const parseMonthPatterns = {
- narrow: [
- /^j/i,
- /^f/i,
- /^m/i,
- /^a/i,
- /^m/i,
- /^j/i,
- /^j/i,
- /^a/i,
- /^s/i,
- /^o/i,
- /^n/i,
- /^d/i
- ],
- any: [
- /^ja/i,
- /^f/i,
- /^mar/i,
- /^ap/i,
- /^may/i,
- /^jun/i,
- /^jul/i,
- /^au/i,
- /^s/i,
- /^o/i,
- /^n/i,
- /^d/i
- ]
-};
-const matchDayPatterns = {
- narrow: /^[smtwf]/i,
- short: /^(su|mo|tu|we|th|fr|sa)/i,
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
-};
-const parseDayPatterns = {
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
-};
-const matchDayPeriodPatterns = {
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
-};
-const parseDayPeriodPatterns = {
- any: {
- am: /^a/i,
- pm: /^p/i,
- midnight: /^mi/i,
- noon: /^no/i,
- morning: /morning/i,
- afternoon: /afternoon/i,
- evening: /evening/i,
- night: /night/i
- }
-};
-const match = {
- ordinalNumber: buildMatchPatternFn({
- matchPattern: matchOrdinalNumberPattern,
- parsePattern: parseOrdinalNumberPattern,
- valueCallback: (value) => parseInt(value, 10)
- }),
- era: buildMatchFn({
- matchPatterns: matchEraPatterns,
- defaultMatchWidth: "wide",
- parsePatterns: parseEraPatterns,
- defaultParseWidth: "any"
- }),
- quarter: buildMatchFn({
- matchPatterns: matchQuarterPatterns,
- defaultMatchWidth: "wide",
- parsePatterns: parseQuarterPatterns,
- defaultParseWidth: "any",
- valueCallback: (index) => index + 1
- }),
- month: buildMatchFn({
- matchPatterns: matchMonthPatterns,
- defaultMatchWidth: "wide",
- parsePatterns: parseMonthPatterns,
- defaultParseWidth: "any"
- }),
- day: buildMatchFn({
- matchPatterns: matchDayPatterns,
- defaultMatchWidth: "wide",
- parsePatterns: parseDayPatterns,
- defaultParseWidth: "any"
- }),
- dayPeriod: buildMatchFn({
- matchPatterns: matchDayPeriodPatterns,
- defaultMatchWidth: "any",
- parsePatterns: parseDayPeriodPatterns,
- defaultParseWidth: "any"
- })
-};
-const dateFormats = {
- full: "EEEE, MMMM do, y",
- long: "MMMM do, y",
- medium: "MMM d, y",
- short: "MM/dd/yyyy"
-};
-const timeFormats = {
- full: "h:mm:ss a zzzz",
- long: "h:mm:ss a z",
- medium: "h:mm:ss a",
- short: "h:mm a"
-};
-const dateTimeFormats = {
- full: "{{date}} 'at' {{time}}",
- long: "{{date}} 'at' {{time}}",
- medium: "{{date}}, {{time}}",
- short: "{{date}}, {{time}}"
-};
-const formatLong = {
- date: buildFormatLongFn({
- formats: dateFormats,
- defaultWidth: "full"
- }),
- time: buildFormatLongFn({
- formats: timeFormats,
- defaultWidth: "full"
- }),
- dateTime: buildFormatLongFn({
- formats: dateTimeFormats,
- defaultWidth: "full"
- })
-};
-const enUS = {
- code: "en-US",
- formatDistance,
- formatLong,
- formatRelative,
- localize,
- match,
- options: {
- weekStartsOn: 0,
- firstWeekContainsDate: 1
- }
-};
-const dateEnUs = {
- name: "en-US",
- locale: enUS
-};
-function useLocale(ns) {
- const {
- mergedLocaleRef,
- mergedDateLocaleRef
- } = inject(configProviderInjectionKey, null) || {};
- const localeRef = computed(() => {
- var _a, _b;
- return (_b = (_a = mergedLocaleRef === null || mergedLocaleRef === void 0 ? void 0 : mergedLocaleRef.value) === null || _a === void 0 ? void 0 : _a[ns]) !== null && _b !== void 0 ? _b : enUS$1[ns];
- });
- const dateLocaleRef = computed(() => {
- var _a;
- return (_a = mergedDateLocaleRef === null || mergedDateLocaleRef === void 0 ? void 0 : mergedDateLocaleRef.value) !== null && _a !== void 0 ? _a : dateEnUs;
- });
- return {
- dateLocaleRef,
- localeRef
- };
-}
-export {
- Binder as B,
- VTarget as V,
- c as a,
- beforeNextFrameOnce as b,
- cssrAnchorMetaName as c,
- useAdjustedTo as d,
- VFollower as e,
- useLocale as u
-};
diff --git a/out/renderer/assets/use-locale-DLWAOXez.js.gz b/out/renderer/assets/use-locale-DLWAOXez.js.gz
deleted file mode 100644
index b02f128..0000000
Binary files a/out/renderer/assets/use-locale-DLWAOXez.js.gz and /dev/null differ
diff --git a/out/renderer/assets/wechat-DjfpYhZS.png b/out/renderer/assets/wechat-DjfpYhZS.png
deleted file mode 100644
index 3411f4f..0000000
Binary files a/out/renderer/assets/wechat-DjfpYhZS.png and /dev/null differ
diff --git a/out/renderer/index.html b/out/renderer/index.html
deleted file mode 100644
index baa0aa5..0000000
--- a/out/renderer/index.html
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
- 网抑云音乐 | AlgerKong | AlgerMusicPlayer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total Page View Loading Total Visits
- Loading Site Total Visitors
- Loading
-
-
-
diff --git a/out/renderer/index.html.gz b/out/renderer/index.html.gz
deleted file mode 100644
index 3957911..0000000
Binary files a/out/renderer/index.html.gz and /dev/null differ