main
2 1 year ago
parent 658e347d72
commit 05932c110f
  1. 108
      src/pages/lingyunge/demo.vue
  2. 16
      vue.config.js

@ -1,68 +1,64 @@
<template> <template>
<view class="pdd"> <view class="pdd">
<div class="text"> <div class="text">
{{ text }} {{ text }}
</div> </div>
<input type="text" :value="value" /> <input type="text" v-model="value" />
<button @click="queryClick">点击发送</button> <button @click="queryClick">点击发送</button>
</view> </view>
</template> </template>
<script> <script>
import axios from 'axios'; import axios from "axios";
export default { export default {
components: {}, components: {},
data() { data() {
return { return {
text: '', text: "",
value: '', value: "",
}; };
}, },
computed: {}, computed: {},
onShow() { }, onShow() {},
methods: {
async query(data) {
// axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
// axios.post('/api/v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84', JSON.stringify(data), {
// headers: {
// 'Authorization': 'Bearer ZT1v19tYfMb4+2Y6VX7gtf9oacNEy6J03SabP8yfa6w=',
// 'Content-Type': 'application/json',
// }
// }).then(function (resp) {
// console.log(resp)
// }).catch(function (error) {
// console.log(error);
// })
// axios
// .post('v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84', JSON.stringify(data), {
// headers: {
// 'Authorization': 'Bearer ZT1v19tYfMb4+2Y6VX7gtf9oacNEy6J03SabP8yfa6w=',
// 'Content-Type': 'application/json',
// },
// })
// .then(function (response) { /**
// console.log(response); *
// }) async function query(data) {
// .catch(function (error) { const response = await fetch("https://flowise.tsl3060.com/api/v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84", {
// console.log(error);
// });
const response = await fetch('/api/v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84', {
headers: { headers: {
'Authorization': 'Bearer ZT1v19tYfMb4+2Y6VX7gtf9oacNEy6J03SabP8yfa6w=', Authorization: "Bearer ZT1v19tYfMb4+2Y6VX7gtf9oacNEy6J03SabP8yfa6w=",
'Content-Type': 'application/json', "Content-Type": "application/json"
}, },
method: 'POST', method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data)
}); });
const result = await response.json(); const result = await response.json();
return result; return result;
}, }
queryClick() { */
let msg = this.query('hello'); methods: {
console.log(msg); async query(data) {
}, axios
.post(`/api/v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84`, data, {
headers: {
Authorization:
"Bearer ZT1v19tYfMb4+2Y6VX7gtf9oacNEy6J03SabP8yfa6w=",
"Content-Type": "application/json",
},
})
.then((response) => {
console.log(response.data.text);
});
},
queryClick() {
const _this = this;
this.query({
question: _this.value,
}).then((response) => {
console.log(response);
});
}, },
},
}; };
</script> </script>

@ -1,20 +1,24 @@
const { defineConfig } = require('@vue/cli-service') const { defineConfig } = require("@vue/cli-service");
const { BASE_URL } = require('./src/config') const { BASE_URL } = require("./src/config");
module.exports = defineConfig({ module.exports = defineConfig({
transpileDependencies: true, transpileDependencies: true,
lintOnSave: false, lintOnSave: false,
publicPath: BASE_URL, publicPath: BASE_URL,
devServer: { devServer: {
port: 8080, port: 8080,
open: true,// vue项目启动时自动打开浏览器 open: true, // vue项目启动时自动打开浏览器
proxy: { proxy: {
"/api": { "/api": {
target: "http://8.217.66.254:3000", target: "https://flowise.tsl3060.com",
changeOrigin: true, //是否跨域 changeOrigin: true, //是否跨域
logLevel: "debug",
bypass: function (req, res, proxyOptions) {
console.log(proxyOptions.target + req.url, req);
},
pathRewrite: { pathRewrite: {
"^/api": "", // "^/api": "",
}, },
}, },
}, },
}, },
}) });

Loading…
Cancel
Save