2021-09-29 14:21:33 +08:00
|
|
|
<template>
|
|
|
|
<q-dialog
|
|
|
|
persistent
|
|
|
|
v-model="show_dialog"
|
|
|
|
@show="onShow"
|
|
|
|
@before-hide="resetData"
|
2022-01-25 19:41:28 +08:00
|
|
|
@keydown="
|
|
|
|
(evt) => {
|
2022-03-19 16:29:53 +08:00
|
|
|
if (!loading && evt.keyCode == 27) {
|
2022-01-25 19:41:28 +08:00
|
|
|
show_dialog = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"
|
2021-09-29 14:21:33 +08:00
|
|
|
>
|
2021-11-05 09:15:51 +08:00
|
|
|
<q-card class="overflow-hidden" style="max-width: 70vw">
|
2021-09-29 14:21:33 +08:00
|
|
|
<q-form @submit="onSubmit">
|
|
|
|
<q-card-section class="q-ma-none q-pa-sm">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-auto text-h6">
|
|
|
|
{{ $t("subtitle") }}
|
|
|
|
</div>
|
|
|
|
<q-space />
|
2022-04-28 15:04:15 +08:00
|
|
|
<q-btn
|
|
|
|
:loading="loading"
|
|
|
|
flat
|
|
|
|
round
|
|
|
|
icon="close"
|
|
|
|
color="red"
|
|
|
|
v-close-popup
|
|
|
|
>
|
|
|
|
<q-tooltip>
|
|
|
|
{{ $t("close") }}
|
|
|
|
</q-tooltip>
|
|
|
|
</q-btn>
|
2021-09-29 14:21:33 +08:00
|
|
|
</div>
|
|
|
|
</q-card-section>
|
|
|
|
|
|
|
|
<q-separator />
|
|
|
|
|
2022-04-25 16:41:42 +08:00
|
|
|
<q-card-section class="scroll" style="width: 70vw">
|
2021-09-29 14:21:33 +08:00
|
|
|
<q-list>
|
2022-04-25 16:41:42 +08:00
|
|
|
<q-item v-if="false">
|
2021-09-29 14:21:33 +08:00
|
|
|
<q-item-section>
|
|
|
|
<q-input
|
|
|
|
:label="$t('background color')"
|
|
|
|
v-model="subtitle.background"
|
2022-06-02 11:01:19 +08:00
|
|
|
:disable="subtitle.background_transparent"
|
2021-09-29 14:21:33 +08:00
|
|
|
:rules="['anyColor']"
|
2022-01-18 08:52:51 +08:00
|
|
|
hint=""
|
2021-09-29 14:21:33 +08:00
|
|
|
>
|
|
|
|
<template v-slot:append>
|
|
|
|
<q-icon name="colorize" class="cursor-pointer">
|
|
|
|
<q-popup-proxy
|
|
|
|
transition-show="scale"
|
|
|
|
transition-hide="scale"
|
|
|
|
>
|
|
|
|
<q-color v-model="subtitle.background" />
|
|
|
|
</q-popup-proxy>
|
|
|
|
</q-icon>
|
|
|
|
</template>
|
|
|
|
</q-input>
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section>
|
|
|
|
<q-checkbox
|
|
|
|
:label="$t('background transparent')"
|
2022-06-02 11:01:19 +08:00
|
|
|
v-model="subtitle.background_transparent"
|
2021-09-29 14:21:33 +08:00
|
|
|
/>
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item>
|
|
|
|
<q-item-section>
|
|
|
|
<q-select
|
2022-06-02 11:01:19 +08:00
|
|
|
:label="$t('move speed')"
|
2021-09-29 14:21:33 +08:00
|
|
|
v-model="subtitle.x_speed"
|
2021-12-28 15:24:51 +08:00
|
|
|
:options="[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 20]"
|
2021-09-29 14:21:33 +08:00
|
|
|
></q-select>
|
|
|
|
</q-item-section>
|
2022-01-18 08:52:51 +08:00
|
|
|
<q-item-section>
|
|
|
|
<q-input
|
|
|
|
type="number"
|
|
|
|
:label="$t('y offset')"
|
|
|
|
maxlength="4"
|
|
|
|
max="2160"
|
|
|
|
min="0"
|
|
|
|
v-model="subtitle.y_offset"
|
|
|
|
/>
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
2022-06-02 11:01:19 +08:00
|
|
|
<q-item>
|
|
|
|
<q-item-section>
|
|
|
|
<q-input
|
|
|
|
type="number"
|
|
|
|
:label="$t('pos x')"
|
|
|
|
maxlength="4"
|
|
|
|
max="7680"
|
|
|
|
min="0"
|
|
|
|
v-model="subtitle.x"
|
|
|
|
/>
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section>
|
|
|
|
<q-input
|
|
|
|
type="number"
|
|
|
|
:label="$t('width')"
|
|
|
|
maxlength="4"
|
|
|
|
max="7680"
|
|
|
|
min="0"
|
|
|
|
v-model="subtitle.width"
|
|
|
|
/>
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
2022-01-18 08:52:51 +08:00
|
|
|
<q-item>
|
2021-12-28 15:24:51 +08:00
|
|
|
<q-item-section>
|
|
|
|
<q-checkbox
|
|
|
|
:label="$t('enable subtitle')"
|
|
|
|
v-model="subtitle.show"
|
|
|
|
/>
|
|
|
|
</q-item-section>
|
2021-09-29 14:21:33 +08:00
|
|
|
</q-item>
|
2022-04-28 15:04:15 +08:00
|
|
|
|
2021-09-29 14:21:33 +08:00
|
|
|
<q-separator inset />
|
2022-04-28 15:04:15 +08:00
|
|
|
<q-item style="height: 50vh">
|
2022-05-04 15:33:34 +08:00
|
|
|
<q-item-section
|
|
|
|
:style="{
|
|
|
|
'align-items': loading ? 'center' : 'unset',
|
|
|
|
}"
|
|
|
|
>
|
2022-04-28 15:04:15 +08:00
|
|
|
<editor
|
2022-05-04 15:33:34 +08:00
|
|
|
v-if="!loading"
|
2022-04-28 15:04:15 +08:00
|
|
|
class="fit"
|
2022-04-28 17:05:51 +08:00
|
|
|
tinymce-script-src="tinymce/tinymce.min.js"
|
2022-04-28 15:04:15 +08:00
|
|
|
:init="editor_config"
|
|
|
|
v-model="subtitle.text"
|
|
|
|
/>
|
2022-05-04 15:33:34 +08:00
|
|
|
<q-spinner v-else color="primary" size="5em" :thickness="2" />
|
2022-04-28 15:04:15 +08:00
|
|
|
</q-item-section>
|
2021-09-29 14:21:33 +08:00
|
|
|
</q-item>
|
|
|
|
</q-list>
|
|
|
|
</q-card-section>
|
|
|
|
<q-separator />
|
|
|
|
|
|
|
|
<q-card-actions align="right">
|
|
|
|
<q-btn
|
|
|
|
:loading="loading"
|
|
|
|
flat
|
|
|
|
:label="$t('Cancel')"
|
|
|
|
color="primary"
|
|
|
|
v-close-popup
|
|
|
|
/>
|
|
|
|
<q-btn
|
|
|
|
ref="accept"
|
|
|
|
flat
|
|
|
|
:label="$t('Accept')"
|
|
|
|
:loading="loading"
|
|
|
|
type="submit"
|
|
|
|
color="primary"
|
|
|
|
/>
|
|
|
|
</q-card-actions>
|
|
|
|
</q-form>
|
|
|
|
</q-card>
|
|
|
|
</q-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import {
|
|
|
|
defineComponent,
|
|
|
|
ref,
|
|
|
|
Ref,
|
2022-04-28 15:04:15 +08:00
|
|
|
reactive,
|
2021-09-29 14:21:33 +08:00
|
|
|
watch,
|
|
|
|
computed,
|
|
|
|
onMounted,
|
|
|
|
onBeforeUnmount,
|
2021-11-05 09:15:51 +08:00
|
|
|
nextTick,
|
2021-09-29 14:21:33 +08:00
|
|
|
} from "vue";
|
2022-04-28 15:04:15 +08:00
|
|
|
|
2021-09-29 14:21:33 +08:00
|
|
|
import { useStore } from "src/store";
|
2022-04-28 15:04:15 +08:00
|
|
|
import { useQuasar, dom as DomUtil } from "quasar";
|
2021-09-29 14:21:33 +08:00
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
import GlobalData from "src/common/GlobalData";
|
|
|
|
import SubtitleEntity from "src/entities/SubtitleEntity";
|
2022-04-28 15:04:15 +08:00
|
|
|
|
|
|
|
import Editor from "@tinymce/tinymce-vue";
|
2021-09-29 14:21:33 +08:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: "ComponentSubtitleDialog",
|
2022-04-28 15:04:15 +08:00
|
|
|
components: {
|
|
|
|
Editor,
|
|
|
|
},
|
2021-09-29 14:21:33 +08:00
|
|
|
setup() {
|
|
|
|
let $store = useStore();
|
|
|
|
let $q = useQuasar();
|
|
|
|
let $t = useI18n();
|
2022-04-28 15:04:15 +08:00
|
|
|
const i18n = useI18n();
|
2021-09-29 14:21:33 +08:00
|
|
|
|
|
|
|
let show_dialog = ref(false);
|
|
|
|
let loading = ref(false);
|
|
|
|
let subtitle = ref(new SubtitleEntity());
|
|
|
|
|
2022-04-28 15:04:15 +08:00
|
|
|
const fontOptions: number[] = [];
|
|
|
|
for (let i = 9; i <= 300; i += 3) {
|
|
|
|
fontOptions.push(i);
|
|
|
|
}
|
2021-09-29 14:21:33 +08:00
|
|
|
|
2022-04-28 15:04:15 +08:00
|
|
|
const get_font_size_formarts = () => {
|
|
|
|
let result = "";
|
|
|
|
for (const item of fontOptions) {
|
|
|
|
result += item + "pt ";
|
2021-11-05 09:15:51 +08:00
|
|
|
}
|
2022-04-28 15:04:15 +08:00
|
|
|
return result;
|
2021-09-29 14:21:33 +08:00
|
|
|
};
|
|
|
|
|
2022-04-28 15:04:15 +08:00
|
|
|
const editor_config = reactive({
|
|
|
|
plugins: [
|
|
|
|
"fullscreen",
|
|
|
|
/*'lists link image paste help wordcount'*/
|
|
|
|
],
|
|
|
|
mobile: {
|
|
|
|
menubar: true,
|
|
|
|
},
|
|
|
|
font_size_formats: get_font_size_formarts(),
|
|
|
|
skin: "tinymce-5",
|
|
|
|
language: i18n.locale.value == "zh-CN" ? "zh_CN" : "",
|
|
|
|
menubar: false,
|
|
|
|
branding: false,
|
|
|
|
toolbar_mode: "wrap",
|
|
|
|
toolbar:
|
2022-05-24 14:02:48 +08:00
|
|
|
// "fullscreen | code undo redo restoredraft | cut copy paste pastetext | fontsize| forecolor backcolor bold italic underline strikethrough | alignleft aligncenter alignright alignjustify |subscript superscript removeformat",
|
|
|
|
"fullscreen | fontsize| forecolor backcolor bold italic underline strikethrough | subscript superscript removeformat",
|
2022-04-28 15:04:15 +08:00
|
|
|
});
|
|
|
|
|
2021-09-29 14:21:33 +08:00
|
|
|
return {
|
|
|
|
show_dialog,
|
|
|
|
loading,
|
|
|
|
subtitle,
|
2022-04-28 15:04:15 +08:00
|
|
|
editor_config,
|
2021-09-29 14:21:33 +08:00
|
|
|
async showDialog() {
|
|
|
|
show_dialog.value = true;
|
|
|
|
loading.value = true;
|
|
|
|
|
|
|
|
try {
|
|
|
|
let response = await GlobalData.getInstance()
|
|
|
|
.getCurrentClient()
|
|
|
|
?.getSubtitle();
|
|
|
|
if (response) {
|
2022-06-02 11:01:19 +08:00
|
|
|
try {
|
|
|
|
const temp = response.subtitle;
|
|
|
|
for (const item of Object.keys(subtitle.value)) {
|
|
|
|
if (typeof (<any>temp)[item] != "undefined") {
|
|
|
|
(<any>subtitle.value)[item] = (<any>temp)[item];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch {
|
|
|
|
subtitle.value = response.subtitle;
|
|
|
|
}
|
2021-09-29 14:21:33 +08:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
show_dialog.value = false;
|
|
|
|
}
|
2022-05-04 15:33:34 +08:00
|
|
|
loading.value = false;
|
2021-09-29 14:21:33 +08:00
|
|
|
},
|
|
|
|
onShow() {
|
2022-05-24 14:02:48 +08:00
|
|
|
let success = false;
|
|
|
|
const checkZIndex = () => {
|
|
|
|
document.querySelectorAll(".tox ").forEach((item) => {
|
|
|
|
if (item && item.classList.contains("tox-tinymce-aux")) {
|
|
|
|
DomUtil.css(item, {
|
|
|
|
zIndex: "99999",
|
|
|
|
});
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const checkZIndexAsync = () => {
|
|
|
|
checkZIndex();
|
|
|
|
setTimeout(() => {
|
|
|
|
if (!success) {
|
|
|
|
checkZIndexAsync();
|
|
|
|
} else {
|
|
|
|
console.log("subtitle initialize success");
|
|
|
|
}
|
|
|
|
}, 50);
|
|
|
|
};
|
|
|
|
|
|
|
|
checkZIndexAsync();
|
2021-09-29 14:21:33 +08:00
|
|
|
},
|
|
|
|
resetData() {
|
|
|
|
loading.value = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
async onSubmit() {
|
|
|
|
loading.value = true;
|
|
|
|
try {
|
2022-06-02 11:01:19 +08:00
|
|
|
subtitle.value.y_offset = parseInt(
|
|
|
|
subtitle.value.y_offset.toString()
|
|
|
|
);
|
|
|
|
subtitle.value.x_speed = parseInt(subtitle.value.x_speed.toString());
|
|
|
|
subtitle.value.x = parseInt(subtitle.value.x.toString());
|
|
|
|
subtitle.value.width = parseInt(subtitle.value.width.toString());
|
|
|
|
|
2021-09-29 14:21:33 +08:00
|
|
|
GlobalData.getInstance()
|
|
|
|
.getCurrentClient()
|
|
|
|
?.setSubtitle(subtitle.value);
|
|
|
|
$q.notify({
|
|
|
|
color: "positive",
|
|
|
|
icon: "done",
|
|
|
|
message: $t.t("set subtitle success") + "!",
|
|
|
|
position: "top",
|
2021-12-22 11:25:04 +08:00
|
|
|
timeout: 1500,
|
2021-09-29 14:21:33 +08:00
|
|
|
});
|
|
|
|
show_dialog.value = false;
|
|
|
|
} catch {}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|