Commit 0ea7f449 by haojie

部分组件修改为自定义组件,减小打包体积

parent 89216715
......@@ -49,7 +49,7 @@ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useStore } from 'vuex';
import Loading from '@/components/Loading/FirstCircle.vue';
import { onBeforeRouteLeave } from 'vue-router';
import { callPyjsInWindow, injectWindow } from '@/utils/pyqt';
import { injectWindow } from '@/utils/pyqt';
import { scriptTypePhonetics } from '@/service/CreateLive';
const props = withDefaults(
......
......@@ -5,6 +5,7 @@
</template>
<script lang="ts" setup>
import { Checkbox as TCheckbox } from 'tdesign-vue-next';
import { ref, watch } from 'vue';
const props = withDefaults(
......
.le-loading {
display: flex;
align-items: center;
justify-content: center;
top: 0;
left: 0;
.le-spinner {
width: 40px;
height: 40px;
border: 4px solid #f3f3f3;
border-top: 4px solid #00cca2;
border-radius: 50%;
animation: spin 1.2s linear infinite;
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
import './index.less';
import { defineComponent } from 'vue';
export default defineComponent({
props: {
position: {
type: String,
default: 'absolute',
},
mask: {
type: Boolean,
default: false,
},
},
setup(props) {
return () => (
<div
class="le-loading"
style={{
position: props.position,
width: props.position == 'absolute' ? '100%' : '',
height: props.position == 'absolute' ? '100%' : '',
background: props.mask ? 'rgba(0,0,0,0.5)' : '',
}}
>
<div class="le-spinner"></div>
</div>
);
},
});
......@@ -4,7 +4,7 @@
<script lang="ts" setup>
import { Progress as TProgress } from 'tdesign-vue-next';
const props = withDefaults(
withDefaults(
defineProps<{
value: number;
}>(),
......
......@@ -22,7 +22,7 @@
</template>
<script lang="ts" setup>
const props = withDefaults(
withDefaults(
defineProps<{
height?: string;
showTool?: boolean;
......
......@@ -22,7 +22,7 @@
</template>
<script lang="ts" setup>
const props = withDefaults(
withDefaults(
defineProps<{
position?: string;
mask?: boolean;
......
<template>
<t-switch class="c-default-switch" v-model="checked" :size="size" :label="['开', '关']"></t-switch>
</template>
<script lang="ts" setup>
import { Switch as TSwitch } from 'tdesign-vue-next';
import { ref, watch } from 'vue';
const props = withDefaults(
defineProps<{
id?: number | string;
modelValue: boolean;
size?: string;
}>(),
{
size: 'large',
id: '',
},
);
const emit = defineEmits(['update:modelValue', 'change']);
const checked = ref(props.modelValue);
watch(
() => props.modelValue,
(v) => {
checked.value = v;
},
);
watch(
() => checked.value,
(v) => {
emit('update:modelValue', v);
emit('change', v, props.id);
},
);
</script>
<style lang="less">
.c-default-switch.t-is-checked {
background: #00cca2;
}
</style>
.le-switch {
height: 24px;
line-height: 24px;
border-radius: 12px;
min-width: 44px;
cursor: pointer;
display: inline-flex;
position: relative;
background-color: #c5c5c5;
.le-switch__content {
font-size: 9px;
color: white;
width: 100%;
padding: 0 8px 0 24px;
user-select: none;
transition: padding 0.2s;
}
.le-switch__handle {
position: absolute;
width: 20px;
height: 20px;
top: 2px;
left: 2px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s cubic-bezier(0.38, 0, 0.24, 1);
border-radius: 50%;
background-color: white;
}
}
.le-switch-checked {
background: #00cca2;
.le-switch__handle {
left: calc(100% - 22px);
}
.le-switch__content {
padding: 0 24px 0 8px;
}
}
import './index.less';
import { defineComponent, computed } from 'vue';
export default defineComponent({
props: {
modelValue: Boolean,
size: {
type: String,
defualt: '24px',
},
label: {
type: Array,
default: () => ['开', '关'],
},
// 用于循环渲染,切换之后要知道自己的下标
id: {
type: [String, Number],
defualt: '',
},
},
emits: ['update:modelValue', 'change'],
setup(props, { emit }) {
const switchValue = computed({
get() {
return props.modelValue;
},
set(value) {
emit('update:modelValue', value);
emit('change', value, props.id);
},
});
const switchChange = () => {
switchValue.value = !switchValue.value;
};
return () => (
<div
class={['le-switch', switchValue.value ? 'le-switch-checked' : '']}
onClick={switchChange}
>
<span class="le-switch__handle"></span>
<div class="le-switch__content">
{switchValue.value ? props.label[0] : props.label[1]}
</div>
</div>
);
},
});
.le-table-parent {
position: relative;
.le-table {
width: 100%;
border-spacing: 0;
thead {
tr {
th {
background-color: #1e1e1e !important;
font-size: 16px;
color: white;
font-weight: normal;
box-sizing: border-box;
padding: 8px 24px 8px 24px;
}
& > :first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
& > :last-child {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
}
}
tbody {
min-height: 120px;
tr {
td {
padding: 13px 24px 11px 24px;
border-bottom: 1px solid #464646;
}
}
.le-table__empty-row {
td {
padding: 0;
.le-table__empty {
color: white;
background-color: #303030;
display: flex;
align-items: center;
justify-content: center;
min-height: 120px;
}
}
}
}
}
.le-table-loading {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
}
}
import './index.less';
import { defineComponent } from 'vue';
import Loading from '@/components/Loading';
export default defineComponent({
props: {
rowKey: {
type: String,
default: '',
},
data: {
type: Array,
default: () => [],
},
columns: {
type: Array,
default: () => [],
},
loading: {
type: Boolean,
default: false,
},
handleRowClick: {
type: [Function, Boolean],
default: false,
},
},
emits: ['update:loading'],
setup(props) {
// 行点击事件
const rowClick = (item: any) => {
const { handleRowClick } = props;
if (handleRowClick && typeof handleRowClick !== 'boolean') {
handleRowClick(item);
}
};
// 当前显示的元素
const currentShowElement = () => {
const { loading, data } = props;
if (data.length) {
return props.data.map((item: any, index: number) => (
<tr key={props.rowKey ? item[props.rowKey] : index} onClick={rowClick.bind(this, item)}>
{props.columns.map((column: any) => (
<td
class={column.className}
style={{
width: column.width ? column.width : '',
textAlign: column.align ? column.align : 'left',
}}
>
{column.cell
? column.cell({
col: column,
row: item,
})
: item[column.key]}
</td>
))}
</tr>
));
} else {
return (
<tr class="le-table__empty-row">
<td colspan={props.columns.length}>
<div class="le-table__empty">暂无数据</div>
</td>
</tr>
);
}
};
return () => (
<div class="le-table-parent">
<table class="le-table">
<thead>
<tr>
{props.columns.map((column: any) => (
<th
style={{
width: column.width ? column.width : '',
textAlign: column.align ? column.align : 'left',
}}
>
{column.title}
</th>
))}
</tr>
</thead>
<tbody>{currentShowElement()}</tbody>
</table>
<div class="le-table-loading" v-show={props.loading}>
<Loading mask={true}></Loading>
</div>
</div>
);
},
});
......@@ -29,7 +29,7 @@ const currentCacheList = ref(getCacheList());
watch(
() => keepAliveList.value,
(v) => {
() => {
currentCacheList.value = getCacheList();
},
{
......
......@@ -4,7 +4,7 @@
<div class="my-person-items">
<template v-for="item in personList.list" :key="item.id">
<template v-if="item.audit_status == LIVE_AUDIT_STATUS.LIVE_AUDIT_STATUS_FINISH">
<CardOne :id="item.id" :img="item.cover_url" :name="item.name" :edit="true" @nameChange="nameChange">
<CardOne :id="item.id" :img="item.cover_url" :name="item.name" :edit="true">
<template #hover>
<div class="my-digtal-people-hover2">
<template v-if="true">
......@@ -71,9 +71,6 @@ const openDialog = (item: any) => {
deleteId.value = item.id;
};
// 修改名称
const nameChange = (id: number | string, name: string) => {};
// 确认删除
const confirm = () => {
//
......
......@@ -12,7 +12,7 @@ import { onBeforeUnmount, onMounted, ref } from 'vue';
import Human from './components/human.vue';
import { useRoute } from 'vue-router';
import { callPyjsInWindow, injectWindow } from '@/utils/pyqt';
import { getliveTaskReply, getUserCookie } from '@/utils/api/userApi';
import { getliveTaskReply } from '@/utils/api/userApi';
import { useStore } from 'vuex';
import { writeLog } from '@/utils/pyqt';
......
......@@ -22,9 +22,9 @@ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import AddVideoPlay from '@/components/AddVideoPlay.vue';
import { getLiveDetail, closeLiveTask } from '@/utils/api/userApi';
import { useRoute, useRouter } from 'vue-router';
import { show_message, isDev, DataType, randomInt, randomIntFormList } from '@/utils/tool';
import { show_message, isDev, DataType, randomIntFormList } from '@/utils/tool';
import { callPyjsInWindow, injectWindow } from '@/utils/pyqt';
import { getliveTaskReply, getUserCookie, liveTts, getLiveTaskInfo, liveTaskRegenerate } from '@/utils/api/userApi';
import { getliveTaskReply, liveTts, getLiveTaskInfo, liveTaskRegenerate } from '@/utils/api/userApi';
import routerConfig from '@/router/tool';
import { useStore } from 'vuex';
import { v4 } from 'uuid';
......@@ -33,7 +33,7 @@ import { CONFUSE_STATUS } from '@/service/Live';
import { processTextCallback } from '@/hooks/useScript';
import { scriptTypeText } from '@/service/CreateLive';
import { writeLog } from '@/utils/pyqt';
const { currentConfuseId, confuseList, stopConfuse, currentStartConfuse, openConfuseInterval } = useConfuse();
const { currentConfuseId, confuseList, stopConfuse, openConfuseInterval } = useConfuse();
const { openInterval: confuseInterval } = processTextCallback();
const store = useStore();
......@@ -151,7 +151,7 @@ const submitAudioTask = async (list: any[]) => {
id: i,
};
// 生成音频
let res: any = await liveTts(params);
await liveTts(params);
}
console.log('等待音频生成完成');
// 开始轮询
......@@ -214,8 +214,6 @@ const findOneVideoInit = () => {
if (status) {
// 当前显示的视频
let item = mainVideoList.value[currentPlayMainIndex.value];
// 主视频列表中的行
let videoInfo = realVideoList.value[item.videoIndex];
const changeVideo = (url: string, index: number | boolean = false) => {
hideVideo.play = false;
......
......@@ -133,7 +133,7 @@
<script lang="tsx" setup>
import Loading from '@/components/loading.vue';
import CustomSwitch from '@/components/switch.vue';
import CustomSwitch from '@/components/switch';
import Upload from '@/components/upload';
import CustomTabs from '@/components/CustomTabs';
import CustomTabPanel from '@/components/CustomTabPanel';
......
......@@ -5,17 +5,7 @@
<Button class="add-interact-button" @click="openDialog()">+ 新增互动内容</Button>
</div>
<div class="interact-table">
<Table
rowkey="id"
:pageNum="pageNum"
:pageSize="pageSize"
:total="total"
:list="tableList.list"
:columns="columns"
:loading="loading"
:pagination="false"
@PageNumChange="PageNumChange"
></Table>
<Table rowkey="id" :data="tableList.list" :columns="columns" :loading="loading"></Table>
</div>
<AddInteractDialog
v-model:visible="dialogVisible"
......@@ -32,8 +22,8 @@
<script lang="tsx" setup>
import ConfirmDialog from '@/components/ConfirmDialog.vue';
import Button from '@/components/Button.vue';
import Table from '@/components/table.vue';
import CustomSwitch from '@/components/switch.vue';
import Table from '@/components/table';
import CustomSwitch from '@/components/switch';
import { reactive, ref, watch } from 'vue';
import EditSvg from '@/assets/svg/home/edit.svg';
import DeleteSvg from '@/assets/svg/home/delete.svg';
......@@ -52,9 +42,6 @@ const confirmRow = ref({});
const dialogType = ref('add');
const loading = ref(false);
const pageNum = ref<number>(1);
const pageSize = ref<number>(10);
const total = ref<number>(0);
const dialogVisible = ref(false);
const tableList = reactive({
......@@ -134,22 +121,19 @@ const switchChange = async (value: string | number | boolean, id: string | numbe
const columns = [
{
title: '问题',
colKey: 'problem',
key: 'problem',
width: '60%',
className: 'table-problem-td',
},
{
title: '状态',
colKey: 'c_status',
cell: (h, { col, row }) => (
<div>
<CustomSwitch v-model={row[col.colKey]} id={row.id} onChange={switchChange}></CustomSwitch>
</div>
),
key: 'c_status',
cell: ({ col, row }) => <CustomSwitch v-model={row[col.key]} id={row.id} onChange={switchChange}></CustomSwitch>,
},
{
title: '操作',
colKey: 'get3',
cell: (h, { row }) => (
key: 'get3',
cell: ({ row }) => (
<div class="edit-box">
<span class="edit-icon" onClick={rowChange.bind(this, row)}>
<EditSvg></EditSvg>
......@@ -202,10 +186,6 @@ watch(
},
);
const PageNumChange = (value: number) => {
pageNum.value = value;
};
const openDialog = () => {
dialogType.value = 'add';
dialogVisible.value = true;
......@@ -238,6 +218,9 @@ const openDialog = () => {
margin-left: 12px;
}
}
.table-problem-td {
color: white;
}
}
}
</style>
......@@ -216,7 +216,6 @@ import ScriptTemplate from '@/components/ScriptTemplate.vue';
import Select from '@/components/Select.vue';
import SelectionPopup from '@/components/SelectionPopup.vue';
import { show_message, isDev, ecursionDeepCopy } from '@/utils/tool';
import { audioAccept } from '@/constants/token';
import AudioScriptDialog from './audioScriptDialog.vue';
import {
createLiveKeys,
......@@ -251,7 +250,6 @@ const route = useRoute();
// 编辑信息
const editInfo = computed(() => store.getters['live/getEditLive']);
const createLiveInfo = computed(() => store.getters['live/getLiveInfo']);
// 文本脚本列表
const textScriptList = ref([]);
......@@ -273,9 +271,6 @@ const deleteAudioIndex = ref();
// 是否gpt洗稿
const isDisorganize = ref(false);
// upload组件的ref
const uploadRef = ref();
const lists = reactive({
tones: [],
soundColor: [],
......@@ -302,8 +297,6 @@ const audioScriptVisible = ref(false);
const ossConfig = ref({});
// 上传的音频文件链接
const mp3Url = ref('');
// 多选文件列表
const mp3UrlList = ref([]);
// 音频 我的音色
const phoneticsVisible = ref(false);
......@@ -315,11 +308,6 @@ const textareaValue = ref('');
const currentOption = ref(scriptTypeText);
// 音频脚本编辑后
const uploadEdit = (list: any[], oldList: any[]) => {
uploadChange();
};
const confirmDeleteAudio = () => {
audioScriptList.value.splice(deleteAudioIndex.value, 1);
uploadChange();
......
......@@ -102,10 +102,8 @@ import { useLiveInfoSubmit } from '@/hooks/useStoreCommit';
import { processTextCallback } from '@/hooks/useScript';
import CustomException from '@/utils/error';
import { v4 } from 'uuid';
import { splitAudio } from '@/utils/audio';
import { audioScriptVersion } from '@/service/CreateLive';
import { audioSplitDuration, getTestUuid } from '@/constants/token';
const { loading, initNum, currentSetp, live_task_id, openInterval, getCreateLiveInfo, submitSuccessed, uploadToAly } =
const { loading, initNum, currentSetp, live_task_id, openInterval, getCreateLiveInfo, submitSuccessed } =
processTextCallback();
const [commitInfo] = useLiveInfoSubmit();
......
......@@ -41,7 +41,7 @@
</div>
</t-form-item>
<t-form-item>
<t-checkbox class="remember-password-box" v-model="remember">记住密码</t-checkbox>
<CheckBox class="remember-password-box" v-model="remember">记住密码</CheckBox>
</t-form-item>
<t-form-item>
<div class="submit-box">
......@@ -63,6 +63,7 @@ import { useStore } from 'vuex';
import { setRememberList, getRememberList } from '@/utils/remember';
import { UserLogin } from '@/utils/api/userApi';
import { useRouter } from 'vue-router';
import CheckBox from '@/components/CheckBox.vue';
const store = useStore();
const router = useRouter();
......@@ -110,7 +111,7 @@ const onSubmit = async ({ validateResult, firstError }: any) => {
time: res.data.expires_in,
});
// 获取用户信息
store.dispatch('user/UserInfo');
store.dispatch('user/getUserInfo');
router.replace({
path: '/',
});
......@@ -205,28 +206,6 @@ onMounted(() => {
}
}
}
.remember-password-box {
.t-checkbox__input {
background: transparent;
border: 1px solid #848e9c;
border-radius: 0;
border-radius: 2px;
}
.t-checkbox__label {
color: white;
font-weight: 300;
font-size: @size-12;
}
}
.t-is-checked {
.t-checkbox__input {
background: #00f9f9;
border-color: transparent;
&::after {
border-color: black;
}
}
}
}
}
}
......
......@@ -14,7 +14,7 @@
import { onBeforeUnmount, ref, watch } from 'vue';
import AddVideoPlay from '@/components/AddVideoPlay.vue';
const props = withDefaults(
withDefaults(
defineProps<{
video: any;
video2: any;
......
......@@ -18,7 +18,7 @@ import { getLiveDetail } from '@/utils/api/userApi';
import { useRoute, useRouter } from 'vue-router';
import { show_message } from '@/utils/tool';
import { callPyjsInWindow, injectWindow } from '@/utils/pyqt';
import { getliveTaskReply, getLiveTask, getUserCookie } from '@/utils/api/userApi';
import { getliveTaskReply, getLiveTask } from '@/utils/api/userApi';
import routerConfig from '@/router/tool';
import { useStore } from 'vuex';
......
......@@ -4,7 +4,6 @@ import { audioStart } from '@/service/Common';
import store from '@/store';
import { v4 } from 'uuid';
import { writeLog } from '@/utils/pyqt';
import { getDurationOfAudioFile } from '@/utils/audio';
/**
* 创建直播的版本
......@@ -60,7 +59,7 @@ export const movementTypeEnd = 2; // 结尾插入
// 合并同类项音频
export const mergeSameAudio = (content: any[]) => {
let list = [];
content.forEach((item: any, index: number) => {
content.forEach((item: any) => {
let title = '';
let url = '';
let movement_name = '';
......@@ -277,7 +276,7 @@ export const filterFiled = (item: any, type: string = '') => {
// 音色id
params.phonetic_timbres_id = item[createLiveKeys.textSoundColor];
params.content = newList.map((row: any, index: number) => {
params.content = newList.map((row: any) => {
return {
title: row.title,
content: row.content,
......@@ -408,45 +407,6 @@ export const regenerate = async (list: any[], item: any, live_id: any) => {
}
};
// 计算音频块列表的开始时间和结束时间
export const getAudioStartTimeAndEndTime = async (list: any[]) => {
try {
let durationList = [];
for (let i = 0; i < list.length; i++) {
let data = list[i].data;
let params: any = {
audio_url: data.audio_address,
};
// 计算音频块的起始与结束时间点
let duration = await getDurationOfAudioFile(data.audio_address);
console.log(duration);
params.duration = duration;
// 默认值
params.start = 0;
params.end = duration;
durationList.forEach((it: any) => {
// 开始时间
params.start += it.duration;
});
durationList.push(params);
if (i !== 0) {
durationList.forEach((it: any, index: number) => {
// 不包括自己
if (index !== durationList.length - 1) {
// 结束时间
durationList[i].end += it.duration;
}
});
}
}
return durationList;
} catch (e) {
console.log(e);
}
};
// 洗稿音频回调处理
export const onAudioProcessed = async (res: any, liveInfo: any) => {
let list = [];
......
......@@ -23,7 +23,8 @@ const getters = {
const actions = {
// 洗稿
async confuse({ commit }, params) {
const { user_id, live_task_id, task_id, audio_task_id, createLiveInfo } = params;
// user_id in params
const { live_task_id, task_id, audio_task_id, createLiveInfo } = params;
try {
// 获取洗稿回调
let confuseList = await onRewriteCallback(task_id);
......
......@@ -71,7 +71,7 @@ const actions = {
commit('changeChartColor', isDarkMode ? DARK_CHART_COLORS : LIGHT_CHART_COLORS);
},
changeBrandTheme(_: { state: IStateType }, payload: IStateType) {
changeBrandTheme({ state: IStateType }, payload: IStateType) {
const { brandTheme } = payload;
document.documentElement.setAttribute('theme-color', brandTheme);
......
......@@ -73,9 +73,12 @@ const getters = {
const actions = {
async getUserInfo({ commit }) {
try {
const res: any = await getAdminUserInfo();
commit('setUserInfo', res.data);
return res;
if (state.token) {
const res: any = await getAdminUserInfo();
commit('setUserInfo', res.data);
return res;
}
return false;
} catch (e) {
console.log(e);
}
......
......@@ -3,33 +3,14 @@
*/
import {
Button as TButton,
Select as TSelect,
Option as TOption,
Pagination as TPagination,
Form as TForm,
Input as TInput,
Switch as TSwitch,
FormItem as TFormItem,
Dialog as TDialog,
Checkbox as TCheckbox,
Progress as TProgress,
Upload as TUpload,
} from 'tdesign-vue-next';
const components = [
TButton,
TSelect,
TOption,
TPagination,
TForm,
TFormItem,
TInput,
TSwitch,
TDialog,
TCheckbox,
TProgress,
TUpload,
];
const components = [TButton, TForm, TFormItem, TDialog, TProgress, TUpload];
export default {
install(app) {
......
......@@ -444,7 +444,7 @@ export const mergedArray = (arr: any[], key: string = 'uuid', first: string = 'i
// 获取视频第一帧
export const getFirstFrameOfVideo = (url: string) => {
return new Promise<Blob>((resolve, reject) => {
return new Promise<Blob>((resolve) => {
// let imgbase64 = null;
let video = document.createElement('video');
video.setAttribute('crossOrigin', 'Anonymous');
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment