refactor: update version handling and remove placeholder injection

- Simplified version display in context menu and template by directly importing version from package.json.
- Removed static version and environment methods from Artplayer class, replacing them with dynamic imports.
- Eliminated placeholder injection logic from build and dev scripts, streamlining the build process.
- Cleaned up build and dev scripts for better readability and maintainability.
This commit is contained in:
Harvey Zack committed 2025-06-20 11:04:29 +08:00
1 parent e2e8e83e63
commit e8a7e050c4
16 files changed
+233 -287

No files matched your search

@@ -1,13 +1,8 @@
import { version } from '../../package.json';
export default function version(option) {
return {
...option,
html: `<a href="https://artplayer.org" target="_blank">ArtPlayer</a>`,
mounted(el) {
const link = el.querySelector('a');
const version = this.constructor.version;
const ref = encodeURIComponent(location.href);
link.textContent += ` ${version}`;
link.href += `?ref=${ref}`;
},
html: `<a href="https://artplayer.org" target="_blank">ArtPlayer ${version}</a>`,
};
}
+2 -6
View File
@@ -1,3 +1,4 @@
import { version } from '../package.json';
import style from 'bundle-text:./style/index.less';
import validator from 'option-validator';
import Emitter from './utils/emitter';
@@ -67,7 +68,6 @@ export default class Artplayer extends Emitter {
if (Artplayer.DEBUG) {
const log = (msg) => console.log(`[ART.${this.id}] -> ${msg}`);
log('Version@' + Artplayer.version);
log('Env@' + Artplayer.env);
for (let index = 0; index < config.events.length; index++) {
this.on('video:' + config.events[index], (event) => log('Event@' + event.type));
}
@@ -81,11 +81,7 @@ export default class Artplayer extends Emitter {
}
static get version() {
return '"5.2.4"'.replace(/"/g, '');
}
static get env() {
return '"development"'.replace(/"/g, '');
return version;
}
static get config() {
+2 -1
View File
@@ -1,3 +1,4 @@
import { version } from '../package.json';
import { supportsFlex, errorHandle, query, addClass, isMobile, replaceElement } from './utils';
export default class Template {
@@ -57,7 +58,7 @@ export default class Template {
<div class="art-info-panel">
<div class="art-info-item">
<div class="art-info-title">Player version:</div>
<div class="art-info-content">${'__APP_VERSION__'}</div>
<div class="art-info-content">${version}</div>
</div>
<div class="art-info-item">
<div class="art-info-title">Video url:</div>