aI问答支持流式输出,效果非常好
This commit is contained in:
157
unpackage/dist/dev/mp-weixin/pages/ai_qa/ai_qa.js
vendored
Normal file
157
unpackage/dist/dev/mp-weixin/pages/ai_qa/ai_qa.js
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
function getSystemInfo() {
|
||||
if (typeof common_vendor.wx$1 !== "undefined" && common_vendor.wx$1.getWindowInfo) {
|
||||
try {
|
||||
const windowInfo = common_vendor.wx$1.getWindowInfo();
|
||||
return {
|
||||
statusBarHeight: windowInfo.statusBarHeight || 20,
|
||||
windowWidth: windowInfo.windowWidth,
|
||||
windowHeight: windowInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("warn", "at pages/ai_qa/ai_qa.vue:113", "[AIQa] wx.getWindowInfo fallback:", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
const systemInfo = common_vendor.index.getSystemInfoSync();
|
||||
return {
|
||||
statusBarHeight: systemInfo.statusBarHeight || 20,
|
||||
windowWidth: systemInfo.windowWidth,
|
||||
windowHeight: systemInfo.windowHeight
|
||||
};
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/ai_qa/ai_qa.vue:125", "[AIQa] getSystemInfoSync:", e);
|
||||
return { statusBarHeight: 20, windowWidth: 375, windowHeight: 667 };
|
||||
}
|
||||
}
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
const systemInfo = getSystemInfo();
|
||||
const statusBarHeightRpx = systemInfo.statusBarHeight * 2;
|
||||
const navbarHeightRpx = 44 * 2;
|
||||
const totalNavbarHeight = statusBarHeightRpx + navbarHeightRpx;
|
||||
return {
|
||||
contentTop: totalNavbarHeight + "rpx",
|
||||
contentBottom: "96rpx"
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
computedContentTop() {
|
||||
const s = getSystemInfo();
|
||||
return s.statusBarHeight * 2 + 44 * 2 + "rpx";
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.updateNavbarPosition();
|
||||
setTimeout(() => this.preloadSubpackage(), 100);
|
||||
},
|
||||
onShow() {
|
||||
this.$nextTick(() => {
|
||||
this.updateNavbarPosition();
|
||||
setTimeout(() => this.updateNavbarPosition(), 50);
|
||||
});
|
||||
},
|
||||
onReady() {
|
||||
this.$nextTick(() => {
|
||||
const query = common_vendor.index.createSelectorQuery().in(this);
|
||||
query.select(".uni-navbar__content").boundingClientRect((data) => {
|
||||
if (data && data.height) {
|
||||
const adjusted = Math.max(data.height * 2 - 4, 0);
|
||||
this.$set(this, "contentTop", adjusted + "rpx");
|
||||
}
|
||||
}).exec();
|
||||
const queryTabbar = common_vendor.index.createSelectorQuery().in(this);
|
||||
queryTabbar.select(".tabbar").boundingClientRect((tabbarData) => {
|
||||
if (tabbarData && tabbarData.height) {
|
||||
const adjustedBottom = Math.max(tabbarData.height * 2 - 4, 0);
|
||||
this.$set(this, "contentBottom", adjustedBottom + "rpx");
|
||||
}
|
||||
}).exec();
|
||||
setTimeout(() => {
|
||||
const q2 = common_vendor.index.createSelectorQuery().in(this);
|
||||
q2.select(".uni-navbar__content").boundingClientRect((data) => {
|
||||
if (data && data.height) {
|
||||
this.$set(this, "contentTop", Math.max(data.height * 2 - 4, 0) + "rpx");
|
||||
}
|
||||
}).exec();
|
||||
const qt2 = common_vendor.index.createSelectorQuery().in(this);
|
||||
qt2.select(".tabbar").boundingClientRect((d) => {
|
||||
if (d && d.height) {
|
||||
this.$set(this, "contentBottom", Math.max(d.height * 2 - 4, 0) + "rpx");
|
||||
}
|
||||
}).exec();
|
||||
}, 200);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
preloadSubpackage() {
|
||||
if (typeof common_vendor.wx$1 !== "undefined" && common_vendor.wx$1.loadSubpackage) {
|
||||
common_vendor.wx$1.loadSubpackage({
|
||||
name: "pages-subpackage",
|
||||
success: () => {
|
||||
},
|
||||
fail: (err) => common_vendor.index.__f__("error", "at pages/ai_qa/ai_qa.vue:201", "[AIQa] loadSubpackage:", err)
|
||||
});
|
||||
}
|
||||
},
|
||||
updateNavbarPosition() {
|
||||
const s = getSystemInfo();
|
||||
const total = s.statusBarHeight * 2 + 44 * 2;
|
||||
this.$set(this, "contentTop", total + "rpx");
|
||||
this.$forceUpdate();
|
||||
},
|
||||
goBack() {
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length <= 1)
|
||||
return;
|
||||
common_vendor.index.navigateBack({
|
||||
fail: (err) => common_vendor.index.__f__("error", "at pages/ai_qa/ai_qa.vue:218", "[AIQa] goBack:", err)
|
||||
});
|
||||
},
|
||||
navigateToQa(slug) {
|
||||
common_vendor.index.navigateTo({
|
||||
url: `/pages-subpackage/ai_qa/${slug}/${slug}`,
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at pages/ai_qa/ai_qa.vue:225", "[AIQa] navigate:", err);
|
||||
common_vendor.index.showToast({ title: "页面跳转失败", icon: "none" });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_uni_nav_bar2 = common_vendor.resolveComponent("uni-nav-bar");
|
||||
_easycom_uni_nav_bar2();
|
||||
}
|
||||
const _easycom_uni_nav_bar = () => "../../uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.js";
|
||||
if (!Math) {
|
||||
_easycom_uni_nav_bar();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.o($options.goBack, "e4"),
|
||||
b: common_vendor.p({
|
||||
fixed: true,
|
||||
statusBar: true,
|
||||
title: "AI问答",
|
||||
leftIcon: "left",
|
||||
color: "#333",
|
||||
backgroundColor: "#FFFFFF"
|
||||
}),
|
||||
c: common_vendor.o(($event) => $options.navigateToQa("general_qa"), "35"),
|
||||
d: common_vendor.o(($event) => $options.navigateToQa("after_sales_qa"), "c0"),
|
||||
e: common_vendor.o(($event) => $options.navigateToQa("demand_qa"), "c8"),
|
||||
f: common_vendor.o(($event) => $options.navigateToQa("price_qa"), "2e"),
|
||||
g: common_vendor.o(($event) => $options.navigateToQa("trust_qa"), "24"),
|
||||
h: common_vendor.o(($event) => $options.navigateToQa("decision_qa"), "b4"),
|
||||
i: common_vendor.o(($event) => $options.navigateToQa("competitor_qa"), "81"),
|
||||
j: common_vendor.o(($event) => $options.navigateToQa("objection_qa"), "0b"),
|
||||
k: common_vendor.o(($event) => $options.navigateToQa("sharp_qa"), "05"),
|
||||
l: $options.computedContentTop || $data.contentTop,
|
||||
m: $data.contentBottom || "96rpx"
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-63bac443"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/ai_qa/ai_qa.js.map
|
||||
Reference in New Issue
Block a user