Merge pull request 'xbx' (#46) from xbx into master

Reviewed-on: http://git.luyuan.tk/luyuan/beelink/pulls/46
This commit is contained in:
luyuan 2020-10-15 09:22:40 +08:00
commit b92d59b01d
5 changed files with 99 additions and 33 deletions

View File

@ -11,6 +11,7 @@ export interface Get {
}
axios.interceptors.response.use((response)=>{
console.log(response)
if(response.data.code == 1001){
router.push("/")
}
@ -35,6 +36,12 @@ const del: Get = async function (url: string, data?: unknown){
return res.data;
}
const put: Get = async function (url: string, data?: unknown){
const res = await axios.put(url, {params:data})
return res.data;
}
function setToken(){
axios.defaults.headers.common['Authorization'] = "Bearer " + getValue("token");
}
@ -43,5 +50,6 @@ export {
get,
post,
del,
put,
setToken
}

View File

@ -37,7 +37,7 @@ export async function userinfo(){
const user = await get<UserInfo>('personalInfo');
// console.log(user.data.img)
if(user.code == 1001){
// router.push("/")
router.push("/")
return '未登录';
}
return {
@ -277,7 +277,7 @@ export async function sendsms(phone: string, type: number): Promise<boolean>{
}
/**
*
*
*/
interface Countries{
@ -296,3 +296,24 @@ export async function getarchives(): Promise<[Countries[],Willsay[]]>{
}
/**
*
*/
interface Language {
dictionaryid: number;
name: string;
alias: string;
code :string;
position: number;
publish: number;
value: string;
deleted_at: null;
created_at: string;
updated_at: string;
}
export async function getlanguages(): Promise<Language[]>{
return (await get<Language[]>("languages")).data;
}

View File

@ -56,7 +56,9 @@ export default createStore({
actions: {
async setUserInfo({ commit }){
const user = await userinfo();
commit('setUserInfo', user);
if(user != '未登录'){
commit('setUserInfo', user);
}
}
},
modules: {

View File

@ -94,9 +94,19 @@
<a-upload
list-type="picture"
:customRequest="uploads"
:beforeUpload="beforeVideoUpload"
>
<div class="upload-image">
<PlaySquareOutlined style="fontSize: 22px;" />
<PlaySquareOutlined
style="fontsize: 22px"
v-if="uploadprogress == 0"
/>
<a-progress
type="circle"
:percent="uploadprogress"
:width="80"
v-else
/>
</div>
</a-upload>
<div class="demand">
@ -171,8 +181,8 @@
ref="select"
:getPopupContainer="triggerNode => triggerNode.parentNode"
>
<a-select-option v-for="(item, index) in ['英语', '中文']" :key="index" :value="item">
{{ item }}
<a-select-option v-for="(item, index) in languages" :key="index" :value="item.name">
{{ item.name }}
</a-select-option>
</a-select>
</div>
@ -259,14 +269,14 @@
</template>
<script lang="ts">
import { computed, defineComponent, onMounted, reactive, Ref, ref } from "vue";
import { computed, defineComponent, onMounted, reactive, Ref, ref, toRaw, watch } from "vue";
import { UserOutlined, PlaySquareOutlined } from '@ant-design/icons-vue';
import NavBottom from '@/components/NavBottom.vue';
import { uploadflie } from "@/utils/vod"
import store from '@/store';
import smile from "@/static/images/smile.png"
import smilet from "@/static/images/smilet.png"
import { getarchives } from "@/api/index"
import { getarchives, getlanguages } from "@/api/index"
export default defineComponent({
name: "Archives",
@ -291,8 +301,10 @@ export default defineComponent({
const modalNode = () => document.getElementsByClassName('modal-container')[0]
const chiveslist = ref<unknown>([[],[]]);
const languages = ref<unknown>([])
onMounted(async ()=>{
chiveslist.value = await getarchives()
languages.value = await getlanguages()
})
/**
@ -420,20 +432,11 @@ export default defineComponent({
* @return { void }
*/
function submitInfo (): void {
console.log('12');
console.log(toRaw(formData.value));
}
interface AntUpload{
action: string;
data: unknown;
file: File;
}
async function uploads(file: AntUpload){
let res = await uploadflie(file.file, (info) => {
console.log(info)
});
console.log(res)
}
// uploadflie()3.
function setlevel(index: number, level: number){
@ -441,6 +444,33 @@ export default defineComponent({
}
/**
* 上传视频
*/
interface AntUpload{
action: string;
data: unknown;
file: File;
}
const uploadprogress: Ref<number> = ref(0);
async function uploads(file: AntUpload) {
uploadprogress.value=0
let res = await uploadflie(file.file, (info: any) => {
console.log(info);
uploadprogress.value = info.percent.toFixed(2) * 100;
});
userinfo.value.video = res.video.url;
}
if(formData.value.video != ""){
uploadprogress.value = 100
}
watch(formData,()=>{
if(formData.value.video != "" && uploadprogress.value == 0){
uploadprogress.value = 100
}
})
return {
modalNode,
formData,
@ -467,7 +497,9 @@ export default defineComponent({
smile,
smilet,
setlevel,
chiveslist
chiveslist,
languages,
uploadprogress
}
}
});
@ -749,5 +781,8 @@ export default defineComponent({
user-select: none;
}
}
::v-deep(.ant-upload-list) {
display: none;
}
}
</style>

View File

@ -64,18 +64,18 @@
<!-- 文件列表 -->
<div v-if="form.video[0].length">
<div
v-for="(item, index) in form.video"
:key="index"
class="video-list"
>
<img src="@/static/images/link.png" class="link" />
<span class="one-line-hide">{{ item.split('/')[item.split('/').length-1] }}</span>
<img
src="@/static/images/delete.png"
@click="removeFile(0)"
class="del"
/>
</div>
v-for="(item, index) in form.video"
:key="index"
class="video-list"
>
<img src="@/static/images/link.png" class="link" />
<span class="one-line-hide">{{ item.split('/')[item.split('/').length-1] }}</span>
<img
src="@/static/images/delete.png"
@click="removeFile(0)"
class="del"
/>
</div>
</div>
</div>
<div class="demand">