Skip to content

Commit

Permalink
#114 八月累计更新 - 1
Browse files Browse the repository at this point in the history
注意:此版本开始将不再兼容 Napcat 1.0 版本,将会出现好友列表无法正常加载的问题;请酌情更新。

:sparkles: 后端连接支持,现在 electron 客户端将使用后端来连接
:sparkles: napcat 2.0 支持,支持多分离式分组获取方式;支持分组排序信息
:sparkles: 支持 Lagrange LagrangeDev/Lagrange.Core@7f67ae9 好友分组
:sparkles: 脚本编辑器支持暗黑模式
:sparkles: 脚本功能新增:userFlush 触发
:sparkles: 现在 Bot 配置文件可选,便于连接不支持的 Bot
:bug: 修正 jsonpath 解析器无法拉取列表的问题
:bug: 修正一个已失效的字段导致的解析问题
:bug: 消息类型面板 i18n 异常
:heavy_plus_sign: 新增依赖 log4js
:lipstick: 脚本列表样式修改
:poop: 去除了独立回复消息字段支持的旧代码
:page_facing_up: direnv、asdf 配置文件补充,移除 nvm 配置文件
:green_heart: [build-electron]
  • Loading branch information
Stapxs authored Aug 21, 2024
2 parents 436e34a + 7796eab commit dac4a65
Show file tree
Hide file tree
Showing 21 changed files with 485 additions and 196 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export PYTHON_PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/python
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.18.2
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stapxs-qq-lite",
"version": "2.8.0",
"version": "2.8.2",
"private": false,
"author": "Stapx Steve [林槐]",
"description": "一个兼容 OneBot 的非官方网页版 QQ 客户端,使用 Vue 重制的全新版本。",
Expand Down Expand Up @@ -28,6 +28,7 @@
"js-file-downloader": "^1.1.24",
"js-yaml-loader": "^1.2.2",
"jsonpath": "^1.1.1",
"log4js": "^6.9.1",
"pinyin": "^3.0.0-alpha.4",
"prismjs": "^1.29.0",
"raw-loader": "^4.0.2",
Expand Down
8 changes: 4 additions & 4 deletions src/assets/css/append/append_new.css
Original file line number Diff line number Diff line change
Expand Up @@ -652,20 +652,20 @@
}
.script-view .list > header > span {
margin: 10px -5px 0 -5px;
font-size: 0.8rem;
font-size: 0.75rem;
}
.script-view .list-body {
margin: 0 -5px;
}
.script-view .list-body h2 {
font-size: 0.9rem;
font-size: 0.8rem;
}
.script-view .list-body span {
font-size: 0.8rem;
font-size: 0.75rem;
}
.script-view .list-body span svg {
margin: 0;
font-size: 0.75rem;
font-size: 0.7rem;
}
.script-view .editor-main {
box-shadow: -5px 0px 4px -5px var(--color-shader);
Expand Down
8 changes: 8 additions & 0 deletions src/assets/l10n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,20 @@
"scripts_run_condition": "条件",
"scripts_run_trigger": "触发",
"scripts_run_message": "新消息",
"scripts_run_userFlush": "好友/群列表刷新",
"option_dev_append": "进阶功能",
"option_dev_scripts_tip": "显示脚本功能面板",
"statue_enabled": "已启用",
"statue_disabled": "已禁用",
"scripts_run_title_err": "脚本标题已存在",
"scripts_run_notice": "脚本方法将限制在当前页面内,你可以参考当前页面的源代码来了解可用的方法可用。",
"option_dev_config_type": "解析配置",
"option_dev_config_type_tip": "不同框架之间的化学反应我们将其称之为达利园效应",
"option_dev_config_type_none": "未连接",
"cq_code": "CQ 码",
"array_code": "Array 数组",
"chat_pic": "图片",
"log_con_backend": "使用后端连接模式",

"menu_about": "关于",
"menu_update": "检查更新…",
Expand Down
6 changes: 3 additions & 3 deletions src/assets/pathMap/Lagrange.OneBot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ user_list:
group_id: /group_id
group_name: /group_name
member_count: /member_count
admin_flag: $.admins[?(@ == '<uin>')]
admin_flag: null

class_id: /group_id
class_name: /group_name
class_id: $.group.group_id
class_name: $.group.group_name
user_id: /user_id
nickname: /nickname
remark: /remark
Expand Down
17 changes: 13 additions & 4 deletions src/assets/pathMap/NapCat.Onebot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ login_info:
# 群、好友列表
friend_list:
name: get_friends_with_category
source: $.data[*]
source: $.data[*].buddyList[*]
list:
class_id: /categoryId
class_name: /categroyName
class_id: null
class_name: null
user_id: /user_id
nickname: /nickname
remark: /remark
Expand All @@ -30,7 +30,16 @@ group_list:
group_id: /group_id
group_name: /group_name
member_count: /member_count
admin_flag: $.admins[?(@ == '<uin>')]
admin_flag: null
# 好友分组
friend_category:
name: get_friends_with_category
source: $.data[*]
list:
class_id: /categoryId
class_name: /categoryName
sort_id: /categorySortId
users: $.buddyList[*].user_id
# 消息列表
message_list:
name: get_group_msg_history
Expand Down
27 changes: 18 additions & 9 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import Store from 'electron-store'
import installExtension from 'electron-devtools-installer'

import windowStateKeeper from 'electron-window-state'
import packageInfo from '../package.json'
import { noticeList, regIpcListener } from './function/electron/ipc'
import { version } from '../package.json'
import { Menu, session, app, protocol, BrowserWindow } from 'electron'
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import { touchBar } from './function/electron/touchbar'
import log4js from 'log4js'

const isDevelopment = process.env.NODE_ENV !== 'production'
const isPrimary = app.requestSingleInstanceLock()
const logger = log4js.getLogger('background')
export let logLevel = isDevelopment ? 'debug' : 'info'

protocol.registerSchemesAsPrivileged([
{ scheme: 'app', privileges: { secure: true, standard: true } }
Expand All @@ -21,19 +24,25 @@ protocol.registerSchemesAsPrivileged([
export let win = undefined as BrowserWindow | undefined
export let touchBarInstance = undefined as touchBar | undefined

/* eslint-disable no-console */
async function createWindow() {
if(new Store().get('opt_log_level')) {
logLevel = (String) (new Store().get('opt_log_level')) ?? 'info'
}
logger.level = logLevel

/* eslint-disable no-console */
console.log('')
console.log(' _____ _____ _____ _____ __ __ \n' +
'| __|_ _| _ | _ | | | \n' +
'|__ | | | | | __|- -| \n' +
'|_____| |_| |__|__|__| |__|__| CopyRight © Stapx Steve')
console.log('=======================================================')
console.log('Welcome to Stapxs QQ Lite, current version: ' + version)
console.log('The background language component will be initialized after the frontend is loaded.')
console.log('日志等级:', logLevel)
/* eslint-enable no-console */
logger.info('欢迎使用 Stapxs QQ Lite, 当前版本: ' + packageInfo.version)

console.log('Platform:' + process.platform)
console.log('Start creating main window ……')
logger.info('启动平台架构:' + process.platform)
logger.info('正在创建窗体 ……')
Menu.setApplicationMenu(null)
// 创建窗口
const mainWindowState = windowStateKeeper({
Expand Down Expand Up @@ -89,7 +98,7 @@ async function createWindow() {
win = new BrowserWindow(windowConfig)
win.once('focus', () => {if(win)win.flashFrame(false)})
mainWindowState.manage(win) // 窗口状态管理器
console.log('Create main window to complete.')
logger.info('创建窗体完成')
// 注册 IPC 事务
regIpcListener()
// macOS:创建 TouchBar
Expand Down Expand Up @@ -175,8 +184,8 @@ app.on('ready', async () => {
if (isDevelopment && !process.env.IS_TEST) {
try {
await installExtension('nhdogjmejiglipccpnnnanhbledajbpd')
} catch (e: any) {
console.error('Vue Devtools failed to install:', e.toString())
} catch (e: unknown) {
logger.error('Vue Devtools 安装失败:', (e as Error).toString())
}
}
createWindow()
Expand Down
37 changes: 2 additions & 35 deletions src/components/MsgBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@
{{ isMe ? runtimeData.loginInfo.nickname : runtimeData.chatInfo.show.name }}
</a>
<div>
<!-- 回复指示框(独立版本) -->
<div v-if="data.source && data.source.seq" :class="isMe ? (type == 'merge' ? 'msg-replay' : 'msg-replay me') : 'msg-replay'"
@click="scrollToMsg(data.source.seq)">
<font-awesome-icon :icon="['fas', 'reply']" />
<a> {{ getRepInfo((data.source ? data.source.message : ''), data) }} </a>
</div>
<!-- 消息体 -->
<template v-if="!hasCard()">
<div v-for="(item, index) in data.message" :class="View.isMsgInline(item.type) ? 'msg-inline' : ''" :key="data.message_id + '-m-' + index">
<div v-if="item.type === undefined"></div>
<span v-else-if="isDebugMsg" class="msg-text">{{ item }}</span>
<span v-else-if="item.type == 'text'" @click="textClick" v-show="item.text !== ''" class="msg-text" v-html="parseText(item.text)"></span>
<img v-else-if="item.type == 'image'" :title="$t('chat_view_pic')" :alt="$t('chat_group_pic')" @load="scrollButtom" @error="imgLoadFail" @click="imgClick(data.message_id)" :class="imgStyle(data.message.length, index, item.asface)" :src="item.url">
<img v-else-if="item.type == 'image'" :title="$t('chat_view_pic')" :alt="$t('chat_pic')" @load="scrollButtom" @error="imgLoadFail" @click="imgClick(data.message_id)" :class="imgStyle(data.message.length, index, item.asface)" :src="item.url">
<template v-else-if="item.type == 'face'">
<img v-if="getFace(item.id)" :alt="item.text" class="msg-face" :src="getFace(item.id)" :title="item.text">
<span v-else-if="item.id == 394" class="msg-face-long"><span v-for="i in 15" :key="data.message_id + '-l-' + i">🐲</span></span>
Expand All @@ -44,7 +38,7 @@
<img v-else-if="item.type == 'mface' && item.url" @load="scrollButtom" @error="imgLoadFail" :class="imgStyle(data.message.length, index, item.asface) + ' msg-mface'" :src="item.url">
<span v-else-if="item.type == 'mface' && item.text" class="msg-unknown">{{ item.text }}</span>
<span v-else-if="item.type == 'bface'" style="font-style: italic;opacity: 0.7;">[ {{ $t('chat_fun_menu_pic') }}:{{ item.text }} ]</span>
<div v-else-if="item.type == 'at'" v-show="isAtShow(data.source, item.qq)" :class="getAtClass(item.qq)">
<div v-else-if="item.type == 'at'" :class="getAtClass(item.qq)">
<a @mouseenter="showUserInfo" :data-id="item.qq" :data-group="data.group_id">{{ getAtName(item) }}</a>
</div>
<div v-else-if="item.type == 'file'" :class="'msg-file' + (isMe ? ' me' : '')">
Expand Down Expand Up @@ -174,18 +168,6 @@ export default defineComponent({
return getMsgRawTxt(message)
},

/**
* 判断是否需要隐藏重复的 At
* @param source 回复信息
* @param at at 信息
*/
isAtShow (source: any, at: any) {
if (source) {
return !(at === source.user_id)
}
return true
},

/**
* 根据消息状态获取 At 消息实际的 CSS class
* @param who
Expand Down Expand Up @@ -423,21 +405,6 @@ export default defineComponent({
}
},

/**
* 获取回复内容(拼接名字和消息内容)
* @param msg 消息对象
* @param data 回复信息
*/
getRepInfo (msg: any, data: any) {
const list = this.runtimeData.chatInfo.info.group_members.filter((item) => {
return Number(item.user_id) === Number(data.source.user_id)
})
if (list.length === 1) {
return (list[0].card !== '' ? list[0].card : list[0].nickname) + ': ' + msg
}
return msg
},

/**
* 尝试在消息列表中寻找这条被回复的消息,获取消息内容
* @param message_id
Expand Down
Loading

0 comments on commit dac4a65

Please sign in to comment.