修复上传问题
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import myaxios from '@/utils/myaxios.ts'
|
||||
import myaxios from '@/utils/myaxios'
|
||||
import { ArticleEntity } from '@/type/interface/ArticleEntity'
|
||||
|
||||
export default {
|
||||
add(data: ArticleEntity) {
|
||||
add(data:any) {
|
||||
console.log(data)
|
||||
return myaxios({
|
||||
url: `/article/add`,
|
||||
@@ -10,7 +10,7 @@ export default {
|
||||
data: data
|
||||
})
|
||||
},
|
||||
pageList(data:ArticleEntity) {
|
||||
pageList(data:any) {
|
||||
return myaxios({
|
||||
url: '/article/pageList',
|
||||
method: 'get',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import myaxios from '@/utils/myaxios.ts'
|
||||
import myaxios from '@/utils/myaxios'
|
||||
|
||||
export default{
|
||||
upload(type:string,data:any){
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import myaxios from '@/utils/myaxios.ts'
|
||||
import myaxios from '@/utils/myaxios'
|
||||
|
||||
// 登录方法
|
||||
export function login(username:string, password:string, code:string, uuid:string) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import {AppGridData} from '@/type/class/AppGridData.ts'
|
||||
import {AppGridData} from '@/type/class/AppGridData'
|
||||
defineProps<{ data: AppGridData }>()
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'vant/es/notify/style';
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import './permission'
|
||||
|
||||
import App from './App.vue'
|
||||
|
||||
const app=createApp(App)
|
||||
|
||||
@@ -13,7 +13,7 @@ const useUserStore = defineStore(
|
||||
}),
|
||||
actions: {
|
||||
// 登录
|
||||
login(userInfo) {
|
||||
login(userInfo:any ) {
|
||||
const username = userInfo.username.trim()
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
@@ -48,7 +48,7 @@ const useUserStore = defineStore(
|
||||
// this.permissions=["*:*:*"]
|
||||
|
||||
} else {
|
||||
this.roles = ['ROLE_DEFAULT']
|
||||
this.roles = ["ROLE_DEFAULT"] as never[]
|
||||
}
|
||||
// this.roles = ["admin"];
|
||||
// this.permissions=["*:*:*"]
|
||||
@@ -67,7 +67,8 @@ const useUserStore = defineStore(
|
||||
// 退出系统
|
||||
logOut() {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(this.token).then((response) => {
|
||||
//this.token
|
||||
logout().then((response) => {
|
||||
this.token = ''
|
||||
this.roles = []
|
||||
this.permissions = []
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import axios from 'axios'
|
||||
// import store from '../store/index'
|
||||
// import vm from '../main'
|
||||
@@ -24,12 +25,12 @@ const myaxios = axios.create({
|
||||
}],
|
||||
})
|
||||
// 请求拦截器
|
||||
myaxios.interceptors.request.use(function(config) {
|
||||
myaxios.interceptors.request.use(function(config:any) {
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
// 是否需要防止数据重复提交
|
||||
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
|
||||
if (getToken() && !isToken) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken()
|
||||
}
|
||||
// store.dispatch("openLoad");
|
||||
return config;
|
||||
|
||||
@@ -73,8 +73,8 @@ import { ref, onMounted, reactive, toRefs } from "vue";
|
||||
import { ImagePreview, Toast } from "vant";
|
||||
import AppCreateTime from "@/components/AppCreateTime.vue";
|
||||
import AppUserIcon from "@/components/AppUserIcon.vue";
|
||||
import articleApi from "@/api/articleApi.ts";
|
||||
import { ArticleEntity } from "@/type/interface/ArticleEntity.ts";
|
||||
import articleApi from "@/api/articleApi";
|
||||
import { ArticleEntity } from "@/type/interface/ArticleEntity";
|
||||
const VanImagePreview = ImagePreview.Component;
|
||||
const url = `${import.meta.env.VITE_APP_BASE_API}/file/`;
|
||||
const data = reactive({
|
||||
@@ -88,7 +88,7 @@ const data = reactive({
|
||||
});
|
||||
const { queryParams } = toRefs(data);
|
||||
|
||||
const articleList = ref<ArticleEntity[]>([]);
|
||||
const articleList = ref<any[]>([]);
|
||||
const totol = ref<Number>(0);
|
||||
const imageShow = ref(false);
|
||||
const index = ref(0);
|
||||
@@ -119,7 +119,7 @@ const onLoad = async () => {
|
||||
finished.value = true;
|
||||
} else {
|
||||
console.log("执行");
|
||||
articleList.value.push(...(response.data.data as ArticleEntity[]));
|
||||
articleList.value.push(...(response.data.data));
|
||||
totol.value = response.data.totol;
|
||||
queryParams.value.pageNum += 1;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ onMounted(() => {
|
||||
|
||||
const getList = () => {
|
||||
articleApi.pageList(queryParams.value).then((response: any) => {
|
||||
articleList.value.push(...(response.data.data as ArticleEntity[]));
|
||||
articleList.value.push(...(response.data.data));
|
||||
totol.value = response.data.totol;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import AppGrid from "@/components/AppGrid.vue";
|
||||
import { AppGridData } from "@/type/class/AppGridData.ts";
|
||||
import { AppGridData } from "@/type/class/AppGridData";
|
||||
import { ref } from "vue";
|
||||
import { Dialog } from "vant";
|
||||
import useUserStore from "@/store/modules/user";
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<van-divider />
|
||||
<van-row>
|
||||
<van-col class="img-col" span="24">
|
||||
<van-uploader :after-read="afterRead" v-model="fileList" multiple />
|
||||
<van-uploader accept="image/*" :after-read="afterRead" v-model="fileList" multiple />
|
||||
</van-col>
|
||||
</van-row>
|
||||
</div>
|
||||
@@ -47,9 +47,9 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive, toRefs,watch } from "vue";
|
||||
import { ArticleEntity } from "@/type/interface/ArticleEntity.ts";
|
||||
import fileApi from "@/api/fileApi.ts";
|
||||
import articleApi from "@/api/articleApi.ts";
|
||||
import { ArticleEntity } from "@/type/interface/ArticleEntity";
|
||||
import fileApi from "@/api/fileApi";
|
||||
import articleApi from "@/api/articleApi";
|
||||
import { Toast } from "vant";
|
||||
import { useRouter } from 'vue-router'
|
||||
const router = useRouter();
|
||||
@@ -58,6 +58,7 @@ const form = reactive<ArticleEntity>({
|
||||
content: "",
|
||||
images: [],
|
||||
isDeleted: false,
|
||||
createTime:""
|
||||
});
|
||||
|
||||
const isSend=ref(false)
|
||||
@@ -68,7 +69,6 @@ onMounted(() => {
|
||||
visible.value = true;
|
||||
});
|
||||
const afterRead = (file: any) => {
|
||||
|
||||
file.status = "uploading";
|
||||
file.message = "上传中...";
|
||||
var formData = new FormData();
|
||||
@@ -83,12 +83,20 @@ else
|
||||
file.forEach((f:any) => {
|
||||
formData.append("file", f.file);
|
||||
});
|
||||
Toast({
|
||||
message: "全部文件正在上传",
|
||||
position: "bottom",
|
||||
});
|
||||
}
|
||||
fileApi.upload("image", formData)
|
||||
.then((response: any) => {
|
||||
images.value.push(...response.data);
|
||||
file.status = "done";
|
||||
file.message = "成功";
|
||||
Toast({
|
||||
message: "文件上传成功",
|
||||
position: "bottom",
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
@@ -118,7 +126,6 @@ watch(()=>form.content,(newValue,oldValue)=>{
|
||||
{
|
||||
isSend.value=true
|
||||
}
|
||||
console.log(isSend.value?'#FFF':'#111')
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user