mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-03-15 21:17:01 +00:00
Use Mixins for global functions.
This commit is contained in:
26
src/main.js
26
src/main.js
@@ -12,7 +12,33 @@ import App from './App.vue'
|
||||
|
||||
import './registerServiceWorker'
|
||||
|
||||
const mixin = {
|
||||
methods: {
|
||||
timeFormat: function (duration) {
|
||||
|
||||
var pad = function (num, size) {
|
||||
return ("000" + num).slice(size * -1);
|
||||
};
|
||||
|
||||
var time = parseFloat(duration).toFixed(3),
|
||||
hours = Math.floor(time / 60 / 60),
|
||||
minutes = Math.floor(time / 60) % 60,
|
||||
seconds = Math.floor(time - minutes * 60);
|
||||
|
||||
var str = "";
|
||||
|
||||
if (hours > 0) str += pad(hours, 2) + ":";
|
||||
|
||||
str += pad(minutes, 2) + ":" + pad(seconds, 2);
|
||||
|
||||
return str;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(router)
|
||||
app.mixin(mixin)
|
||||
app.component('font-awesome-icon', FontAwesomeIcon)
|
||||
app.mount('#app')
|
||||
|
||||
Reference in New Issue
Block a user