if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
const promise = this.constructor;
return this.then(
(value) => promise.resolve(callback()).then(() => value),
(reason) => promise.resolve(callback()).then(() => {
throw reason;
})
);
};
}
;
if (typeof uni !== "undefined" && uni && uni.requireGlobal) {
const global2 = uni.requireGlobal();
ArrayBuffer = global2.ArrayBuffer;
Int8Array = global2.Int8Array;
Uint8Array = global2.Uint8Array;
Uint8ClampedArray = global2.Uint8ClampedArray;
Int16Array = global2.Int16Array;
Uint16Array = global2.Uint16Array;
Int32Array = global2.Int32Array;
Uint32Array = global2.Uint32Array;
Float32Array = global2.Float32Array;
Float64Array = global2.Float64Array;
BigInt64Array = global2.BigInt64Array;
BigUint64Array = global2.BigUint64Array;
}
;
if (uni.restoreGlobal) {
uni.restoreGlobal(Vue, weex, plus, setTimeout, clearTimeout, setInterval, clearInterval);
}
(function(vue) {
"use strict";
const ON_SHOW = "onShow";
function formatAppLog(type, filename, ...args) {
if (uni.__log__) {
uni.__log__(type, filename, ...args);
} else {
console[type].apply(console, [...args, filename]);
}
}
function resolveEasycom(component, easycom) {
return typeof component === "string" ? easycom : component;
}
const createLifeCycleHook = (lifecycle, flag = 0) => (hook, target = vue.getCurrentInstance()) => {
!vue.isInSSRComponentSetup && vue.injectHook(lifecycle, hook, target);
};
const onShow = /* @__PURE__ */ createLifeCycleHook(
ON_SHOW,
1 | 2
/* HookFlags.PAGE */
);
const BASE_URL = "https://cloudtest.yuxindazhineng.com";
const login = async (username, password) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/login`,
method: "POST",
data: {
"username": username,
"password": password,
"login_type": "phone"
},
header: {
"Content-Type": "application/json"
},
success: (res) => {
if (res.statusCode === 200) {
const token = res.data.access_token;
if (token) {
uni.setStorageSync("token", token);
resolve(token);
} else {
const msg = res.data.error || "检查用户名和密码";
reject(msg);
}
} else {
reject(`请求失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const getUserConversations = async (token) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/get_user_conversations`,
method: "POST",
data: {
"access_token": token
},
header: {
"Content-Type": "application/json"
},
success: (res) => {
if (res.statusCode === 200) {
const conversations = res.data.conversations;
resolve(conversations);
} else {
reject(`请求失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const getConversationMessages = async (token, conversatio_id) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/get_conversation_messages`,
method: "POST",
data: {
"access_token": token,
"conversation_id": conversatio_id
},
header: {
"Content-Type": "application/json"
},
success: (res) => {
if (res.statusCode === 200) {
const messagesInfo = res.data;
if (messagesInfo) {
formatAppLog("log", "at utils/cloud-api.js:88", "工作区id为:", messagesInfo.workspace_id);
uni.setStorageSync("workspace_id", messagesInfo.workspace_id);
resolve(messagesInfo.messages);
} else {
const msg = res.data.error || "获取消息出错啦";
reject(msg);
}
} else {
reject(`请求失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const addMessageDict = async (token, role, conversation_id, message) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/add_message_dict`,
method: "POST",
data: {
"access_token": token,
"conversation_id": conversation_id,
"message": {
"role": role,
"content": message
}
},
header: {
"Content-Type": "application/json"
},
success: (res) => {
if (res.statusCode === 200) {
const message_id = res.data.message_id;
if (message_id) {
resolve(message_id);
} else {
const msg = res.data.error || "用户发送消息出错啦";
reject(msg);
}
} else {
reject(`用户发送失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const createWorkspace = async (token, name2) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/create_workspace`,
method: "POST",
data: {
"access_token": token,
"name": name2
},
header: {
"Content-Type": "application/json"
},
success: (res) => {
if (res.statusCode === 200) {
const workspaceId = res.data.workspace_id;
if (workspaceId) {
resolve(workspaceId);
} else {
const msg = res.data.error || "创建工作区id出错啦";
reject(msg);
}
} else {
reject(`创建工作区id失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const createConversation = async (token, workspaceId, title, sender) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/create_conversation`,
method: "POST",
data: {
"access_token": token,
"workspace_id": workspaceId,
"title": title,
"sender": sender
},
header: {
"Content-Type": "application/json"
},
success: (res) => {
if (res.statusCode === 200) {
const conversationId = res.data.conversation_id;
if (conversationId) {
resolve(conversationId);
} else {
const msg = res.data.error || "创建新对话id出错啦";
reject(msg);
}
} else {
reject(`创建新对话失败:${res.statusCode}`);
}
}
});
});
};
const deleteConversation = async (token, conversation_ids) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/delete_conversation`,
method: "POST",
data: {
"access_token": token,
"conversation_ids": conversation_ids
},
header: {
"Content-Type": "application/json"
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond == null ? void 0 : respond.success) {
resolve(respond.message);
} else {
const msg = respond.failed_ids.error || "删除对话出错啦";
reject(msg);
}
} else {
reject(`删除对话失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const getUserInfo = async (token) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/get_user_info`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token
},
success: (res) => {
var _a, _b;
if (res.statusCode === 200) {
const respond = res.data;
if (respond == null ? void 0 : respond._id) {
uni.setStorageSync("userId", respond._id);
resolve(respond);
} else {
const msg = ((_b = (_a = respond == null ? void 0 : respond.detail) == null ? void 0 : _a[0]) == null ? void 0 : _b.msg) || "获取用户信息出错啦";
reject(msg);
}
} else {
reject(`获取用户信息失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const getUserAvatar = (token, userIds) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/cloud_api/get_user_avatar`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token,
"user_ids": userIds
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond.success) {
resolve(respond.users);
} else {
const msg = (respond == null ? void 0 : respond.error) || "获取用户头像出错啦";
reject(msg);
}
} else {
reject(`获取用户头像失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const searchUsers = (token, keyword) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/cloud_api/search_users`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token,
"keyword": keyword
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond.success) {
resolve(respond.users);
} else {
const msg = (respond == null ? void 0 : respond.error) || "通过用户名或邮箱来去查询用户出错啦";
reject(msg);
}
} else {
reject(`通过用户名或邮箱来去查询用户失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const getWorkspaceList = (token, workspacesId) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/cloud_api/phone/workspace/list`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token,
"workspaces_id": workspacesId,
"format": "tree",
"parent_path": "",
"filter_type": ""
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond.success) {
resolve(respond.data);
} else {
const msg = (respond == null ? void 0 : respond.error) || "获取工作区文件目录出错啦";
reject(msg);
}
} else {
reject(`获取工作区文件目录失败:${res.statusCode}`);
}
},
fail: (err) => {
const msg = err.errMsg || "网络错误";
reject(msg);
}
});
});
};
const daleteWorkspace = (token, workspacesId, path) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/cloud_api/phone/workspace/delete`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token,
"workspaces_id": workspacesId,
"file_path": path
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond.success) {
resolve(respond.message);
} else {
const msg = (respond == null ? void 0 : respond.error) || "删除工作区文件出错啦";
reject(msg);
}
} else {
reject(`删除工作区文件失败:${res.statusCode}`);
}
}
});
});
};
const createWorkspaceFolder = (token, workspacesId, path) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/cloud_api/phone/workspace/create`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token,
"workspaces_id": workspacesId,
"dir_path": path
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond.success) {
resolve(respond.message);
} else {
const msg = (respond == null ? void 0 : respond.error) || "创建工作区文件夹出错啦";
reject(msg);
}
} else {
reject(`创建工作区文件夹失败:${res.statusCode}`);
}
}
});
});
};
const getWorkspaceFileURL = (token, workspacesId, path) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/cloud_api/phone/workspace/downloadFile`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token,
"workspaces_id": workspacesId,
"file_path": path
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond.success) {
resolve(respond.message || respond.data);
} else if (Array.isArray(respond)) {
resolve(respond);
} else {
const msg = (respond == null ? void 0 : respond.error) || "获取工作区文URL出错啦";
reject(msg);
}
} else {
reject(`获取工作区文URL失败:${res.statusCode}`);
}
}
});
});
};
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main$a = {
__name: "Login",
setup(__props, { expose: __expose }) {
__expose();
const UsernameValue = vue.ref("");
const isUsernameFocused = vue.ref(false);
const isUsernameError = vue.ref(false);
const usernameFocused = () => {
isUsernameFocused.value = true;
formDataHasNull.value = false;
};
const handleUsernameBlur = () => {
isUsernameFocused.value = false;
};
const validateUsername = () => {
};
const PasswordValue = vue.ref("");
const isPasswordFocused = vue.ref(false);
const isPasswordError = vue.ref(false);
const passwordFocused = () => {
isPasswordFocused.value = true;
formDataHasNull.value = false;
};
const handlePasswordBlur = () => {
isPasswordFocused.value = false;
};
const form = vue.reactive({
username: vue.computed(() => UsernameValue.value),
password: vue.computed(() => PasswordValue.value),
remember: true
});
const loading = vue.ref(false);
const formDataHasNull = vue.ref(false);
const handleLogin = async () => {
checkFormData();
if (formDataHasNull.value)
return;
loading.value = true;
try {
const token = await login(UsernameValue.value, PasswordValue.value);
saveLoginInfo();
uni.reLaunch({
url: "/pages/Chat/Chat"
});
} catch (err) {
formatAppLog("log", "at pages/Login/Login.vue:124", "登录失败", err);
uni.showToast({
title: err || "失败",
icon: "error"
});
} finally {
loading.value = false;
}
};
const checkFormData = () => {
if (!UsernameValue.value || !PasswordValue.value) {
formDataHasNull.value = true;
}
};
const saveLoginInfo = () => {
if (form.remember) {
const loginInfo = {
username: form.username,
password: form.password,
remember: true
};
uni.setStorageSync("login_info", loginInfo);
uni.setStorageSync("chatType", 0);
} else {
uni.removeStorageSync("login_info");
}
};
const loadLoginInfo = () => {
try {
const loginInfo = uni.getStorageSync("login_info");
if (loginInfo) {
UsernameValue.value = loginInfo.username || "";
PasswordValue.value = loginInfo.password || "";
form.remember = loginInfo.remember ?? true;
}
} catch (e2) {
formatAppLog("error", "at pages/Login/Login.vue:168", "读取登录信息失败", e2);
}
};
vue.onMounted(() => {
loadLoginInfo();
});
const __returned__ = { UsernameValue, isUsernameFocused, isUsernameError, usernameFocused, handleUsernameBlur, validateUsername, PasswordValue, isPasswordFocused, isPasswordError, passwordFocused, handlePasswordBlur, form, loading, formDataHasNull, handleLogin, checkFormData, saveLoginInfo, loadLoginInfo, reactive: vue.reactive, ref: vue.ref, computed: vue.computed, onMounted: vue.onMounted, get login() {
return login;
} };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
};
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock(
vue.Fragment,
null,
[
vue.createElementVNode("view", { class: "status-bar" }),
vue.createElementVNode("view", { class: "login-container page-container" }, [
vue.createElementVNode("view", { class: "login-card" }, [
vue.createElementVNode("view", { class: "login-header" }, [
vue.createElementVNode("view", { class: "login-header-logo" }, [
vue.createElementVNode("view", { class: "icon-wrapper" }, [
vue.createElementVNode("view", { class: "iconfont icon-brain-2-fill danao-style" })
]),
vue.createElementVNode("text", null, "YXD")
]),
vue.createElementVNode("view", { class: "sub-title" }, "File Handling Chat")
]),
vue.createElementVNode("view", { class: "form-wrapper" }, [
vue.createElementVNode("view", { class: "form-item" }, [
vue.createElementVNode("view", { class: "form-label" }, [
vue.createElementVNode("text", null, "用户名")
]),
vue.withDirectives(vue.createElementVNode(
"input",
{
class: vue.normalizeClass(["form-input", { focused: $setup.isUsernameFocused, error: $setup.isUsernameError }]),
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.UsernameValue = $event),
onFocus: $setup.usernameFocused,
onBlur: $setup.handleUsernameBlur,
onInput: $setup.validateUsername,
placeholder: "请输入用户名"
},
null,
34
/* CLASS, NEED_HYDRATION */
), [
[vue.vModelText, $setup.UsernameValue]
])
]),
vue.createElementVNode("view", { class: "form-item" }, [
vue.createElementVNode("view", { class: "form-label" }, [
vue.createElementVNode("text", null, "密码")
]),
vue.withDirectives(vue.createElementVNode(
"input",
{
type: "password",
class: vue.normalizeClass(["form-input", { focused: $setup.isPasswordFocused, error: $setup.isPasswordError }]),
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => $setup.PasswordValue = $event),
onFocus: $setup.passwordFocused,
onBlur: $setup.handlePasswordBlur,
placeholder: "请输入密码"
},
null,
34
/* CLASS, NEED_HYDRATION */
), [
[vue.vModelText, $setup.PasswordValue]
])
]),
$setup.formDataHasNull ? (vue.openBlock(), vue.createElementBlock("text", {
key: 0,
class: "error-info"
}, "用户名或密码不能为空")) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "form-option" }, [
vue.createElementVNode("view", {
class: "checkbox-wrapper",
onClick: _cache[2] || (_cache[2] = ($event) => $setup.form.remember = !$setup.form.remember)
}, [
vue.createElementVNode(
"view",
{
class: vue.normalizeClass(["checkbox", { checked: $setup.form.remember }])
},
[
$setup.form.remember ? (vue.openBlock(), vue.createElementBlock("text", { key: 0 }, "✓")) : vue.createCommentVNode("v-if", true)
],
2
/* CLASS */
),
vue.createElementVNode("text", { class: "checkbox-text" }, "记住密码")
]),
vue.createElementVNode("text", { class: "forget-pwd" }, "忘记密码?")
]),
vue.createElementVNode("button", {
class: "login-btn",
disabled: $setup.loading,
loading: $setup.loading,
onClick: $setup.handleLogin
}, vue.toDisplayString($setup.loading ? "Loading..." : "登录"), 9, ["disabled", "loading"])
])
])
])
],
64
/* STABLE_FRAGMENT */
);
}
const PagesLoginLogin = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$9], ["__scopeId", "data-v-461d1d79"], ["__file", "D:/Projects/uniapp/app-test/test1/pages/Login/Login.vue"]]);
const fontData = [
{
"font_class": "arrow-down",
"unicode": ""
},
{
"font_class": "arrow-left",
"unicode": ""
},
{
"font_class": "arrow-right",
"unicode": ""
},
{
"font_class": "arrow-up",
"unicode": ""
},
{
"font_class": "auth",
"unicode": ""
},
{
"font_class": "auth-filled",
"unicode": ""
},
{
"font_class": "back",
"unicode": ""
},
{
"font_class": "bars",
"unicode": ""
},
{
"font_class": "calendar",
"unicode": ""
},
{
"font_class": "calendar-filled",
"unicode": ""
},
{
"font_class": "camera",
"unicode": ""
},
{
"font_class": "camera-filled",
"unicode": ""
},
{
"font_class": "cart",
"unicode": ""
},
{
"font_class": "cart-filled",
"unicode": ""
},
{
"font_class": "chat",
"unicode": ""
},
{
"font_class": "chat-filled",
"unicode": ""
},
{
"font_class": "chatboxes",
"unicode": ""
},
{
"font_class": "chatboxes-filled",
"unicode": ""
},
{
"font_class": "chatbubble",
"unicode": ""
},
{
"font_class": "chatbubble-filled",
"unicode": ""
},
{
"font_class": "checkbox",
"unicode": ""
},
{
"font_class": "checkbox-filled",
"unicode": ""
},
{
"font_class": "checkmarkempty",
"unicode": ""
},
{
"font_class": "circle",
"unicode": ""
},
{
"font_class": "circle-filled",
"unicode": ""
},
{
"font_class": "clear",
"unicode": ""
},
{
"font_class": "close",
"unicode": ""
},
{
"font_class": "closeempty",
"unicode": ""
},
{
"font_class": "cloud-download",
"unicode": ""
},
{
"font_class": "cloud-download-filled",
"unicode": ""
},
{
"font_class": "cloud-upload",
"unicode": ""
},
{
"font_class": "cloud-upload-filled",
"unicode": ""
},
{
"font_class": "color",
"unicode": ""
},
{
"font_class": "color-filled",
"unicode": ""
},
{
"font_class": "compose",
"unicode": ""
},
{
"font_class": "contact",
"unicode": ""
},
{
"font_class": "contact-filled",
"unicode": ""
},
{
"font_class": "down",
"unicode": ""
},
{
"font_class": "bottom",
"unicode": ""
},
{
"font_class": "download",
"unicode": ""
},
{
"font_class": "download-filled",
"unicode": ""
},
{
"font_class": "email",
"unicode": ""
},
{
"font_class": "email-filled",
"unicode": ""
},
{
"font_class": "eye",
"unicode": ""
},
{
"font_class": "eye-filled",
"unicode": ""
},
{
"font_class": "eye-slash",
"unicode": ""
},
{
"font_class": "eye-slash-filled",
"unicode": ""
},
{
"font_class": "fire",
"unicode": ""
},
{
"font_class": "fire-filled",
"unicode": ""
},
{
"font_class": "flag",
"unicode": ""
},
{
"font_class": "flag-filled",
"unicode": ""
},
{
"font_class": "folder-add",
"unicode": ""
},
{
"font_class": "folder-add-filled",
"unicode": ""
},
{
"font_class": "font",
"unicode": ""
},
{
"font_class": "forward",
"unicode": ""
},
{
"font_class": "gear",
"unicode": ""
},
{
"font_class": "gear-filled",
"unicode": ""
},
{
"font_class": "gift",
"unicode": ""
},
{
"font_class": "gift-filled",
"unicode": ""
},
{
"font_class": "hand-down",
"unicode": ""
},
{
"font_class": "hand-down-filled",
"unicode": ""
},
{
"font_class": "hand-up",
"unicode": ""
},
{
"font_class": "hand-up-filled",
"unicode": ""
},
{
"font_class": "headphones",
"unicode": ""
},
{
"font_class": "heart",
"unicode": ""
},
{
"font_class": "heart-filled",
"unicode": ""
},
{
"font_class": "help",
"unicode": ""
},
{
"font_class": "help-filled",
"unicode": ""
},
{
"font_class": "home",
"unicode": ""
},
{
"font_class": "home-filled",
"unicode": ""
},
{
"font_class": "image",
"unicode": ""
},
{
"font_class": "image-filled",
"unicode": ""
},
{
"font_class": "images",
"unicode": ""
},
{
"font_class": "images-filled",
"unicode": ""
},
{
"font_class": "info",
"unicode": ""
},
{
"font_class": "info-filled",
"unicode": ""
},
{
"font_class": "left",
"unicode": ""
},
{
"font_class": "link",
"unicode": ""
},
{
"font_class": "list",
"unicode": ""
},
{
"font_class": "location",
"unicode": ""
},
{
"font_class": "location-filled",
"unicode": ""
},
{
"font_class": "locked",
"unicode": ""
},
{
"font_class": "locked-filled",
"unicode": ""
},
{
"font_class": "loop",
"unicode": ""
},
{
"font_class": "mail-open",
"unicode": ""
},
{
"font_class": "mail-open-filled",
"unicode": ""
},
{
"font_class": "map",
"unicode": ""
},
{
"font_class": "map-filled",
"unicode": ""
},
{
"font_class": "map-pin",
"unicode": ""
},
{
"font_class": "map-pin-ellipse",
"unicode": ""
},
{
"font_class": "medal",
"unicode": ""
},
{
"font_class": "medal-filled",
"unicode": ""
},
{
"font_class": "mic",
"unicode": ""
},
{
"font_class": "mic-filled",
"unicode": ""
},
{
"font_class": "micoff",
"unicode": ""
},
{
"font_class": "micoff-filled",
"unicode": ""
},
{
"font_class": "minus",
"unicode": ""
},
{
"font_class": "minus-filled",
"unicode": ""
},
{
"font_class": "more",
"unicode": ""
},
{
"font_class": "more-filled",
"unicode": ""
},
{
"font_class": "navigate",
"unicode": ""
},
{
"font_class": "navigate-filled",
"unicode": ""
},
{
"font_class": "notification",
"unicode": ""
},
{
"font_class": "notification-filled",
"unicode": ""
},
{
"font_class": "paperclip",
"unicode": ""
},
{
"font_class": "paperplane",
"unicode": ""
},
{
"font_class": "paperplane-filled",
"unicode": ""
},
{
"font_class": "person",
"unicode": ""
},
{
"font_class": "person-filled",
"unicode": ""
},
{
"font_class": "personadd",
"unicode": ""
},
{
"font_class": "personadd-filled",
"unicode": ""
},
{
"font_class": "personadd-filled-copy",
"unicode": ""
},
{
"font_class": "phone",
"unicode": ""
},
{
"font_class": "phone-filled",
"unicode": ""
},
{
"font_class": "plus",
"unicode": ""
},
{
"font_class": "plus-filled",
"unicode": ""
},
{
"font_class": "plusempty",
"unicode": ""
},
{
"font_class": "pulldown",
"unicode": ""
},
{
"font_class": "pyq",
"unicode": ""
},
{
"font_class": "qq",
"unicode": ""
},
{
"font_class": "redo",
"unicode": ""
},
{
"font_class": "redo-filled",
"unicode": ""
},
{
"font_class": "refresh",
"unicode": ""
},
{
"font_class": "refresh-filled",
"unicode": ""
},
{
"font_class": "refreshempty",
"unicode": ""
},
{
"font_class": "reload",
"unicode": ""
},
{
"font_class": "right",
"unicode": ""
},
{
"font_class": "scan",
"unicode": ""
},
{
"font_class": "search",
"unicode": ""
},
{
"font_class": "settings",
"unicode": ""
},
{
"font_class": "settings-filled",
"unicode": ""
},
{
"font_class": "shop",
"unicode": ""
},
{
"font_class": "shop-filled",
"unicode": ""
},
{
"font_class": "smallcircle",
"unicode": ""
},
{
"font_class": "smallcircle-filled",
"unicode": ""
},
{
"font_class": "sound",
"unicode": ""
},
{
"font_class": "sound-filled",
"unicode": ""
},
{
"font_class": "spinner-cycle",
"unicode": ""
},
{
"font_class": "staff",
"unicode": ""
},
{
"font_class": "staff-filled",
"unicode": ""
},
{
"font_class": "star",
"unicode": ""
},
{
"font_class": "star-filled",
"unicode": ""
},
{
"font_class": "starhalf",
"unicode": ""
},
{
"font_class": "trash",
"unicode": ""
},
{
"font_class": "trash-filled",
"unicode": ""
},
{
"font_class": "tune",
"unicode": ""
},
{
"font_class": "tune-filled",
"unicode": ""
},
{
"font_class": "undo",
"unicode": ""
},
{
"font_class": "undo-filled",
"unicode": ""
},
{
"font_class": "up",
"unicode": ""
},
{
"font_class": "top",
"unicode": ""
},
{
"font_class": "upload",
"unicode": ""
},
{
"font_class": "upload-filled",
"unicode": ""
},
{
"font_class": "videocam",
"unicode": ""
},
{
"font_class": "videocam-filled",
"unicode": ""
},
{
"font_class": "vip",
"unicode": ""
},
{
"font_class": "vip-filled",
"unicode": ""
},
{
"font_class": "wallet",
"unicode": ""
},
{
"font_class": "wallet-filled",
"unicode": ""
},
{
"font_class": "weibo",
"unicode": ""
},
{
"font_class": "weixin",
"unicode": ""
}
];
const getVal = (val) => {
const reg = /^[0-9]*$/g;
return typeof val === "number" || reg.test(val) ? val + "px" : val;
};
const _sfc_main$9 = {
name: "UniIcons",
emits: ["click"],
props: {
type: {
type: String,
default: ""
},
color: {
type: String,
default: "#333333"
},
size: {
type: [Number, String],
default: 16
},
customPrefix: {
type: String,
default: ""
},
fontFamily: {
type: String,
default: ""
}
},
data() {
return {
icons: fontData
};
},
computed: {
unicode() {
let code = this.icons.find((v) => v.font_class === this.type);
if (code) {
return code.unicode;
}
return "";
},
iconSize() {
return getVal(this.size);
},
styleObj() {
if (this.fontFamily !== "") {
return `color: ${this.color}; font-size: ${this.iconSize}; font-family: ${this.fontFamily};`;
}
return `color: ${this.color}; font-size: ${this.iconSize};`;
}
},
methods: {
_onClick(e2) {
this.$emit("click", e2);
}
}
};
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock(
"text",
{
style: vue.normalizeStyle($options.styleObj),
class: vue.normalizeClass(["uni-icons", ["uniui-" + $props.type, $props.customPrefix, $props.customPrefix ? $props.type : ""]]),
onClick: _cache[0] || (_cache[0] = (...args) => $options._onClick && $options._onClick(...args))
},
[
vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
],
6
/* CLASS, STYLE */
);
}
const __easycom_0 = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$8], ["__scopeId", "data-v-d31e1c47"], ["__file", "D:/Projects/uniapp/app-test/test1/uni_modules/uni-icons/components/uni-icons/uni-icons.vue"]]);
const getToken = () => {
return uni.getStorageSync("token");
};
const getCurrentSessionId = () => {
const sessionId = uni.getStorageSync("currentSessionId");
if (!isNaN(Number(sessionId))) {
return sessionId;
}
return sessionId.replace(/-/g, "");
};
const getTaskCallId = () => {
return uni.getStorageSync("taskCallId");
};
const getUserId = () => {
formatAppLog("log", "at utils/user-info.js:50", "用户Id(UserId)", uni.getStorageSync("userId"));
return uni.getStorageSync("userId");
};
const getChatType = () => {
return uni.getStorageSync("chatType");
};
const getReceiverId = () => {
return uni.getStorageSync("receiverId");
};
const getWorkspaceId = () => {
return uni.getStorageSync("workspace_id");
};
const _sfc_main$8 = /* @__PURE__ */ Object.assign({
name: "ChatSidebar"
}, {
__name: "ChatSidebar",
props: {
chatList: {
type: Array,
required: true
},
showNewChatModal: {
type: Boolean,
default: false
},
currentSessionId: {
type: [String, Number],
required: true
},
chatType: {
type: Number,
required: true
}
},
emits: [
"update:showNewChatModal",
"update:currentSessionId",
"refresh-conversations",
"update:chatType"
],
setup(__props, { expose: __expose, emit: __emit }) {
__expose();
const props = __props;
const emit = __emit;
const UserConversations = vue.toRef(props, "chatList");
const showNewChatModal = vue.toRef(props, "showNewChatModal");
const chatType = vue.toRef(props, "chatType");
const openUserCardVisible = () => {
uni.navigateTo({
url: "/pages/UserProfileModal/UserProfileModal"
});
};
const isSelectMode = vue.ref(false);
const selectedHistoryIds = vue.ref([]);
const deleteConversations = () => {
if (selectedHistoryIds.value.length === 0)
return;
uni.showModal({
title: "确认删除",
content: `确定要删除全部 ${selectedHistoryIds.value.length} 个对话吗?此操作不可恢复。`,
confirmText: "确认删除",
confirmColor: "#ff0000",
success: async (res) => {
if (res.confirm) {
try {
const userToken = getToken();
await deleteConversation(userToken, selectedHistoryIds.value);
uni.showToast({
title: "删除成功",
icon: "success"
});
selectedHistoryIds.value = [];
isSelectMode.value = false;
emit("refresh-conversations");
} catch (error) {
formatAppLog("error", "at components/ChatSidebar.vue:209", "删除会话失败:", error);
uni.showToast({
title: "删除失败,请重试",
icon: "none"
});
}
}
}
});
};
const clearAllConversations = () => {
if (!UserConversations.value.length) {
uni.showToast({ title: "没有可删除的会话", icon: "none" });
return;
}
uni.showModal({
title: "确认删除",
content: `确定要删除全部 ${UserConversations.value.length} 个对话吗?此操作不可恢复。`,
confirmText: "删除全部",
confirmColor: "#ff0000",
success: async (res) => {
if (res.confirm) {
try {
const userToken = getToken();
const allIds = UserConversations.value.map((item) => item._id);
await deleteConversation(userToken, allIds);
uni.showToast({ title: "已删除全部对话", icon: "success" });
emit("refresh-conversations");
} catch (error) {
formatAppLog("error", "at components/ChatSidebar.vue:241", "清空全部对话失败:", error);
uni.showToast({ title: "删除失败,请重试", icon: "none" });
}
}
}
});
};
const isAllHistorySelected = vue.computed(() => {
return UserConversations.value.length > 0 && selectedHistoryIds.value.length === UserConversations.value.length;
});
const currentChatId = vue.toRef(props, "currentSessionId");
const selectChat = (chatId, receiverId = "") => {
formatAppLog("log", "at components/ChatSidebar.vue:259", "选择的id是:", chatId);
if (receiverId) {
uni.setStorageSync("receiverId", receiverId);
}
uni.setStorageSync("currentSessionId", chatId);
emit("update:currentSessionId", chatId);
};
const openNewChatModal = () => {
formatAppLog("log", "at components/ChatSidebar.vue:270", "点击了新建会话");
emit("update:showNewChatModal", true);
};
const goContactPages = () => {
uni.navigateTo({
url: "/pages/ContactPages/ContactPages"
});
};
const chatHistoryQuery = vue.ref("");
const isHistorySearchFocused = vue.ref(false);
const toggleSelectMode = () => {
isSelectMode.value = !isSelectMode.value;
if (!isSelectMode.value) {
selectedHistoryIds.value = [];
}
};
const toggleHistorySelect = (chatId) => {
const index = selectedHistoryIds.value.indexOf(chatId);
if (index === -1) {
selectedHistoryIds.value.push(chatId);
} else {
selectedHistoryIds.value.splice(index, 1);
}
};
const toggleSelectAllHistory = () => {
if (isAllHistorySelected.value) {
selectedHistoryIds.value = [];
} else {
selectedHistoryIds.value = UserConversations.value.map((chat) => chat._id);
}
};
const UserToken = vue.ref("");
const UserAvatar = vue.ref("");
const UserName = vue.ref("");
vue.onMounted(async () => {
UserToken.value = getToken();
const UserInfo = await getUserInfo(UserToken.value);
UserAvatar.value = UserInfo.avatar || "";
UserName.value = UserInfo.username || "";
formatAppLog("log", "at components/ChatSidebar.vue:320", "菜单收到的会话列表:", UserConversations.value);
});
const __returned__ = { props, emit, UserConversations, showNewChatModal, chatType, openUserCardVisible, isSelectMode, selectedHistoryIds, deleteConversations, clearAllConversations, isAllHistorySelected, currentChatId, selectChat, openNewChatModal, goContactPages, chatHistoryQuery, isHistorySearchFocused, toggleSelectMode, toggleHistorySelect, toggleSelectAllHistory, UserToken, UserAvatar, UserName, computed: vue.computed, onMounted: vue.onMounted, onUnmounted: vue.onUnmounted, ref: vue.ref, toRef: vue.toRef, get deleteConversation() {
return deleteConversation;
}, get getToken() {
return getToken;
}, get getUserInfo() {
return getUserInfo;
} };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
});
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
const _component_uni_icons = resolveEasycom(vue.resolveDynamicComponent("uni-icons"), __easycom_0);
return vue.openBlock(), vue.createElementBlock("view", { class: "chat-sidebar-container" }, [
vue.createElementVNode("view", { class: "status-bar" }),
vue.createElementVNode("view", { class: "sidebar-header" }, [
vue.createElementVNode("view", {
class: "user-profile-card",
onClick: $setup.openUserCardVisible
}, [
vue.createElementVNode("view", { class: "left" }, [
$setup.UserAvatar ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "avatar-preview"
}, [
vue.createElementVNode("image", {
src: $setup.UserAvatar,
mode: "aspectFill"
}, null, 8, ["src"])
])) : (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "avatar-placeholder"
}, [
vue.createVNode(_component_uni_icons, {
type: "contact-filled",
size: "50",
color: "#007aff"
})
]))
]),
vue.createElementVNode("view", { class: "center" }, [
vue.createElementVNode("text", null, "欢迎回来"),
vue.createElementVNode(
"text",
null,
vue.toDisplayString($setup.UserName),
1
/* TEXT */
)
]),
vue.createElementVNode("view", { class: "right" }, [
vue.createElementVNode("view", { class: "status-dot" }),
vue.createElementVNode("view", { class: "status-text" }, [
vue.createElementVNode("text", null, "在线")
])
])
]),
vue.createElementVNode("view", {
class: "new-chat-btn",
onClick: $setup.goContactPages
}, [
vue.createElementVNode("text", null, "+ 聊天列表")
])
]),
vue.createElementVNode("view", { class: "chat-history" }, [
vue.createElementVNode("view", { class: "history-header" }, [
vue.createElementVNode("view", { class: "history-title-section" }, [
vue.createElementVNode("text", null, "历史会话"),
vue.createElementVNode(
"text",
null,
vue.toDisplayString($setup.UserConversations.length) + "个对话",
1
/* TEXT */
)
]),
vue.createElementVNode("view", { class: "history-management" }, [
!$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "history-management-btn iconfont icon-jia icon-jia-style",
onClick: $setup.openNewChatModal
})) : vue.createCommentVNode("v-if", true),
!$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "history-management-btn iconfont icon-duoxuan icon-duoxuan-style",
onClick: $setup.toggleSelectMode
})) : vue.createCommentVNode("v-if", true),
!$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 2,
class: "history-management-btn iconfont icon-saochu icon-saochu-style",
onClick: $setup.clearAllConversations
})) : vue.createCommentVNode("v-if", true),
$setup.isSelectMode && $setup.selectedHistoryIds.length > 0 ? (vue.openBlock(), vue.createElementBlock("view", {
key: 3,
class: "history-management-btn iconfont icon-shanchu icon-shanchu-style",
onClick: $setup.deleteConversations
})) : vue.createCommentVNode("v-if", true),
$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock(
"view",
{
key: 4,
class: vue.normalizeClass(["history-management-btn iconfont icon-total_selection icon-total_selection-style", { active: $setup.isAllHistorySelected }]),
onClick: $setup.toggleSelectAllHistory
},
null,
2
/* CLASS */
)) : vue.createCommentVNode("v-if", true),
$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 5,
class: "history-management-btn iconfont icon-quxiao icon-quxiao-style",
onClick: $setup.toggleSelectMode
})) : vue.createCommentVNode("v-if", true)
])
]),
!$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "history-search-wrap"
}, [
vue.createElementVNode(
"view",
{
class: vue.normalizeClass(["history-search-inner", { "has-value": $setup.chatHistoryQuery || $setup.isHistorySearchFocused }])
},
[
vue.createVNode(_component_uni_icons, {
type: "search",
class: vue.normalizeClass([$setup.chatHistoryQuery || $setup.isHistorySearchFocused ? "chat-search-icon" : "search-icon"])
}, null, 8, ["class"]),
vue.withDirectives(vue.createElementVNode(
"input",
{
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.chatHistoryQuery = $event),
onFocus: _cache[1] || (_cache[1] = ($event) => $setup.isHistorySearchFocused = true),
onBlur: _cache[2] || (_cache[2] = ($event) => $setup.isHistorySearchFocused = false),
type: "text",
placeholder: "搜索会话..."
},
null,
544
/* NEED_HYDRATION, NEED_PATCH */
), [
[vue.vModelText, $setup.chatHistoryQuery]
])
],
2
/* CLASS */
)
])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "chat-history-list" }, [
$setup.chatType === 0 ? (vue.openBlock(true), vue.createElementBlock(
vue.Fragment,
{ key: 0 },
vue.renderList($setup.UserConversations, (chat) => {
return vue.openBlock(), vue.createElementBlock("view", {
key: chat._id,
"data-chat-id": chat._id,
class: vue.normalizeClass(["chat-history-card", { "is-select-chat": $setup.currentChatId === chat._id || $setup.selectedHistoryIds.includes(chat._id) }]),
onClick: ($event) => $setup.isSelectMode ? $setup.toggleHistorySelect(chat._id) : $setup.selectChat(chat._id)
}, [
$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "history-chat-checkbox"
}, [
$setup.selectedHistoryIds.includes(chat._id) ? (vue.openBlock(), vue.createBlock(_component_uni_icons, {
key: 0,
type: "checkmarkempty",
size: "20",
color: "#007aff"
})) : vue.createCommentVNode("v-if", true)
])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "history-chat-avatar" }, [
vue.createVNode(_component_uni_icons, {
type: "chat-filled",
size: "26",
color: "#007aff"
})
]),
chat.agent_id ? (vue.openBlock(), vue.createElementBlock(
"view",
{ key: 1 },
vue.toDisplayString(chat.agent_data.title),
1
/* TEXT */
)) : (vue.openBlock(), vue.createElementBlock(
"view",
{ key: 2 },
vue.toDisplayString(chat.title),
1
/* TEXT */
))
], 10, ["data-chat-id", "onClick"]);
}),
128
/* KEYED_FRAGMENT */
)) : vue.createCommentVNode("v-if", true),
$setup.chatType === 1 ? (vue.openBlock(true), vue.createElementBlock(
vue.Fragment,
{ key: 1 },
vue.renderList($setup.UserConversations, (chat) => {
return vue.openBlock(), vue.createElementBlock("view", {
key: chat.sessionId,
"data-chat-id": chat.sessionId,
class: vue.normalizeClass(["chat-history-card", { "is-select-chat": $setup.currentChatId === chat.sessionId || $setup.selectedHistoryIds.includes(chat.sessionId) }]),
onClick: ($event) => $setup.isSelectMode ? $setup.toggleHistorySelect(chat.sessionId) : $setup.selectChat(chat.sessionId, chat.receiver)
}, [
$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "history-chat-checkbox"
}, [
$setup.selectedHistoryIds.includes(chat.sessionId) ? (vue.openBlock(), vue.createBlock(_component_uni_icons, {
key: 0,
type: "checkmarkempty",
size: "20",
color: "#007aff"
})) : vue.createCommentVNode("v-if", true)
])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "history-chat-avatar" }, [
chat.avatar ? (vue.openBlock(), vue.createElementBlock("image", {
key: 0,
src: chat.avatar,
class: "friend-avatar",
mode: "aspectFill"
}, null, 8, ["src"])) : vue.createCommentVNode("v-if", true)
]),
vue.createElementVNode(
"view",
null,
vue.toDisplayString(chat.friendNickName),
1
/* TEXT */
)
], 10, ["data-chat-id", "onClick"]);
}),
128
/* KEYED_FRAGMENT */
)) : vue.createCommentVNode("v-if", true),
$setup.chatType === 2 ? (vue.openBlock(true), vue.createElementBlock(
vue.Fragment,
{ key: 2 },
vue.renderList($setup.UserConversations, (chat) => {
return vue.openBlock(), vue.createElementBlock("view", {
key: chat.id,
"data-chat-id": chat.id,
class: vue.normalizeClass(["chat-history-card", { "is-select-chat": $setup.currentChatId === chat.id || $setup.selectedHistoryIds.includes(chat.id) }]),
onClick: ($event) => $setup.isSelectMode ? $setup.toggleHistorySelect(chat.id) : $setup.selectChat(chat.id)
}, [
$setup.isSelectMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "history-chat-checkbox"
}, [
$setup.selectedHistoryIds.includes(chat.id) ? (vue.openBlock(), vue.createBlock(_component_uni_icons, {
key: 0,
type: "checkmarkempty",
size: "20",
color: "#007aff"
})) : vue.createCommentVNode("v-if", true)
])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "history-chat-avatar" }, [
vue.createElementVNode("view", {
class: "iconfont icon-qunliao",
style: { "font-size": "80rpx", "color": "#fff" }
})
]),
vue.createElementVNode(
"view",
null,
vue.toDisplayString(chat.name),
1
/* TEXT */
)
], 10, ["data-chat-id", "onClick"]);
}),
128
/* KEYED_FRAGMENT */
)) : vue.createCommentVNode("v-if", true)
])
])
]);
}
const ChatSidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$7], ["__scopeId", "data-v-0c6c7315"], ["__file", "D:/Projects/uniapp/app-test/test1/components/ChatSidebar.vue"]]);
var e = { "": ["", ""], _: ["", ""], "*": ["", ""], "~": ["", ""], "\n": ["
"], " ": ["
"], "-": ["
" + n(r(p).replace(/^\n+|\n+$/g, "")) + "" : (p = g[6]) ? (p.match(/\./) && (g[5] = g[5].replace(/^\d+/gm, "")), s = t(n(g[5].replace(/^\s*[>*+.-]/gm, ""))), ">" == p ? p = "blockquote" : (p = p.match(/\./) ? "ol" : "ul", s = s.replace(/^(.*)(\n|$)/gm, "" + r(g[16]) + "" : (g[17] || g[1]) && (o = f(g[17] || "--"))), h += l, h += o;
return (h + a.substring(d) + $()).replace(/^\n+|\n+$/g, "");
}
var isVue2 = false;
function set(target, key, val) {
if (Array.isArray(target)) {
target.length = Math.max(target.length, key);
target.splice(key, 1, val);
return val;
}
target[key] = val;
return val;
}
function del(target, key) {
if (Array.isArray(target)) {
target.splice(key, 1);
return;
}
delete target[key];
}
function getDevtoolsGlobalHook() {
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
function getTarget() {
return typeof navigator !== "undefined" && typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
}
const isProxyAvailable = typeof Proxy === "function";
const HOOK_SETUP = "devtools-plugin:setup";
const HOOK_PLUGIN_SETTINGS_SET = "plugin:settings:set";
let supported;
let perf;
function isPerformanceSupported() {
var _a;
if (supported !== void 0) {
return supported;
}
if (typeof window !== "undefined" && window.performance) {
supported = true;
perf = window.performance;
} else if (typeof global !== "undefined" && ((_a = global.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) {
supported = true;
perf = global.perf_hooks.performance;
} else {
supported = false;
}
return supported;
}
function now() {
return isPerformanceSupported() ? perf.now() : Date.now();
}
class ApiProxy {
constructor(plugin, hook) {
this.target = null;
this.targetQueue = [];
this.onQueue = [];
this.plugin = plugin;
this.hook = hook;
const defaultSettings = {};
if (plugin.settings) {
for (const id in plugin.settings) {
const item = plugin.settings[id];
defaultSettings[id] = item.defaultValue;
}
}
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`;
let currentSettings = Object.assign({}, defaultSettings);
try {
const raw = localStorage.getItem(localSettingsSaveId);
const data = JSON.parse(raw);
Object.assign(currentSettings, data);
} catch (e2) {
}
this.fallbacks = {
getSettings() {
return currentSettings;
},
setSettings(value) {
try {
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
} catch (e2) {
}
currentSettings = value;
},
now() {
return now();
}
};
if (hook) {
hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
if (pluginId === this.plugin.id) {
this.fallbacks.setSettings(value);
}
});
}
this.proxiedOn = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target.on[prop];
} else {
return (...args) => {
this.onQueue.push({
method: prop,
args
});
};
}
}
});
this.proxiedTarget = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target[prop];
} else if (prop === "on") {
return this.proxiedOn;
} else if (Object.keys(this.fallbacks).includes(prop)) {
return (...args) => {
this.targetQueue.push({
method: prop,
args,
resolve: () => {
}
});
return this.fallbacks[prop](...args);
};
} else {
return (...args) => {
return new Promise((resolve) => {
this.targetQueue.push({
method: prop,
args,
resolve
});
});
};
}
}
});
}
async setRealTarget(target) {
this.target = target;
for (const item of this.onQueue) {
this.target.on[item.method](...item.args);
}
for (const item of this.targetQueue) {
item.resolve(await this.target[item.method](...item.args));
}
}
}
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
const descriptor = pluginDescriptor;
const target = getTarget();
const hook = getDevtoolsGlobalHook();
const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy;
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
} else {
const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null;
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
list.push({
pluginDescriptor: descriptor,
setupFn,
proxy
});
if (proxy)
setupFn(proxy.proxiedTarget);
}
}
/*!
* pinia v2.1.7
* (c) 2023 Eduardo San Martin Morote
* @license MIT
*/
let activePinia;
const setActivePinia = (pinia) => activePinia = pinia;
const piniaSymbol = Symbol("pinia");
function isPlainObject(o) {
return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
}
var MutationType;
(function(MutationType2) {
MutationType2["direct"] = "direct";
MutationType2["patchObject"] = "patch object";
MutationType2["patchFunction"] = "patch function";
})(MutationType || (MutationType = {}));
const IS_CLIENT = typeof window !== "undefined";
const USE_DEVTOOLS = IS_CLIENT;
const _global = /* @__PURE__ */ (() => typeof window === "object" && window.window === window ? window : typeof self === "object" && self.self === self ? self : typeof global === "object" && global.global === global ? global : typeof globalThis === "object" ? globalThis : { HTMLElement: null })();
function bom(blob, { autoBom = false } = {}) {
if (autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(65279), blob], { type: blob.type });
}
return blob;
}
function download(url, name2, opts) {
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "blob";
xhr.onload = function() {
saveAs(xhr.response, name2, opts);
};
xhr.onerror = function() {
console.error("could not download file");
};
xhr.send();
}
function corsEnabled(url) {
const xhr = new XMLHttpRequest();
xhr.open("HEAD", url, false);
try {
xhr.send();
} catch (e2) {
}
return xhr.status >= 200 && xhr.status <= 299;
}
function click(node) {
try {
node.dispatchEvent(new MouseEvent("click"));
} catch (e2) {
const evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
node.dispatchEvent(evt);
}
}
const _navigator = typeof navigator === "object" ? navigator : { userAgent: "" };
const isMacOSWebView = /* @__PURE__ */ (() => /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent))();
const saveAs = !IS_CLIENT ? () => {
} : (
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : (
// Use msSaveOrOpenBlob as a second approach
"msSaveOrOpenBlob" in _navigator ? msSaveAs : (
// Fallback to using FileReader and a popup
fileSaverSaveAs
)
)
);
function downloadSaveAs(blob, name2 = "download", opts) {
const a = document.createElement("a");
a.download = name2;
a.rel = "noopener";
if (typeof blob === "string") {
a.href = blob;
if (a.origin !== location.origin) {
if (corsEnabled(a.href)) {
download(blob, name2, opts);
} else {
a.target = "_blank";
click(a);
}
} else {
click(a);
}
} else {
a.href = URL.createObjectURL(blob);
setTimeout(function() {
URL.revokeObjectURL(a.href);
}, 4e4);
setTimeout(function() {
click(a);
}, 0);
}
}
function msSaveAs(blob, name2 = "download", opts) {
if (typeof blob === "string") {
if (corsEnabled(blob)) {
download(blob, name2, opts);
} else {
const a = document.createElement("a");
a.href = blob;
a.target = "_blank";
setTimeout(function() {
click(a);
});
}
} else {
navigator.msSaveOrOpenBlob(bom(blob, opts), name2);
}
}
function fileSaverSaveAs(blob, name2, opts, popup) {
popup = popup || open("", "_blank");
if (popup) {
popup.document.title = popup.document.body.innerText = "downloading...";
}
if (typeof blob === "string")
return download(blob, name2, opts);
const force = blob.type === "application/octet-stream";
const isSafari = /constructor/i.test(String(_global.HTMLElement)) || "safari" in _global;
const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") {
const reader = new FileReader();
reader.onloadend = function() {
let url = reader.result;
if (typeof url !== "string") {
popup = null;
throw new Error("Wrong reader.result type");
}
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;");
if (popup) {
popup.location.href = url;
} else {
location.assign(url);
}
popup = null;
};
reader.readAsDataURL(blob);
} else {
const url = URL.createObjectURL(blob);
if (popup)
popup.location.assign(url);
else
location.href = url;
popup = null;
setTimeout(function() {
URL.revokeObjectURL(url);
}, 4e4);
}
}
function toastMessage(message, type) {
const piniaMessage = "🍍 " + message;
if (typeof __VUE_DEVTOOLS_TOAST__ === "function") {
__VUE_DEVTOOLS_TOAST__(piniaMessage, type);
} else if (type === "error") {
console.error(piniaMessage);
} else if (type === "warn") {
console.warn(piniaMessage);
} else {
console.log(piniaMessage);
}
}
function isPinia(o) {
return "_a" in o && "install" in o;
}
function checkClipboardAccess() {
if (!("clipboard" in navigator)) {
toastMessage(`Your browser doesn't support the Clipboard API`, "error");
return true;
}
}
function checkNotFocusedError(error) {
if (error instanceof Error && error.message.toLowerCase().includes("document is not focused")) {
toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', "warn");
return true;
}
return false;
}
async function actionGlobalCopyState(pinia) {
if (checkClipboardAccess())
return;
try {
await navigator.clipboard.writeText(JSON.stringify(pinia.state.value));
toastMessage("Global state copied to clipboard.");
} catch (error) {
if (checkNotFocusedError(error))
return;
toastMessage(`Failed to serialize the state. Check the console for more details.`, "error");
console.error(error);
}
}
async function actionGlobalPasteState(pinia) {
if (checkClipboardAccess())
return;
try {
loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText()));
toastMessage("Global state pasted from clipboard.");
} catch (error) {
if (checkNotFocusedError(error))
return;
toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, "error");
console.error(error);
}
}
async function actionGlobalSaveState(pinia) {
try {
saveAs(new Blob([JSON.stringify(pinia.state.value)], {
type: "text/plain;charset=utf-8"
}), "pinia-state.json");
} catch (error) {
toastMessage(`Failed to export the state as JSON. Check the console for more details.`, "error");
console.error(error);
}
}
let fileInput;
function getFileOpener() {
if (!fileInput) {
fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = ".json";
}
function openFile() {
return new Promise((resolve, reject) => {
fileInput.onchange = async () => {
const files = fileInput.files;
if (!files)
return resolve(null);
const file = files.item(0);
if (!file)
return resolve(null);
return resolve({ text: await file.text(), file });
};
fileInput.oncancel = () => resolve(null);
fileInput.onerror = reject;
fileInput.click();
});
}
return openFile;
}
async function actionGlobalOpenStateFile(pinia) {
try {
const open2 = getFileOpener();
const result = await open2();
if (!result)
return;
const { text, file } = result;
loadStoresState(pinia, JSON.parse(text));
toastMessage(`Global state imported from "${file.name}".`);
} catch (error) {
toastMessage(`Failed to import the state from JSON. Check the console for more details.`, "error");
console.error(error);
}
}
function loadStoresState(pinia, state) {
for (const key in state) {
const storeState = pinia.state.value[key];
if (storeState) {
Object.assign(storeState, state[key]);
} else {
pinia.state.value[key] = state[key];
}
}
}
function formatDisplay(display) {
return {
_custom: {
display
}
};
}
const PINIA_ROOT_LABEL = "🍍 Pinia (root)";
const PINIA_ROOT_ID = "_root";
function formatStoreForInspectorTree(store) {
return isPinia(store) ? {
id: PINIA_ROOT_ID,
label: PINIA_ROOT_LABEL
} : {
id: store.$id,
label: store.$id
};
}
function formatStoreForInspectorState(store) {
if (isPinia(store)) {
const storeNames = Array.from(store._s.keys());
const storeMap = store._s;
const state2 = {
state: storeNames.map((storeId) => ({
editable: true,
key: storeId,
value: store.state.value[storeId]
})),
getters: storeNames.filter((id) => storeMap.get(id)._getters).map((id) => {
const store2 = storeMap.get(id);
return {
editable: false,
key: id,
value: store2._getters.reduce((getters, key) => {
getters[key] = store2[key];
return getters;
}, {})
};
})
};
return state2;
}
const state = {
state: Object.keys(store.$state).map((key) => ({
editable: true,
key,
value: store.$state[key]
}))
};
if (store._getters && store._getters.length) {
state.getters = store._getters.map((getterName) => ({
editable: false,
key: getterName,
value: store[getterName]
}));
}
if (store._customProperties.size) {
state.customProperties = Array.from(store._customProperties).map((key) => ({
editable: true,
key,
value: store[key]
}));
}
return state;
}
function formatEventData(events) {
if (!events)
return {};
if (Array.isArray(events)) {
return events.reduce((data, event) => {
data.keys.push(event.key);
data.operations.push(event.type);
data.oldValue[event.key] = event.oldValue;
data.newValue[event.key] = event.newValue;
return data;
}, {
oldValue: {},
keys: [],
operations: [],
newValue: {}
});
} else {
return {
operation: formatDisplay(events.type),
key: formatDisplay(events.key),
oldValue: events.oldValue,
newValue: events.newValue
};
}
}
function formatMutationType(type) {
switch (type) {
case MutationType.direct:
return "mutation";
case MutationType.patchFunction:
return "$patch";
case MutationType.patchObject:
return "$patch";
default:
return "unknown";
}
}
let isTimelineActive = true;
const componentStateTypes = [];
const MUTATIONS_LAYER_ID = "pinia:mutations";
const INSPECTOR_ID = "pinia";
const { assign: assign$1 } = Object;
const getStoreType = (id) => "🍍 " + id;
function registerPiniaDevtools(app, pinia) {
setupDevtoolsPlugin({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes,
app
}, (api) => {
if (typeof api.now !== "function") {
toastMessage("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
}
api.addTimelineLayer({
id: MUTATIONS_LAYER_ID,
label: `Pinia 🍍`,
color: 15064968
});
api.addInspector({
id: INSPECTOR_ID,
label: "Pinia 🍍",
icon: "storage",
treeFilterPlaceholder: "Search stores",
actions: [
{
icon: "content_copy",
action: () => {
actionGlobalCopyState(pinia);
},
tooltip: "Serialize and copy the state"
},
{
icon: "content_paste",
action: async () => {
await actionGlobalPasteState(pinia);
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
},
tooltip: "Replace the state with the content of your clipboard"
},
{
icon: "save",
action: () => {
actionGlobalSaveState(pinia);
},
tooltip: "Save the state as a JSON file"
},
{
icon: "folder_open",
action: async () => {
await actionGlobalOpenStateFile(pinia);
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
},
tooltip: "Import the state from a JSON file"
}
],
nodeActions: [
{
icon: "restore",
tooltip: 'Reset the state (with "$reset")',
action: (nodeId) => {
const store = pinia._s.get(nodeId);
if (!store) {
toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, "warn");
} else if (typeof store.$reset !== "function") {
toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, "warn");
} else {
store.$reset();
toastMessage(`Store "${nodeId}" reset.`);
}
}
}
]
});
api.on.inspectComponent((payload, ctx) => {
const proxy = payload.componentInstance && payload.componentInstance.proxy;
if (proxy && proxy._pStores) {
const piniaStores = payload.componentInstance.proxy._pStores;
Object.values(piniaStores).forEach((store) => {
payload.instanceData.state.push({
type: getStoreType(store.$id),
key: "state",
editable: true,
value: store._isOptionsAPI ? {
_custom: {
value: vue.toRaw(store.$state),
actions: [
{
icon: "restore",
tooltip: "Reset the state of this store",
action: () => store.$reset()
}
]
}
} : (
// NOTE: workaround to unwrap transferred refs
Object.keys(store.$state).reduce((state, key) => {
state[key] = store.$state[key];
return state;
}, {})
)
});
if (store._getters && store._getters.length) {
payload.instanceData.state.push({
type: getStoreType(store.$id),
key: "getters",
editable: false,
value: store._getters.reduce((getters, key) => {
try {
getters[key] = store[key];
} catch (error) {
getters[key] = error;
}
return getters;
}, {})
});
}
});
}
});
api.on.getInspectorTree((payload) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
let stores = [pinia];
stores = stores.concat(Array.from(pinia._s.values()));
payload.rootNodes = (payload.filter ? stores.filter((store) => "$id" in store ? store.$id.toLowerCase().includes(payload.filter.toLowerCase()) : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) : stores).map(formatStoreForInspectorTree);
}
});
api.on.getInspectorState((payload) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
if (!inspectedStore) {
return;
}
if (inspectedStore) {
payload.state = formatStoreForInspectorState(inspectedStore);
}
}
});
api.on.editInspectorState((payload, ctx) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
if (!inspectedStore) {
return toastMessage(`store "${payload.nodeId}" not found`, "error");
}
const { path } = payload;
if (!isPinia(inspectedStore)) {
if (path.length !== 1 || !inspectedStore._customProperties.has(path[0]) || path[0] in inspectedStore.$state) {
path.unshift("$state");
}
} else {
path.unshift("state");
}
isTimelineActive = false;
payload.set(inspectedStore, path, payload.state.value);
isTimelineActive = true;
}
});
api.on.editComponentState((payload) => {
if (payload.type.startsWith("🍍")) {
const storeId = payload.type.replace(/^🍍\s*/, "");
const store = pinia._s.get(storeId);
if (!store) {
return toastMessage(`store "${storeId}" not found`, "error");
}
const { path } = payload;
if (path[0] !== "state") {
return toastMessage(`Invalid path for store "${storeId}":
${path}
Only state can be modified.`);
}
path[0] = "$state";
isTimelineActive = false;
payload.set(store, path, payload.state.value);
isTimelineActive = true;
}
});
});
}
function addStoreToDevtools(app, store) {
if (!componentStateTypes.includes(getStoreType(store.$id))) {
componentStateTypes.push(getStoreType(store.$id));
}
setupDevtoolsPlugin({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes,
app,
settings: {
logStoreChanges: {
label: "Notify about new/deleted stores",
type: "boolean",
defaultValue: true
}
// useEmojis: {
// label: 'Use emojis in messages ⚡️',
// type: 'boolean',
// defaultValue: true,
// },
}
}, (api) => {
const now2 = typeof api.now === "function" ? api.now.bind(api) : Date.now;
store.$onAction(({ after, onError, name: name2, args }) => {
const groupId = runningActionId++;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🛫 " + name2,
subtitle: "start",
data: {
store: formatDisplay(store.$id),
action: formatDisplay(name2),
args
},
groupId
}
});
after((result) => {
activeAction = void 0;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🛬 " + name2,
subtitle: "end",
data: {
store: formatDisplay(store.$id),
action: formatDisplay(name2),
args,
result
},
groupId
}
});
});
onError((error) => {
activeAction = void 0;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
logType: "error",
title: "💥 " + name2,
subtitle: "end",
data: {
store: formatDisplay(store.$id),
action: formatDisplay(name2),
args,
error
},
groupId
}
});
});
}, true);
store._customProperties.forEach((name2) => {
vue.watch(() => vue.unref(store[name2]), (newValue, oldValue) => {
api.notifyComponentUpdate();
api.sendInspectorState(INSPECTOR_ID);
if (isTimelineActive) {
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "Change",
subtitle: name2,
data: {
newValue,
oldValue
},
groupId: activeAction
}
});
}
}, { deep: true });
});
store.$subscribe(({ events, type }, state) => {
api.notifyComponentUpdate();
api.sendInspectorState(INSPECTOR_ID);
if (!isTimelineActive)
return;
const eventData = {
time: now2(),
title: formatMutationType(type),
data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)),
groupId: activeAction
};
if (type === MutationType.patchFunction) {
eventData.subtitle = "⤵️";
} else if (type === MutationType.patchObject) {
eventData.subtitle = "🧩";
} else if (events && !Array.isArray(events)) {
eventData.subtitle = events.type;
}
if (events) {
eventData.data["rawEvent(s)"] = {
_custom: {
display: "DebuggerEvent",
type: "object",
tooltip: "raw DebuggerEvent[]",
value: events
}
};
}
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: eventData
});
}, { detached: true, flush: "sync" });
const hotUpdate = store._hotUpdate;
store._hotUpdate = vue.markRaw((newStore) => {
hotUpdate(newStore);
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🔥 " + store.$id,
subtitle: "HMR update",
data: {
store: formatDisplay(store.$id),
info: formatDisplay(`HMR update`)
}
}
});
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
});
const { $dispose } = store;
store.$dispose = () => {
$dispose();
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
api.getSettings().logStoreChanges && toastMessage(`Disposed "${store.$id}" store 🗑`);
};
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
api.getSettings().logStoreChanges && toastMessage(`"${store.$id}" store installed 🆕`);
});
}
let runningActionId = 0;
let activeAction;
function patchActionForGrouping(store, actionNames, wrapWithProxy) {
const actions = actionNames.reduce((storeActions, actionName) => {
storeActions[actionName] = vue.toRaw(store)[actionName];
return storeActions;
}, {});
for (const actionName in actions) {
store[actionName] = function() {
const _actionId = runningActionId;
const trackedStore = wrapWithProxy ? new Proxy(store, {
get(...args) {
activeAction = _actionId;
return Reflect.get(...args);
},
set(...args) {
activeAction = _actionId;
return Reflect.set(...args);
}
}) : store;
activeAction = _actionId;
const retValue = actions[actionName].apply(trackedStore, arguments);
activeAction = void 0;
return retValue;
};
}
}
function devtoolsPlugin({ app, store, options }) {
if (store.$id.startsWith("__hot:")) {
return;
}
store._isOptionsAPI = !!options.state;
patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI);
const originalHotUpdate = store._hotUpdate;
vue.toRaw(store)._hotUpdate = function(newStore) {
originalHotUpdate.apply(this, arguments);
patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI);
};
addStoreToDevtools(
app,
// FIXME: is there a way to allow the assignment from Store