Skip to content

Commit

Permalink
小小的需求,大大的满足
Browse files Browse the repository at this point in the history
💚 去除了 CI 流程中的一些无用代码
🎨 对部分不统一的 font-awesome-icon 组件用法进行了统一
💄 修改了一些样式 <- #104
✨ 增加了禁用回应选单的功能,便于部分不支持此功能的 bot 适用 <- #101
🐛 自动判断消息类型失效 <- #107
🐛 (未解决) macOS 无法获取 homebrew 环境用于判断安装方式,暂时去除了相关功能
  • Loading branch information
Stapxs committed Jul 15, 2024
1 parent 7b0edf0 commit 3a3bece
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</component>
<TransitionGroup class="app-msg" name="appmsg" tag="div">
<div v-for="msg in appMsgs" :key="'appmsg-' + msg.id">
<div><font-awesome-icon :icon="'fa-solid fa-' + msg.svg"/></div>
<div><font-awesome-icon :icon="['fas', msg.svg]"/></div>
<a>{{ msg.text }}</a>
<div v-if="!msg.autoClose" @click="popInfo.remove(msg.id)">
<font-awesome-icon :icon="['fas', 'xmark']"/>
Expand All @@ -134,7 +134,7 @@
<font-awesome-icon :icon="['fas', runtimeData.popBoxList[0].svg]" />
</div>
<a>{{ runtimeData.popBoxList[0].title }}</a>
<font-awesome-icon @click="removePopBox" icon="fa-solid fa-xmark"/>
<font-awesome-icon @click="removePopBox" :icon="['fas','xmark']"/>
</header>
<div v-if="runtimeData.popBoxList[0].html" v-html="runtimeData.popBoxList[0].html"></div>
<component v-else
Expand Down
3 changes: 2 additions & 1 deletion src/assets/css/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ input {
background: transparent;
line-height: 1.1rem;
border-radius: 7px;
margin-top: 5px;
font-size: 0.85rem;
max-height: 50px;
margin-top: 5px;
height: 26px;
resize: none;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/msg.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
.msg-face {
width: 1.5rem;
height: 1.5rem;
margin: -5px 2px 0 2px;
margin:0 2px -5px 2px;
/* image-rendering: pixelated; */
}
.msg-face-svg {
Expand Down
1 change: 1 addition & 0 deletions src/assets/css/view.css
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ textarea:focus {
}
.friend-list > div:first-child label > input {
background: transparent;
font-size: 0.8rem;
padding: 0 15px;
height: 100%;
width: 100%;
Expand Down
2 changes: 2 additions & 0 deletions src/assets/l10n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@
"option_view_dont_touch_tip": "啊吧啊吧(智慧)",
"option_dev_chatview_name_none": "默认",
"chat_msg_menu_plus": "+ 1",
"option_dev_chat_respond": "关闭回应功能",
"option_dev_chat_respond_tip": "如果你不想用它或者 bot 不支持,可以关闭这个功能",

"menu_about": "关于",
"menu_update": "检查更新…",
Expand Down
Empty file removed src/assets/l10n/zh-CN.yaml
Empty file.
4 changes: 2 additions & 2 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import installExtension from 'electron-devtools-installer'

import windowStateKeeper from 'electron-window-state'
import { noticeList, regIpcListener } from './function/electron/ipc'
import { version as appVersion } from '../package.json'
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'
Expand All @@ -28,7 +28,7 @@ async function createWindow() {
'|__ | | | | | __|- -| \n' +
'|_____| |_| |__|__|__| |__|__| CopyRight © Stapx Steve')
console.log('=======================================================')
console.log('Welcome to Stapxs QQ Lite, current version: ' + appVersion)
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('Platform:' + process.platform)
Expand Down
2 changes: 1 addition & 1 deletion src/components/FacePan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div icon="fa-solid fa-store">
<div class="store-face-list">
<div v-for="face in storeFace" :key="face.emoji_id">
<font-awesome-icon @click="removeMface(face)" icon="fa-solid fa-xmark"/>
<font-awesome-icon @click="removeMface(face)" :icon="['fas', 'xmark']"/>
<img loading="lazy"
:src="face.url"
:title="face.summary"
Expand Down
4 changes: 2 additions & 2 deletions src/components/FileBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<template>
<div :class="(item.type === 2 ? ' folder' : '') + ((item.sub_list && item.sub_list.length > 0) ? ' open' : '')"
@click="loadFileDir(item.id, item.type)">
<font-awesome-icon v-if="item.type === 2" icon="fa-solid fa-folder"/>
<font-awesome-icon v-if="item.type === 1" icon="fa-solid fa-file"/>
<font-awesome-icon v-if="item.type === 2" :icon="['fas', 'folder']"/>
<font-awesome-icon v-if="item.type === 1" :icon="['fas', 'file']"/>
<div class="main">
<span>{{ toHtml(item.name) }}</span>
<div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/FriendBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:data-name="data.user_id ? data.nickname : data.group_name" :data-nickname="data.user_id ? data.nickname : ''"
:data-type="data.user_id ? 'friend' : 'group'">
<div :class="(data.new_msg === true ? 'new' : '')"></div>
<font-awesome-icon v-if="data.user_id == -10000" icon="fa-solid fa-bell"/>
<font-awesome-icon v-if="data.user_id == -10000" :icon="['fas', 'bell']"/>
<img v-else loading="lazy" :title="getShowName()" :src="data.user_id ?
'https://q1.qlogo.cn/g?b=qq&s=0&nk=' + data.user_id :
'https://p.qlogo.cn/gh/' + data.group_id + '/' + data.group_id + '/0'">
Expand All @@ -26,7 +26,7 @@
<div>
<a>{{ data.raw_msg }}</a>
<div style="margin-left:10px;display:flex;">
<font-awesome-icon v-if="data.always_top === true" icon="fa-solid fa-thumbtack"/>
<font-awesome-icon v-if="data.always_top === true" :icon="['fas', 'thumbtack']"/>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/MsgBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<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>
<font-awesome-icon v-else :class="'msg-face-svg' + (isMe ? ' me': '')" icon="fa-solid fa-face-grin-wide"/>
<font-awesome-icon v-else :class="'msg-face-svg' + (isMe ? ' me': '')" :icon="['fas', 'face-grin-wide']"/>
</template>
<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>
Expand All @@ -53,7 +53,7 @@
<div><p>{{ loadFileBase(item, item.name, data.message_id) }}</p><a>({{ getSizeFromBytes(item.size) }})</a></div><i>{{ item.md5 }}</i>
</div>
<div>
<font-awesome-icon @click="downloadFile(item, data.message_id)" v-if="item.downloadingPercentage === undefined" icon="fa-solid fa-angle-down"/>
<font-awesome-icon @click="downloadFile(item, data.message_id)" v-if="item.downloadingPercentage === undefined" :icon="['fas', 'angle-down']"/>
<svg v-if="item.downloadingPercentage !== undefined" class="download-bar" xmlns="http://www.w3.org/2000/svg">
<circle cx="50%" cy="50%" r="40%" stroke-width="15%" fill="none" stroke-linecap="round" />
<circle cx="50%" cy="50%" r="40%" stroke-width="15%" fill="none" :stroke-dasharray="item.downloadingPercentage === undefined ?
Expand Down
2 changes: 1 addition & 1 deletion src/components/WelPan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<span>{{ $t('wel_select_language') }}</span>
<a>Select a language</a>
<div class="l10n-info" style="width: calc(100% - 40px)">
<font-awesome-icon style="margin-right: 30px;" icon="fa-solid fa-language"/>
<font-awesome-icon style="margin-right: 30px;" :icon="['fas', 'language']"/>
<div style="overflow: hidden;">
<select @change="save($event);gaLanguage($event)" name="language" title="language" v-model="runtimeData.sysConfig.language">
<option v-for="item in languages" :value="item.value" :key="item.value">{{ item.name }}</option>
Expand Down
5 changes: 4 additions & 1 deletion src/function/elements/information.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export enum BotMsgType {
CQCode, Array
CQCode, Array, Auto
}
export const botMsgTypeName: string[] = [
'CQ 码', 'Array 数组', '自动检测'
]

export interface RunTimeDataElem {
reader?: Electron.IpcRenderer | null,
Expand Down
5 changes: 3 additions & 2 deletions src/function/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const optDefault: { [key: string]: any } = {
initial_scale: 0.85,
fs_adaptation: 0,
theme_color: 0,
chat_background_blur: 0
chat_background_blur: 0,
msg_type: 2
}

// =============== 设置项事件 ===============
Expand Down Expand Up @@ -67,7 +68,7 @@ function updateGTKColor(value: boolean) {
}

function setMsgType(value: any) {
if(value && typeof value == 'number') {
if(value) {
runtimeData.tags.msgType = value
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/function/utils/msgUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Logger } from '@/function/base'
import { runtimeData } from '@/function/msg'
import { v4 as uuid } from 'uuid'
import { Connector } from '@/function/connect'
import { BotMsgType } from '../elements/information'

const logger = new Logger()

Expand Down Expand Up @@ -118,6 +119,15 @@ export function buildMsgList(msgList: { [key: string]: any }): { [key: string]:
}

export function parseMsgList(list: any, map: string, valueMap: { [key: string]: any }): any[] {
// 判断消息类型
if(runtimeData.tags.msgType == BotMsgType.Auto) {
if(typeof list[0].message == 'string') {
runtimeData.tags.msgType = BotMsgType.CQCode
} else {
runtimeData.tags.msgType = BotMsgType.Array
}
}

// 消息类型的特殊处理
switch (map.split('|')[0]) {
case 'cq-code': {
Expand Down
10 changes: 7 additions & 3 deletions src/pages/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
id="chat-pan">
<!-- 聊天基本信息 -->
<div class="info">
<font-awesome-icon @click="openLeftBar" icon="fa-solid fa-bars-staggered"/><img :src="chat.show.avatar">
<font-awesome-icon @click="openLeftBar" :icon="['fas', 'bars-staggered']"/><img :src="chat.show.avatar">
<div class="info">
<p>{{ chat.show.name }}</p>
<span v-if="chat.show.temp">
Expand All @@ -33,7 +33,7 @@
</div>
<div class="space"></div>
<div class="more">
<font-awesome-icon @click="openChatInfoPan" icon="fa-solid fa-ellipsis-vertical"/>
<font-awesome-icon @click="openChatInfoPan" :icon="['fas', 'ellipsis-vertical']"/>
</div>
</div>
<!-- 加载中指示器 -->
Expand Down Expand Up @@ -372,7 +372,7 @@
<script lang="ts">
import app from '@/main'
import SendUtil from '@/function/sender'
import Option from '@/function/option'
import Option, { get } from '@/function/option'
import Info from '@/pages/Info.vue'
import MsgBody from '@/components/MsgBody.vue'
import NoticeBody from '@/components/NoticeBody.vue'
Expand Down Expand Up @@ -706,6 +706,10 @@ export default defineComponent({
msg = this.tags.openedMenuMsg.msg
}
if(menu !== null && msg !== null) {
// 关闭回应功能
if(get('close_respond') == true) {
this.tags.menuDisplay.showRespond = false
}
if(select.nodeName == 'IMG' && (select as HTMLImageElement).name == 'avatar') {
// 右击头像需要显示的内容
Object.keys(this.tags.menuDisplay).forEach((name: string) => {
Expand Down
27 changes: 14 additions & 13 deletions src/pages/options/OptDev.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
<span>{{ $t('option_dev_msg_type') }}</span>
<span>{{ $t('option_dev_msg_type_tip') }}</span>
</div>
<select @change="save" name="msg_type" title="msg_type" v-model="runtimeData.tags.msgType">
<option value="">{{ $t('option_dev_msg_type_auto') }}</option>
<select @change="save" name="msg_type" title="msg_type" v-model="runtimeData.sysConfig.msgType">
<option v-for="item in BotMsgType" v-show="(typeof item == 'number')" :value="item" :key="item">{{
BotMsgType[item] }}</option>
botMsgTypeName[item] }}</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -188,14 +187,15 @@ import { runtimeData } from '@/function/msg'
import app from '@/main'
import { BrowserInfo, detect } from 'detect-browser'
import packageInfo from '../../../package.json'
import { BotMsgType } from '@/function/elements/information'
import { BotMsgType, botMsgTypeName } from '@/function/elements/information'
import { uptime } from '@/main'

export default defineComponent({
name: 'ViewOptDev',
data () {
return {
BotMsgType: BotMsgType,
botMsgTypeName: botMsgTypeName,
runtimeData: runtimeData,
save: save,
ws_text: '',
Expand Down Expand Up @@ -262,11 +262,15 @@ export default defineComponent({
if(runtimeData.tags.isElectron && runtimeData.reader && runtimeData.tags.release) {
switch(process.platform) {
case 'darwin': {
// homebrew
const brewInfo = await runtimeData.reader.invoke('sys:runCommand', 'brew list --cask stapxs-qq-lite')
if(brewInfo.success) {
info += ` Install Type -> homebrew\n`
}
// PS:在 macOS 下因为严格的进程权限,子线程环境无法获取到 brew 信息
// 暂时注释掉,没有找到解决方案
// // homebrew
// const brewInfo = await runtimeData.reader.invoke('sys:runCommand', '$SHELL -c "brew list --cask stapxs-qq-lite"')
// if(brewInfo.success) {
// info += ` Install Type -> homebrew\n`
// } else {
// logger.error('获取 homebrew 信息失败:' + brewInfo.message)
// }
break;
}
case 'linux': {
Expand All @@ -285,14 +289,11 @@ export default defineComponent({
}
break;
}
default: {
info += ` Install Type -> raw\n`
}
}
}

info += `Application Info:\n`
info += ` Uptime -> ${new Date().getTime() - uptime} ms\n`
info += ` Uptime -> ${Math.floor((new Date().getTime() - uptime) / 1000 * 100) / 100} s\n`
info += ` Package Version -> ${packageInfo.version}\n`
info += ` Runtime env -> ${process.env.NODE_ENV}\n`
info += ` Service Work -> ${runtimeData.tags.sw}\n`
Expand Down
14 changes: 14 additions & 0 deletions src/pages/options/OptFunction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@
</div>
</label>
</div>
<div class="opt-item">
<font-awesome-icon :icon="['fas', 'face-laugh-squint']"/>
<div>
<span>{{ $t('option_dev_chat_respond') }}</span>
<span>{{ $t('option_dev_chat_respond_tip') }}</span>
</div>
<label class="ss-switch">
<input type="checkbox" @change="save" name="close_respond"
v-model="runtimeData.sysConfig.close_respond">
<div>
<div></div>
</div>
</label>
</div>
<div class="opt-item">
<font-awesome-icon :icon="['fas', 'fish-fins']" />
<div>
Expand Down
18 changes: 1 addition & 17 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
: undefined
,
transpileDependencies: true,
productionSourceMap: false,
configureWebpack: {
devtool: 'source-map',
module: {
Expand Down Expand Up @@ -166,7 +167,6 @@ module.exports = {
},
],
},

afterAllArtifactBuild: async (context) => {
// 如果环境参数中有 `github-actions`,则删除 `dist_electron/out` 目录下所有的
// `*-unpacked` 目录和 `build` 开头的文件,便于 GitHub Actions 上传构建结果
Expand All @@ -188,22 +188,6 @@ module.exports = {
}
}
}
// 生成所有输出文件的 MD5 验证文件
const crypto = require('crypto')
const fs = require('fs')
const path = require('path')
const fileList = fs.readdirSync(context.outDir)
let md5List = []
for (const item of fileList) {
// 只包括 stapxs 开头的文件,忽略大小写,忽略文件夹
if (item.toLowerCase().startsWith('stapxs') &&
fs.statSync(path.join(context.outDir, item)).isFile()) {
const file = fs.readFileSync(path.join(context.outDir, item))
const md5Str = crypto.createHash('md5').update(file).digest('hex')
md5List.push(`${md5Str} ${item}`)
}
}
fs.writeFileSync(path.join(context.outDir, 'md5sum.txt'), md5List.join('\n'))
}
}
}
Expand Down

0 comments on commit 3a3bece

Please sign in to comment.