From b97219565e09012adfaf261eaa76ea92144f39b5 Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Wed, 23 Apr 2025 13:39:25 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E9=A1=B5=E9=9D=A2=E6=98=AF=E5=90=A6=E5=8F=AF?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E6=96=B9=E6=B3=95=EF=BC=8C=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=99=BD=E5=B1=8F=E5=8F=8A=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.js b/src/main.js index c434bc6..650fc8b 100644 --- a/src/main.js +++ b/src/main.js @@ -99,6 +99,16 @@ export function createApp() { location.reload(true) } + //检查聊天页面是否可用 + window.checkChatWebviewAvailable = () => { + let OAWebView = plus.webview.all() + OAWebView.forEach((webview, index) => { + if (webview.id === 'webviewId1') { + webview.evalJS(`doneCheckChatWebviewAvailable()`) + } + }) + } + window.message = ['success', 'error', 'warning'].reduce((acc, type) => { acc[type] = (message) => { if (typeof message === 'string') { From 11bb78cc5e5c9940e9d4f8adc32722e9bf7afe97 Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Wed, 23 Apr 2025 14:24:10 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=88=9B=E5=BB=BAchat?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=EF=BC=8C=E5=88=9B=E5=BB=BA=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E8=AE=B0=E5=BD=95=E6=95=B0=E6=8D=AE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/dialogueList.js | 13 ++++ src/store/modules/sqlite.js | 100 ++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 src/store/modules/sqlite.js diff --git a/src/store/modules/dialogueList.js b/src/store/modules/dialogueList.js index ad18299..eb33aa0 100644 --- a/src/store/modules/dialogueList.js +++ b/src/store/modules/dialogueList.js @@ -5,8 +5,21 @@ import lodash from 'lodash' import { ref } from 'vue' import { createGlobalState, useStorage } from '@vueuse/core' import { uniStorage } from '@/utils/uniStorage.js' +import { initDatabase } from './sqlite' export const useDialogueListStore = createGlobalState(() => { + const testDatabase = async () => { + // 初始化数据库 + initDatabase() + // 查询所有数据 + const result = await plus.sqlite.selectSql({ + name: 'chat', + sql: 'SELECT * FROM talk_records' + }) + console.warn('数据库内容:', result) + } + testDatabase() + const dialogueList = useStorage('dialogueList', [], uniStorage) // const dialogueList = ref([]) const zpagingRef = ref() diff --git a/src/store/modules/sqlite.js b/src/store/modules/sqlite.js new file mode 100644 index 0000000..2747ff9 --- /dev/null +++ b/src/store/modules/sqlite.js @@ -0,0 +1,100 @@ +// 初始化数据库 +export const initDatabase = async () => { + try { + const isOpen = await plus.sqlite.isOpenDatabase({ + name: 'chat', + path: '_doc/chat.db' + }) + + if (!isOpen) { + await plus.sqlite.openDatabase({ + name: 'chat', + path: '_doc/chat.db' + }) + + await plus.sqlite.executeSql({ + name: 'chat', + sql: ` + CREATE TABLE IF NOT EXISTS talk_records ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + msg_id TEXT NOT NULL, + sequence INTEGER NOT NULL, + talk_type INTEGER NOT NULL DEFAULT 1, + msg_type INTEGER NOT NULL DEFAULT 1, + user_id INTEGER NOT NULL DEFAULT 0, + receiver_id INTEGER NOT NULL DEFAULT 0, + is_revoke INTEGER NOT NULL DEFAULT 0, + is_mark INTEGER NOT NULL DEFAULT 0, + quote_id TEXT NOT NULL, + extra TEXT NOT NULL, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + biz_date TEXT + ); + + CREATE UNIQUE INDEX IF NOT EXISTS uk_msgid ON talk_records(msg_id); + CREATE UNIQUE INDEX IF NOT EXISTS idx_user_id_receiver_id_sequence ON talk_records(user_id, receiver_id, sequence); + CREATE INDEX IF NOT EXISTS idx_receiver_id ON talk_records(receiver_id); + CREATE INDEX IF NOT EXISTS idx_created_at ON talk_records(created_at); + CREATE INDEX IF NOT EXISTS idx_updated_at ON talk_records(updated_at); + CREATE INDEX IF NOT EXISTS idx_biz_date ON talk_records(biz_date); + ` + }) + } + + return true + } catch (error) { + console.error('数据库初始化失败:', error) + return false + } +} + +// 添加消息记录 +export const sqlAddRecord = async (message) => { + try { + await plus.sqlite.executeSql({ + name: 'chat', + sql: `INSERT INTO talk_records ( + msg_id, sequence, talk_type, msg_type, user_id, receiver_id, + is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + args: [ + message.msg_id, + message.sequence, + message.talk_type, + message.msg_type, + message.user_id, + message.receiver_id, + message.is_revoke || 0, + message.is_mark || 0, + message.quote_id || '', + JSON.stringify(message.extra), + message.created_at, + message.updated_at, + message.biz_date + ] + }) + return true + } catch (error) { + console.error('添加消息失败:', error) + return false + } +} + +// 查询消息记录 +export const sqlGetRecord = async (receiverId, page = 1, pageSize = 20) => { + try { + const result = await plus.sqlite.selectSql({ + name: 'chat', + sql: `SELECT * FROM talk_records + WHERE receiver_id = ? + ORDER BY sequence DESC + LIMIT ? OFFSET ?`, + args: [receiverId, pageSize, (page - 1) * pageSize] + }) + return result + } catch (error) { + console.error('查询消息失败:', error) + return [] + } +} \ No newline at end of file From d137f394713a3c4680cd4944bdf746e6156d2549 Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Thu, 24 Apr 2025 11:18:39 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93sql=E5=BB=BA=E5=BA=93=E5=BB=BA?= =?UTF-8?q?=E8=A1=A8=E6=8F=92=E5=85=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/dialogueList.js | 97 +++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 10 deletions(-) diff --git a/src/store/modules/dialogueList.js b/src/store/modules/dialogueList.js index eb33aa0..b2ed2ca 100644 --- a/src/store/modules/dialogueList.js +++ b/src/store/modules/dialogueList.js @@ -10,13 +10,90 @@ import { initDatabase } from './sqlite' export const useDialogueListStore = createGlobalState(() => { const testDatabase = async () => { // 初始化数据库 - initDatabase() - // 查询所有数据 - const result = await plus.sqlite.selectSql({ - name: 'chat', - sql: 'SELECT * FROM talk_records' + let chatDatabase = { + eventType: 'openDatabase', + eventParams: { + name: 'chat', + path: '_doc/chat.db', + }, + } + let chatDBexecuteSql = { + eventType: 'executeSql', + eventParams: { + name: 'chat', + // sql: `CREATE TABLE IF NOT EXISTS talk_records ( + // id INTEGER PRIMARY KEY AUTOINCREMENT, + // msg_id TEXT NOT NULL, + // sequence INTEGER NOT NULL, + // talk_type INTEGER NOT NULL DEFAULT 1, + // msg_type INTEGER NOT NULL DEFAULT 1, + // user_id INTEGER NOT NULL DEFAULT 0, + // receiver_id INTEGER NOT NULL DEFAULT 0, + // is_revoke INTEGER NOT NULL DEFAULT 0, + // is_mark INTEGER NOT NULL DEFAULT 0, + // quote_id TEXT NOT NULL, + // extra TEXT NOT NULL, + // created_at TEXT NOT NULL, + // updated_at TEXT NOT NULL, + // biz_date TEXT + // )`, + sql: `INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ('77b715fb30f54f739a255a915ef72445', 166, 2, 1, 1774, 888890, 0, 0, '', '{"content": "我试试传送文件和图片是不是一个接口"}', '2025-03-06T15:57:07.000Z', '2025-03-06T15:57:07.000Z', '20250306')`, + }, + } + + let chatDBexecuteSql2 = { + eventType: 'executeSql', + eventParams: { + name: 'chat', + sql: `INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ('77b715fb30f54f739a255a915ef72445', 166, 2, 1, 1774, 888890, 0, 0, '', '{"content": "我试试传送文件和图片是不是一个接口"}', '2025-03-06T15:57:07.000Z', '2025-03-06T15:57:07.000Z', '20250306')`, + }, + } + let chatDBSelectSql = { + eventType: 'selectSql', + eventParams: { + name: 'chat', + sql: `SELECT * FROM talk_records ORDER BY sequence DESC LIMIT 20`, + }, + } + let chatDBSelectSql2 = { + eventType: 'selectSql', + eventParams: { + name: 'chat', + sql: `SELECT name FROM sqlite_master WHERE type='table' AND name='talk_records'`, + }, + } + document.addEventListener('plusready', () => { + let OAWebView = plus.webview.all() + OAWebView.forEach((webview, index) => { + if (webview.id === 'webviewId1') { + webview.evalJS( + `operateSQLite('${encodeURIComponent( + JSON.stringify(chatDatabase), + )}')`, + ) + webview.evalJS( + `operateSQLite('${encodeURIComponent( + JSON.stringify(chatDBexecuteSql), + )}')`, + ) + // webview.evalJS( + // `operateSQLite('${encodeURIComponent( + // JSON.stringify(chatDBexecuteSql2), + // )}')`, + // ) + webview.evalJS( + `operateSQLite('${encodeURIComponent( + JSON.stringify(chatDBSelectSql), + )}')`, + ) + webview.evalJS( + `operateSQLite('${encodeURIComponent( + JSON.stringify(chatDBSelectSql2), + )}')`, + ) + } + }) }) - console.warn('数据库内容:', result) } testDatabase() @@ -45,7 +122,7 @@ export const useDialogueListStore = createGlobalState(() => { talk: { username: dialogue.talk.username, talk_type: dialogue.talk.talk_type, - receiver_id: dialogue.talk.receiver_id + receiver_id: dialogue.talk.receiver_id, }, online: dialogue.online, records: dialogue.records || [], @@ -56,7 +133,7 @@ export const useDialogueListStore = createGlobalState(() => { isDismiss: dialogue.isDismiss, isQuit: dialogue.isQuit, unreadNum: dialogue.unreadNum, - members: dialogue.members.map(member => ({ + members: dialogue.members.map((member) => ({ id: member.id, nickname: member.nickname, avatar: member.avatar, @@ -68,9 +145,9 @@ export const useDialogueListStore = createGlobalState(() => { key: member.key, erp_user_id: member.erp_user_id, is_mute: member.is_mute, - is_mine: member.is_mine + is_mine: member.is_mine, })), - forwardType: dialogue.forwardType + forwardType: dialogue.forwardType, } dialogueList.value.push(newDialogue) } else { From d5df575aac019b590235e0ba69b7d1b0968478c7 Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Fri, 25 Apr 2025 11:20:41 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9B=B8=E5=85=B3sql?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/dialogueList.js | 56 ++++++++++++++++++------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/store/modules/dialogueList.js b/src/store/modules/dialogueList.js index b2ed2ca..b6e1c87 100644 --- a/src/store/modules/dialogueList.js +++ b/src/store/modules/dialogueList.js @@ -21,31 +21,35 @@ export const useDialogueListStore = createGlobalState(() => { eventType: 'executeSql', eventParams: { name: 'chat', - // sql: `CREATE TABLE IF NOT EXISTS talk_records ( - // id INTEGER PRIMARY KEY AUTOINCREMENT, - // msg_id TEXT NOT NULL, - // sequence INTEGER NOT NULL, - // talk_type INTEGER NOT NULL DEFAULT 1, - // msg_type INTEGER NOT NULL DEFAULT 1, - // user_id INTEGER NOT NULL DEFAULT 0, - // receiver_id INTEGER NOT NULL DEFAULT 0, - // is_revoke INTEGER NOT NULL DEFAULT 0, - // is_mark INTEGER NOT NULL DEFAULT 0, - // quote_id TEXT NOT NULL, - // extra TEXT NOT NULL, - // created_at TEXT NOT NULL, - // updated_at TEXT NOT NULL, - // biz_date TEXT - // )`, - sql: `INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ('77b715fb30f54f739a255a915ef72445', 166, 2, 1, 1774, 888890, 0, 0, '', '{"content": "我试试传送文件和图片是不是一个接口"}', '2025-03-06T15:57:07.000Z', '2025-03-06T15:57:07.000Z', '20250306')`, + sql: `CREATE TABLE IF NOT EXISTS talk_records ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + msg_id TEXT NOT NULL, + sequence INTEGER NOT NULL, + talk_type INTEGER NOT NULL DEFAULT 1, + msg_type INTEGER NOT NULL DEFAULT 1, + user_id INTEGER NOT NULL DEFAULT 0, + receiver_id INTEGER NOT NULL DEFAULT 0, + is_revoke INTEGER NOT NULL DEFAULT 0, + is_mark INTEGER NOT NULL DEFAULT 0, + quote_id TEXT NOT NULL, + extra TEXT NOT NULL, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + biz_date TEXT + )`, }, } + const content = { + content: "我试试传送文件和图片是不是一个接口" + }; + const extra = JSON.stringify(content); + let chatDBexecuteSql2 = { eventType: 'executeSql', eventParams: { name: 'chat', - sql: `INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ('77b715fb30f54f739a255a915ef72445', 166, 2, 1, 1774, 888890, 0, 0, '', '{"content": "我试试传送文件和图片是不是一个接口"}', '2025-03-06T15:57:07.000Z', '2025-03-06T15:57:07.000Z', '20250306')`, + sql: `INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ('77b715fb30f54f739a255a915ef72445', 166, 2, 1, 1774, 888890, 0, 0, '', '${extra}', '2025-03-06T15:57:07.000Z', '2025-03-06T15:57:07.000Z', '20250306')`, }, } let chatDBSelectSql = { @@ -76,16 +80,20 @@ export const useDialogueListStore = createGlobalState(() => { JSON.stringify(chatDBexecuteSql), )}')`, ) - // webview.evalJS( - // `operateSQLite('${encodeURIComponent( - // JSON.stringify(chatDBexecuteSql2), - // )}')`, - // ) + console.error(JSON.stringify(chatDBexecuteSql2), 'chatDBexecuteSql2') + console.error(encodeURIComponent( + JSON.stringify(chatDBexecuteSql2), + ), 'chatDBexecuteSql2') webview.evalJS( `operateSQLite('${encodeURIComponent( - JSON.stringify(chatDBSelectSql), + JSON.stringify(chatDBexecuteSql2), )}')`, ) + // webview.evalJS( + // `operateSQLite('${encodeURIComponent( + // JSON.stringify(chatDBSelectSql), + // )}')`, + // ) webview.evalJS( `operateSQLite('${encodeURIComponent( JSON.stringify(chatDBSelectSql2), From 0a15ae5463c575296d7661defee0401efef1dd30 Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Fri, 25 Apr 2025 13:18:47 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9sql=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E4=B8=80=E6=9D=A1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/dialogueList.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/store/modules/dialogueList.js b/src/store/modules/dialogueList.js index b6e1c87..d83b4af 100644 --- a/src/store/modules/dialogueList.js +++ b/src/store/modules/dialogueList.js @@ -49,7 +49,7 @@ export const useDialogueListStore = createGlobalState(() => { eventType: 'executeSql', eventParams: { name: 'chat', - sql: `INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ('77b715fb30f54f739a255a915ef72445', 166, 2, 1, 1774, 888890, 0, 0, '', '${extra}', '2025-03-06T15:57:07.000Z', '2025-03-06T15:57:07.000Z', '20250306')`, + sql: 'INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ("'+'77b715fb30f54f739a255a915ef72445'+'", 166, 2, 1, 1774, 888890, 0, 0, "'+''+'", "'+'extra'+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'20250306'+'")', }, } let chatDBSelectSql = { @@ -63,7 +63,7 @@ export const useDialogueListStore = createGlobalState(() => { eventType: 'selectSql', eventParams: { name: 'chat', - sql: `SELECT name FROM sqlite_master WHERE type='table' AND name='talk_records'`, + sql: 'SELECT name FROM sqlite_master WHERE type="'+'table'+'" AND name="'+'talk_records'+'"' }, } document.addEventListener('plusready', () => { @@ -80,20 +80,16 @@ export const useDialogueListStore = createGlobalState(() => { JSON.stringify(chatDBexecuteSql), )}')`, ) - console.error(JSON.stringify(chatDBexecuteSql2), 'chatDBexecuteSql2') - console.error(encodeURIComponent( - JSON.stringify(chatDBexecuteSql2), - ), 'chatDBexecuteSql2') - webview.evalJS( - `operateSQLite('${encodeURIComponent( - JSON.stringify(chatDBexecuteSql2), - )}')`, - ) // webview.evalJS( // `operateSQLite('${encodeURIComponent( - // JSON.stringify(chatDBSelectSql), + // JSON.stringify(chatDBexecuteSql2), // )}')`, // ) + webview.evalJS( + `operateSQLite('${encodeURIComponent( + JSON.stringify(chatDBSelectSql), + )}')`, + ) webview.evalJS( `operateSQLite('${encodeURIComponent( JSON.stringify(chatDBSelectSql2), From f19660c03ceceb50119269549d41b4c27d88f053 Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Mon, 28 Apr 2025 13:19:21 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E7=9A=84sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/dialogueList.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/store/modules/dialogueList.js b/src/store/modules/dialogueList.js index d83b4af..9b51e34 100644 --- a/src/store/modules/dialogueList.js +++ b/src/store/modules/dialogueList.js @@ -41,7 +41,11 @@ export const useDialogueListStore = createGlobalState(() => { } const content = { - content: "我试试传送文件和图片是不是一个接口" + content: "我试试传送文件和图片是不是一个接口", + name: "测试excel1.xlsx", + path: "https://cdn-test.szjixun.cn/fonchain-chat/chat/file/multipart/20250307/727a2371-ffc4-46da-b953-a7d449ff82ff-测试excel1.xlsx", + size: 9909, + drive: 3 }; const extra = JSON.stringify(content); @@ -49,7 +53,7 @@ export const useDialogueListStore = createGlobalState(() => { eventType: 'executeSql', eventParams: { name: 'chat', - sql: 'INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ("'+'77b715fb30f54f739a255a915ef72445'+'", 166, 2, 1, 1774, 888890, 0, 0, "'+''+'", "'+'extra'+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'20250306'+'")', + sql: 'INSERT INTO talk_records (msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_revoke, is_mark, quote_id, extra, created_at, updated_at, biz_date) VALUES ("'+'77b715fb30f54f739a255a915ef72445'+'", 166, 2, 1, 1774, 888890, 0, 0, "'+''+'", "'+extra+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'2025-03-06T15:57:07.000Z'+'", "'+'20250306'+'")', }, } let chatDBSelectSql = { @@ -59,11 +63,11 @@ export const useDialogueListStore = createGlobalState(() => { sql: `SELECT * FROM talk_records ORDER BY sequence DESC LIMIT 20`, }, } - let chatDBSelectSql2 = { - eventType: 'selectSql', + let chatDBIsOpenDatabase = { + eventType: 'isOpenDatabase', eventParams: { name: 'chat', - sql: 'SELECT name FROM sqlite_master WHERE type="'+'table'+'" AND name="'+'talk_records'+'"' + path: '_doc/chat.db', }, } document.addEventListener('plusready', () => { @@ -80,11 +84,11 @@ export const useDialogueListStore = createGlobalState(() => { JSON.stringify(chatDBexecuteSql), )}')`, ) - // webview.evalJS( - // `operateSQLite('${encodeURIComponent( - // JSON.stringify(chatDBexecuteSql2), - // )}')`, - // ) + webview.evalJS( + `operateSQLite('${encodeURIComponent( + JSON.stringify(chatDBexecuteSql2), + )}')`, + ) webview.evalJS( `operateSQLite('${encodeURIComponent( JSON.stringify(chatDBSelectSql), @@ -92,7 +96,7 @@ export const useDialogueListStore = createGlobalState(() => { ) webview.evalJS( `operateSQLite('${encodeURIComponent( - JSON.stringify(chatDBSelectSql2), + JSON.stringify(chatDBIsOpenDatabase), )}')`, ) } From 033cf16ae7b5b493a0f6600a0db218c1157c8d1c Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Mon, 28 Apr 2025 19:13:16 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=8E=9F=E7=94=9F=E5=AE=89=E5=8D=93=E8=A7=86=E9=A2=91=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E6=8F=92=E4=BB=B6=E5=B9=B6=E8=8E=B7=E5=8F=96=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E5=9C=B0=E5=9D=80=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 11 +++++++++++ src/pages/dialog/components/filePanel.vue | 12 ++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 650fc8b..8372b00 100644 --- a/src/main.js +++ b/src/main.js @@ -109,6 +109,17 @@ export function createApp() { }) } + //获取从base传来的多选视频列表 + window.getBaseMulVideo = (videoList) => { + const videos = JSON.parse(decodeURIComponent(videoList)) + console.error('=====videos', videos) + if(videos.length > 0){ + const videoUri = videos[0] + console.error('=====videoUri', videoUri) + + } + } + window.message = ['success', 'error', 'warning'].reduce((acc, type) => { acc[type] = (message) => { if (typeof message === 'string') { diff --git a/src/pages/dialog/components/filePanel.vue b/src/pages/dialog/components/filePanel.vue index faab8ed..b1130df 100644 --- a/src/pages/dialog/components/filePanel.vue +++ b/src/pages/dialog/components/filePanel.vue @@ -162,6 +162,12 @@ const photoActionsSelect = (index) => { ) } } else { + // let OAWebView = plus.webview.all() + // OAWebView.forEach((webview, index) => { + // if (webview.id === 'webviewId1') { + // webview.evalJS(`getPlusVideoPicker()`) + // } + // }) uni.chooseVideo({ sourceType: ['album'], compressed: true, @@ -317,7 +323,9 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => { virtualList.value.unshift(newItem) try { - const result = await uploadImg(form, (e) => onProgressFn(e, randomId)) + const result = await uploadImg(form, (e) => + onProgressFn(e, randomId), + ) console.log('视频上传完成,结果:', result) if (result.status === 0) { @@ -369,7 +377,7 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => { uploadsStore.updateUploadStatus(false) message.error('获取视频信息失败') resolve('') - } + }, }) } })