update
1.更换变量,修改外链打包后不生效问题
This commit is contained in:
+1
-1
@@ -32,4 +32,4 @@ VITE_EMERGENCY_SCREEN=http://emer.dev.yg.dt.io/
|
||||
VITE_PLATFORM = 'YT'
|
||||
|
||||
# 跳转外部链接
|
||||
VITE_OUT_URL=https://console-jkglpt.iosp.ydpt.tech/hb/healthadmin/index.html?param=
|
||||
VITE_GLOB_OUT_URL=https://console-jkglpt.iosp.ydpt.tech/hb/healthadmin/index.html?param=
|
||||
|
||||
+1
-1
@@ -41,4 +41,4 @@ VITE_LEGACY = false
|
||||
VITE_PLATFORM = 'YT'
|
||||
|
||||
# 跳转外部链接
|
||||
VITE_OUT_URL=https://console-jkglpt.iosp.ydpt.tech/hb/healthadmin/index.html?param=
|
||||
VITE_GLOB_OUT_URL=https://console-jkglpt.iosp.ydpt.tech/hb/healthadmin/index.html?param=
|
||||
|
||||
@@ -39,4 +39,4 @@ VITE_LEGACY = false
|
||||
VITE_PLATFORM = 'YT'
|
||||
|
||||
# 跳转外部链接
|
||||
VITE_OUT_URL=https://gstest.superwx.cn/healthapiadmin/index.html?param=
|
||||
VITE_GLOB_OUT_URL=https://gstest.superwx.cn/healthapiadmin/index.html?param=
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ ENV LANG en_US.UTF-8
|
||||
|
||||
ENV VITE_GLOB_API_URL https://xj-api.mcrm.vip:8888
|
||||
ENV VITE_GLOB_DOMAIN_URL https://xj-api.mcrm.vip:8888
|
||||
ENV VITE_OUT_URL https://gstest.superwx.cn/healthapiadmin/index.html?param=
|
||||
ENV VITE_GLOB_OUT_URL https://gstest.superwx.cn/healthapiadmin/index.html?param=
|
||||
|
||||
RUN echo "server { \
|
||||
#解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 \
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ window['$CONFIG_VAR'] = {
|
||||
"VITE_GLOB_DOMAIN_URL": "${VITE_GLOB_DOMAIN_URL:-http://default-domain.com}",
|
||||
"VITE_GLOB_ST_DOMAIN_URL": "${VITE_GLOB_ST_DOMAIN_URL:-http://default-domain.com}",
|
||||
"VITE_GLOB_API_URL_PREFIX": "${VITE_GLOB_API_URL_PREFIX:-}",
|
||||
"VITE_OUT_URL": "${VITE_OUT_URL:-}"
|
||||
"VITE_GLOB_OUT_URL": "${VITE_GLOB_OUT_URL:-}"
|
||||
};
|
||||
|
||||
// 冻结对象(可选,模拟生产行为)
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
// 数据库管理类
|
||||
class ConversationDB {
|
||||
constructor() {
|
||||
this.dbName = 'TIMConversationDB';
|
||||
this.version = 1;
|
||||
this.db = null;
|
||||
}
|
||||
|
||||
// 打开数据库
|
||||
async openDB() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = indexedDB.open(this.dbName, this.version);
|
||||
|
||||
request.onerror = () => reject(request.error);
|
||||
request.onsuccess = () => {
|
||||
this.db = request.result;
|
||||
resolve(this.db);
|
||||
};
|
||||
|
||||
request.onupgradeneeded = (event) => {
|
||||
const db = event.target.result;
|
||||
|
||||
// 创建会话存储空间
|
||||
if (!db.objectStoreNames.contains('conversations')) {
|
||||
const store = db.createObjectStore('conversations', {
|
||||
keyPath: 'conversationID',
|
||||
});
|
||||
|
||||
// 创建索引
|
||||
store.createIndex('lastMessageTime', 'lastMessageTime', { unique: false });
|
||||
store.createIndex('isTop', 'isTop', { unique: false });
|
||||
store.createIndex('status', 'status', { unique: false });
|
||||
store.createIndex('type', 'type', { unique: false });
|
||||
}
|
||||
|
||||
// 创建消息存储空间(可选)
|
||||
if (!db.objectStoreNames.contains('messages')) {
|
||||
const messageStore = db.createObjectStore('messages', {
|
||||
keyPath: 'ID',
|
||||
});
|
||||
messageStore.createIndex('conversationID', 'conversationID', { unique: false });
|
||||
messageStore.createIndex('time', 'time', { unique: false });
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// 保存或更新会话
|
||||
async saveConversation(conversation) {
|
||||
if (!this.db) await this.openDB();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const transaction = this.db.transaction(['conversations'], 'readwrite');
|
||||
const store = transaction.objectStore('conversations');
|
||||
|
||||
// 添加更新时间
|
||||
conversation.updatedTime = Date.now();
|
||||
|
||||
const request = store.put(conversation);
|
||||
|
||||
request.onerror = () => reject(request.error);
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
});
|
||||
}
|
||||
|
||||
// 批量保存会话
|
||||
async saveConversations(conversations) {
|
||||
if (!this.db) await this.openDB();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const transaction = this.db.transaction(['conversations'], 'readwrite');
|
||||
const store = transaction.objectStore('conversations');
|
||||
|
||||
conversations.forEach((conversation) => {
|
||||
conversation.updatedTime = Date.now();
|
||||
store.put(conversation);
|
||||
});
|
||||
|
||||
transaction.oncomplete = () => resolve();
|
||||
transaction.onerror = () => reject(transaction.error);
|
||||
});
|
||||
}
|
||||
|
||||
// 获取会话列表(支持排序和分页)
|
||||
async getConversationList(options = {}) {
|
||||
if (!this.db) await this.openDB();
|
||||
|
||||
const {
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
status = 0, // 0:活跃 1:已结束
|
||||
sortBy = 'lastMessageTime',
|
||||
sortOrder = 'desc',
|
||||
} = options;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const transaction = this.db.transaction(['conversations'], 'readonly');
|
||||
const store = transaction.objectStore('conversations');
|
||||
const index = store.index(sortBy);
|
||||
|
||||
let conversations = [];
|
||||
let count = 0;
|
||||
let cursor = index.openCursor(null, sortOrder === 'desc' ? 'prev' : 'next');
|
||||
|
||||
cursor.onsuccess = (event) => {
|
||||
const cursor = event.target.result;
|
||||
if (cursor) {
|
||||
const conversation = cursor.value;
|
||||
|
||||
// 过滤条件
|
||||
if (conversation.status === status) {
|
||||
count++;
|
||||
|
||||
// 分页计算
|
||||
const startIndex = (page - 1) * pageSize;
|
||||
const endIndex = page * pageSize;
|
||||
|
||||
if (count > startIndex && count <= endIndex) {
|
||||
conversations.push(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
if (count < endIndex) {
|
||||
cursor.continue();
|
||||
} else {
|
||||
resolve({
|
||||
conversations,
|
||||
total: count,
|
||||
page,
|
||||
pageSize,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
resolve({
|
||||
conversations,
|
||||
total: count,
|
||||
page,
|
||||
pageSize,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
cursor.onerror = () => reject(cursor.error);
|
||||
});
|
||||
}
|
||||
|
||||
// 根据会话ID获取会话
|
||||
async getConversation(conversationID) {
|
||||
if (!this.db) await this.openDB();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const transaction = this.db.transaction(['conversations'], 'readonly');
|
||||
const store = transaction.objectStore('conversations');
|
||||
const request = store.get(conversationID);
|
||||
|
||||
request.onerror = () => reject(request.error);
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
});
|
||||
}
|
||||
|
||||
// 删除会话
|
||||
async deleteConversation(conversationID) {
|
||||
if (!this.db) await this.openDB();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const transaction = this.db.transaction(['conversations'], 'readwrite');
|
||||
const store = transaction.objectStore('conversations');
|
||||
const request = store.delete(conversationID);
|
||||
|
||||
request.onerror = () => reject(request.error);
|
||||
request.onsuccess = () => resolve();
|
||||
});
|
||||
}
|
||||
|
||||
// 标记会话为已结束
|
||||
async markConversationEnded(conversationID, reason = '') {
|
||||
const conversation = await this.getConversation(conversationID);
|
||||
if (conversation) {
|
||||
conversation.status = 1;
|
||||
conversation.endReason = reason;
|
||||
conversation.endTime = Date.now();
|
||||
await this.saveConversation(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新会话最后消息
|
||||
async updateLastMessage(conversationID, message) {
|
||||
const conversation = await this.getConversation(conversationID);
|
||||
if (conversation) {
|
||||
conversation.lastMessage = this.getMessageSummary(message);
|
||||
conversation.lastMessageType = message.type;
|
||||
conversation.lastMessageTime = message.time || Date.now();
|
||||
|
||||
// 如果会话已结束但收到新消息,重新激活
|
||||
if (conversation.status === 1) {
|
||||
conversation.status = 0;
|
||||
conversation.endReason = '';
|
||||
conversation.endTime = 0;
|
||||
}
|
||||
|
||||
await this.saveConversation(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取消息摘要
|
||||
getMessageSummary(message) {
|
||||
switch (message.type) {
|
||||
case 'TIMTextElem':
|
||||
return message.payload.text;
|
||||
case 'TIMImageElem':
|
||||
return '[图片]';
|
||||
case 'TIMSoundElem':
|
||||
return '[语音]';
|
||||
case 'TIMCustomElem':
|
||||
return this.parseCustomMessage(message);
|
||||
default:
|
||||
return '[未知消息]';
|
||||
}
|
||||
}
|
||||
|
||||
// 解析自定义消息
|
||||
parseCustomMessage(message) {
|
||||
try {
|
||||
const data = JSON.parse(message.payload.data);
|
||||
if (data.type === 'END_CONVERSATION') {
|
||||
return `[会话结束: ${data.reason}]`;
|
||||
}
|
||||
return '[自定义消息]';
|
||||
} catch {
|
||||
return '[自定义消息]';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 单例模式
|
||||
export const conversationDB = new ConversationDB();
|
||||
@@ -131,6 +131,8 @@
|
||||
if (item.title === '健康银行') {
|
||||
open();
|
||||
const url = viteOutUrl;
|
||||
console.log(url);
|
||||
console.log(useGlobSetting());
|
||||
await defHttp
|
||||
.get({
|
||||
url: '/health-system/api/sys/encryptInfo',
|
||||
|
||||
@@ -17,7 +17,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
|
||||
VITE_GLOB_ONLINE_VIEW_URL,
|
||||
VITE_GLOB_ST_DOMAIN_URL,
|
||||
VITE_PLATFORM,
|
||||
VITE_OUT_URL,
|
||||
VITE_GLOB_OUT_URL,
|
||||
} = getAppEnvConfig();
|
||||
|
||||
if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) {
|
||||
@@ -41,7 +41,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
|
||||
viewUrl: VITE_GLOB_ONLINE_VIEW_URL,
|
||||
stDomainUrl: VITE_GLOB_ST_DOMAIN_URL,
|
||||
vitePlatform: VITE_PLATFORM,
|
||||
viteOutUrl: VITE_OUT_URL,
|
||||
viteOutUrl: VITE_GLOB_OUT_URL,
|
||||
};
|
||||
window._CONFIG['domianURL'] = VITE_GLOB_DOMAIN_URL;
|
||||
return glob as Readonly<GlobConfig>;
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ export function getAppEnvConfig() {
|
||||
VITE_GLOB_ONLINE_VIEW_URL,
|
||||
VITE_GLOB_ST_DOMAIN_URL,
|
||||
VITE_PLATFORM,
|
||||
VITE_OUT_URL,
|
||||
VITE_GLOB_OUT_URL,
|
||||
} = ENV;
|
||||
if (!/^[a-zA-Z\_]*$/.test(VITE_GLOB_APP_SHORT_NAME)) {
|
||||
// warn(
|
||||
@@ -56,7 +56,7 @@ export function getAppEnvConfig() {
|
||||
VITE_GLOB_ONLINE_VIEW_URL,
|
||||
VITE_GLOB_ST_DOMAIN_URL,
|
||||
VITE_PLATFORM,
|
||||
VITE_OUT_URL,
|
||||
VITE_GLOB_OUT_URL,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -181,5 +181,5 @@ export interface GlobEnvConfig {
|
||||
VITE_GLOB_ONLINE_VIEW_URL?: string;
|
||||
VITE_GLOB_ST_DOMAIN_URL?: string;
|
||||
VITE_PLATFORM?: string;
|
||||
VITE_OUT_URL?: string;
|
||||
VITE_GLOB_OUT_URL?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user