| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <link id="app-favicon" rel="icon" type="image/svg+xml" href="/vite.svg" />
- <meta
- name="viewport"
- content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
- />
- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
- <meta http-equiv="Pragma" content="no-cache" />
- <meta http-equiv="Expires" content="0" />
- <title></title>
- <script>
- let globalThis = window;
- globalThis.modelServer = "%VITE_API%" || "";
- globalThis.isKnowledgeApi = "%VITE_USE_KNOWLEDGE_API%" === "true";
- // 新版聊天协议后端基础地址(POST /api/chat,SSE)
- globalThis.VITE_CHAT_API = "%VITE_CHAT_API%" || "";
- globalThis.isQingpuEnv = "MODE" === "qingpu";
- globalThis.__ZHAOSHANG_LLM_MODELS = ["zhaoshang", "zhaoshang_staging", "zhaoshang_safe"];
- globalThis.__isZhaoshangLLM = function (model) {
- return globalThis.__ZHAOSHANG_LLM_MODELS.indexOf(model || globalThis.llmModel || "") > -1;
- };
- var cardURL = globalThis.modelServer;
- function getQueryObj(querykey) {
- if (!querykey || typeof querykey !== "string") {
- console.warn("Invalid querykey provided to getQueryObj");
- return "";
- }
- var hash = location.hash;
- if (!hash || hash.indexOf("?") === -1) {
- console.warn("No query parameters found in URL hash");
- return "";
- }
- var queryString = hash.split("?")[1];
- if (!queryString) {
- console.warn('No query string found after "?" in URL hash');
- return "";
- }
- var arr = queryString.split("#")[0].split("&");
- var resObj = {};
- arr.forEach(function (item) {
- if (item) {
- var splitItem = item.split("=");
- var key = splitItem[0];
- var value = splitItem[1] || "";
- if (key) {
- resObj[key] = decodeURIComponent(value);
- }
- }
- });
- return resObj.hasOwnProperty(querykey) ? resObj[querykey] : null;
- }
- function changeLoadingText(text) {
- document.querySelector("#loading-cover").classList.add("blur-effect");
- setTimeout(function () {
- var loadingCover = document.querySelector("#result-text");
- loadingCover.innerText = text;
- var circle = document.querySelector("#circle");
- if (circle) {
- circle.style.display = "none";
- }
- }, 500);
- }
- function showReloadView(text) {
- document.getElementById("error-info").style.display = "flex";
- document.querySelector("#error-tips").innerText = text;
- setTimeout(function () {
- document.getElementById("error-info").style.opacity = 1;
- document.getElementById("error-reload").addEventListener("click", function () {
- location.reload();
- });
- }, 100);
- }
- function addVersionInfo() {
- var version = "%VITE_VERSION%";
- window.humanCardVersion = version;
- var mode = "%MODE%";
- window.humanCardEnv = mode;
- console.log("%c@@@version===>", "color:green;font-size:15px", version, mode);
- document.title += " Ver. " + version;
- if (["development", "test"].includes(mode)) {
- document.title += " " + mode.toUpperCase();
- }
- }
- function randomString() {
- var chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- var length = 32;
- var result = "";
- for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
- return result;
- }
- function initToken() {
- var openId = localStorage.getItem("openId") || randomString();
- localStorage.setItem("openId", openId);
- var requestOptions = {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- openid: openId,
- mobile: "17",
- nickname: globalThis.orgTitle,
- app_key: "%VITE_APP_KEY%",
- }),
- };
- var url = globalThis.modelServer + "/open/openid_to_token";
- fetch(url, requestOptions)
- .then((response) => response.json())
- .then((result) => {
- console.log(result.ret.token);
- globalThis.token = result.ret.token;
- // globalThis.token =
- // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOjMxNjA1MSwiZXhwIjoxNzM2NDE1MDAyLCJpYXQiOjE3MzU1NTEwMDIsImlzcyI6ImFpLWh1bWFuLW1pbmkiLCJzY29wZSI6IiJ9.jYvLswI5NQaeL8W6Q0TQm7sdz4EtqyLRNVjuuKFtdO0";
- // globalThis.mini_id = 10156;
- initCardInfo();
- })
- .catch((error) => console.log("error", error));
- }
- function initCardInfo() {
- var token = globalThis.token;
- var mini = globalThis.mini_id;
- var card_id = globalThis.card_id;
- // if (!token || (!card_id && !mini)) {
- // return;
- // } else {
- // sessionStorage.setItem("token", token);
- // }
- var url = cardURL + "/mini/info";
- let params = [];
- if (mini) {
- params.push("mini=" + mini);
- }
- if (card_id) {
- params.push("card=" + card_id);
- }
- url += "?" + params.join("&");
- fetch(url, {
- method: "get",
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- Authorization: token,
- },
- })
- .then(function (response) {
- return response.json();
- })
- .then(function (result) {
- if (result.err_code === -1) {
- globalThis.showReloadView(result.err_msg);
- return;
- }
- if (result.err_code !== 0) {
- globalThis.changeLoadingText(result.err_msg);
- return;
- }
- if (result.ret.hasOwnProperty("card_id") && result.ret.card_id === 0) {
- globalThis.changeLoadingText("助手不存在,请在管理后台中创建");
- return;
- }
- globalThis.cardInfo = result.ret;
- globalThis.cardInfo.tts_args = {
- speed: 30,
- volume: 100,
- voice_name: "S_x8pOUDlm1",
- };
- globalThis.hasSequence = true;
- // globalThis.token = data.ret;
- document.dispatchEvent(new CustomEvent("dataLoaded"));
- document.dispatchEvent(new CustomEvent("sequenceLoaded"));
- addVersionInfo();
- })
- .catch(function (err) {
- console.warn(err);
- addVersionInfo();
- globalThis.changeLoadingText(err);
- });
- }
- function initMessageChannel() {
- window.addEventListener("message", () => {
- if (event.data && event.data.type === "initMessage") {
- // 这里收到父页面发来的大文本
- console.log("收到父页面消息:", event.data.text);
- localStorage.setItem("initMessage", event.data.text);
- // ...你的业务处理...
- }
- });
- window.parent.postMessage(
- { type: "ready" },
- "%VITE_PARENT_ORIGIN%" // 指定父页面的 origin,务必不要写成 '*',防止安全隐患
- );
- }
- function updateFavicon() {
- var favicon =
- document.querySelector("#app-favicon") || document.querySelector('link[rel="icon"]');
- if (!favicon) {
- favicon = document.createElement("link");
- favicon.id = "app-favicon";
- favicon.rel = "icon";
- document.head.appendChild(favicon);
- }
- var isZhaoshang = globalThis.__isZhaoshangLLM(globalThis.llmModel);
- favicon.type = isZhaoshang ? "image/x-icon" : "image/svg+xml";
- favicon.href = isZhaoshang ? "/qs_favicon.ico" : "/vite.svg";
- }
- (function initSystem() {
- let isLanMode = globalThis.isQingpuEnv;
- globalThis.isXF = false;
- var requestedPolicyMode = getQueryObj("mode");
- var isZhaoshangMode =
- requestedPolicyMode === "zhaoshang" ||
- requestedPolicyMode === "zhaoshang_staging" ||
- requestedPolicyMode === "zhaoshang_safe" ||
- /^zhaoshang_staging_\d+$/.test(requestedPolicyMode || "");
- globalThis.policyMode = isZhaoshangMode ? requestedPolicyMode : "zhaoshang";
- {
- globalThis.card_id = 317;
- globalThis.orgTitle = "营商助手";
- globalThis.llmModel = globalThis.policyMode;
- globalThis.greeting =
- "您好!我是青浦区营商助手”智”小青。我新上岗不久,还在努力学习提升中,请多理解包涵。请问有什么可以帮助您?";
- const credit_code = getQueryObj("credit_code");
- if (credit_code) {
- globalThis.transmission = { credit_code };
- }
- // 预下载完整政策列表到内存中
- (function () {
- var downloadURL = "%VITE_DOWNLOAD_URL%" + "merchant-agent/policies_public.v1.json";
- var localFallbackURL = "/merchant-agent/policies_public.v1.json";
- function applyPolicies(data, source) {
- // 支持 { data: [...] } 和纯数组两种格式
- var list = Array.isArray(data) ? data : data.data;
- globalThis.policiesPublic = list || [];
- console.log(
- "%c[zhaoshang] 政策列表加载完成(" +
- source +
- "):" +
- globalThis.policiesPublic.length +
- " 条",
- "color:green"
- );
- }
- function loadPolicies(url, isFallback) {
- return fetch(url)
- .then(function (response) {
- if (!response.ok) throw new Error("HTTP " + response.status);
- return response.json();
- })
- .then(function (data) {
- applyPolicies(data, isFallback ? "local" : "remote");
- });
- }
- loadPolicies(downloadURL, false).catch(function (err) {
- console.warn("[zhaoshang] 政策列表下载失败,尝试本地兜底:", err);
- loadPolicies(localFallbackURL, true).catch(function (fallbackErr) {
- console.warn("[zhaoshang] 本地政策列表也加载失败:", fallbackErr);
- globalThis.policiesPublic = [];
- });
- });
- })();
- }
- document.title = globalThis.orgTitle;
- updateFavicon();
- initMessageChannel();
- if (globalThis.isKnowledgeApi) {
- document.title = globalThis.orgTitle;
- globalThis.cardInfo = {
- id: 100161,
- human_gender: 1,
- card_id: 297,
- card_name: "政策解读",
- name: "政策解读",
- background: "",
- url: "https://timg.metamaker.cn/mms_threejs_res/1c792f578384242a92f1fb2e1ad8f70d",
- human_avatar:
- "//img.metamaker.cn/resources/52116488a01573be4d6754d7de9090464a54ccc3.png",
- title: "1",
- duty: "1",
- org: "1",
- mobile: "1",
- wx_id: "1",
- logo: "",
- tts_args: {
- speed: 30,
- volume: 100,
- voice_name: "S_x8pOUDlm1",
- },
- share_conf: {
- qrcode: "https://img.metamaker.cn/human_card/b380126e1c138a4c1373f1b6bc8e1a4b.jpg",
- share_img: "https://img.metamaker.cn/human_card/3ce6f8c86bd3525d113dde450aeadbd7.jpg",
- share_title: "政策解读",
- card_img: "https://img.metamaker.cn/human_card/91c4f4e2ccf393168f01761e54802351.jpg",
- },
- func_sets: {
- opt_area: [
- {
- name: "拨打电话",
- type: 1,
- alias: "",
- check: false,
- },
- {
- name: "复制微信",
- type: 2,
- alias: "",
- check: false,
- },
- {
- name: "查看文档",
- type: 3,
- alias: "",
- check: false,
- },
- ],
- question_guide: {
- guess_ask: {
- check: false,
- value: "",
- },
- common_problem: {
- check: false,
- value: [],
- },
- },
- hide_name_brand: 0,
- human_interaction: {
- welcome: {
- check: true,
- value: globalThis.greeting,
- },
- },
- },
- dialog_sets: {
- strict: false,
- only_kl: false,
- unable_answer: {
- text: "很抱歉,我不太理解您的意思,请问您想了解的是什么问题呢?",
- check: false,
- amount: 1,
- },
- belief_threshold: 0.88,
- },
- };
- globalThis.hasSequence = true;
- document.dispatchEvent(new CustomEvent("dataLoaded"));
- document.dispatchEvent(new CustomEvent("sequenceLoaded"));
- addVersionInfo();
- } else {
- initToken();
- }
- })();
- (function () {
- var src = "//cdn.jsdelivr.net/npm/eruda";
- if (!/eruda=true/.test(window.location) && localStorage.getItem("active-eruda") != "true")
- return;
- document.write("<scr" + 'ipt src="' + src + '"></scr' + "ipt>");
- document.write("<scr" + "ipt>eruda.init();</scr" + "ipt>");
- })();
- //
- document.addEventListener("WeixinJSBridgeReady", () => {
- console.log("WeixinJSBridgeReady");
- // let video = document.getElementById("human-stream");
- // video && video.play();
- });
- </script>
- </head>
- <body>
- <div id="app"></div>
- <div id="loading-cover">
- <div id="cover">
- <!-- <div id="circle" data-text=" "></div> -->
- <div id="result-text">正在初始化,请稍候...</div>
- <!-- 加载中,请稍候... -->
- </div>
- </div>
- <div id="error-info" style="display: none; opacity: 0">
- <div id="error-tips"></div>
- <div id="error-reload">重试</div>
- </div>
- <script>
- (function initLoadingAnimation() {
- var circle = document.querySelector("#circle");
- if (!circle) {
- return;
- }
- var text = circle.dataset.text;
- var characters = text.split("");
- var deltaAngle = 360 / characters.length;
- var distanceFromCenter = 110;
- characters.forEach(function (character, index) {
- var span = document.createElement("span");
- span.innerText = character;
- var rotateY = "rotateY(" + index * deltaAngle + "deg)";
- var translateZ = "translateZ(" + distanceFromCenter + "px)";
- span.style.transform = rotateY + " " + translateZ;
- circle.appendChild(span);
- });
- })();
- </script>
- <script>
- var _hmt = _hmt || [];
- (function () {
- var hm = document.createElement("script");
- hm.src = "https://hm.baidu.com/hm.js?d6307cb011c91628ce6be043f40d510a";
- var s = document.getElementsByTagName("script")[0];
- s.parentNode.insertBefore(hm, s);
- })();
- </script>
- <script type="module" src="/src/main.ts"></script>
- <style>
- body {
- margin: 0px;
- background: #fff;
- }
- #loading-cover {
- width: 100%;
- height: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 100;
- font-size: 14px;
- backdrop-filter: blur(40px);
- -webkit-backdrop-filter: blur(40px);
- background: rgba(0, 0, 0, 0.1);
- display: flex;
- justify-content: center;
- align-items: center;
- color: #232323;
- font-family:
- -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
- "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
- "Noto Color Emoji";
- }
- #cover {
- display: flex;
- flex-direction: column;
- }
- #circle {
- position: relative;
- transform-style: preserve-3d;
- animation: rotate-animation 8s linear infinite;
- }
- #circle span {
- position: absolute;
- top: 0;
- left: 0;
- }
- .blur-effect {
- animation: add-blur-effect 1s ease-in-out forwards !important;
- }
- #error-info {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 100vw;
- height: 100vh;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 101;
- transition: all 0.5s ease-in-out;
- }
- #error-tips {
- display: inline-flex;
- padding: 18px 32px;
- justify-content: center;
- align-items: center;
- border-radius: 20px;
- background: rgba(11, 12, 14, 0.8);
- font-family: Inter;
- font-size: 16px;
- font-style: normal;
- font-weight: 400;
- line-height: normal;
- color: #ffffff;
- transform: translateY(-100%);
- }
- #error-reload {
- display: flex;
- width: 162.5px;
- padding: 10px 16px;
- justify-content: center;
- align-items: center;
- border-radius: 14px;
- background: linear-gradient(95deg, rgba(74, 114, 255, 0.96) -6.43%, #925eff 98.24%);
- color: #fff;
- /* title/h5_medium */
- font-family: PingFang HK;
- font-size: 16px;
- font-style: normal;
- font-weight: 500;
- line-height: 24px;
- transform: translateY(500%);
- }
- @keyframes add-blur-effect {
- 0% {
- filter: blur(0px);
- -webkit-filter: blur(0px);
- }
- 50% {
- filter: blur(20px);
- -webkit-filter: blur(20px);
- }
- 100% {
- filter: blur(0px);
- -webkit-filter: blur(0px);
- }
- }
- @keyframes rotate-animation {
- 0% {
- transform: rotateY(360deg) rotateX(-12deg) rotateZ(12deg);
- }
- 50% {
- transform: rotateY(180deg) rotateX(12deg) rotateZ(-12deg);
- }
- 100% {
- transform: rotateY(0) rotateX(-12deg) rotateZ(12deg);
- }
- }
- </style>
- </body>
- </html>
|