Skip to content

Commit

Permalink
#177 一月累积更新
Browse files Browse the repository at this point in the history
✨ 群收纳盒功能,现在你可以在群收纳盒中查看活跃的群消息了 <- #169
✨ at 和特别关心消息现在将显示为红色文本便于查看 <- #169
✨ 快速动画模式 💨 <- #169
✨ 本地高级链接解析,目前只支持 electron 端
✨ 好友信息面板完善 <- #160
🐛 修正移出群聊和撤回菜单显示判断异常 <- #169
🐛 +1 操作未拷贝对象导致渲染移动 <- #170
🐛 为 npx 快速启动组件限制访问路径防止非法访问 <- #176
💩 移除英文文档和英文多语言支持
💩 调整一个判断错误导致的统计功能损坏
  • Loading branch information
Stapxs authored Jan 21, 2025
2 parents ad2d89c + 3c14729 commit 017b638
Show file tree
Hide file tree
Showing 34 changed files with 595 additions and 3,065 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# 文档

- **简体中文(当前)**
- **[English](README_en-US.md)**

## ✨ 特性支持

Expand Down
163 changes: 0 additions & 163 deletions README_en-US.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stapxs-qq-lite",
"version": "3.0.2",
"version": "3.0.3",
"private": false,
"author": "Stapx Steve [林槐]",
"description": "一个兼容 OneBot 的非官方网页版 QQ 客户端,使用 Vue 重制的全新版本。",
Expand Down
36 changes: 35 additions & 1 deletion src/main/function/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Store from 'electron-store'
import path from 'path'
import os from 'os'
import log4js from 'log4js'
import axios from 'axios'

import {
ipcMain,
Expand All @@ -12,7 +13,7 @@ import {
MenuItemConstructorOptions,
Notification as ELNotification,
} from 'electron'
import { runCommand } from './util.ts'
import { linkView, runCommand } from './util.ts'
import { win, touchBarInstance } from '../index.ts'
import { Connector } from './connector.ts'
import { logLevel } from '../index.ts'
Expand Down Expand Up @@ -41,6 +42,39 @@ export function regIpcListener() {
ipcMain.handle('sys:getRelease', () => {
return os.release()
})
// 本地链接预览
ipcMain.handle('sys:previewLink', async (_, link: string) => {
const linkList = {
bilibili: ['bilibili.com', 'b23.tv', 'bili2233.cn', 'acg.tv'],
}

// 判断是不是特殊解析的链接
for (const key in linkList) {
if (linkList[key].some((item: string) => link.includes(item))) {
return await linkView[key](link)
}
}
// 通用解析,注意排除非 html 的请求防止下载大文件
const res = await axios.get(link, {
headers: { Accept: 'text/html' }
})
const contentType = res.headers['content-type']
if(contentType && contentType.includes('text/html')) {
// 获取 html
let html = res.data
const headEnd = html.indexOf('</head>')
html = html.slice(0, headEnd)
// 获取所有的 og meta 标签
const ogRegex = /<meta\s+property="og:([^"]+)"\s+content="([^"]+)"\s*\/?>/g
const ogTags = {} as {[key: string]: string}
let match: string[] | null
while ((match = ogRegex.exec(html)) !== null) {
ogTags[`og:${match[1]}`] = match[2]
}
return ogTags
}
return null
})
// 代理请求 HTTP
// ipcMain.on('sys:requestHttp', (event, args) => {
// console.log(args)
Expand Down
71 changes: 71 additions & 0 deletions src/main/function/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import child_process from 'child_process'
import axios from 'axios'
import { logLevel } from '../index.ts'
import log4js from 'log4js'

const logger = log4js.getLogger('util')

export function queryKeys(keyPath: string, value: string) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -34,3 +39,69 @@ export function runCommand(command: string) {
}
}) as Promise<{ stdout: any; stderr: any }>
}

export const linkView = {
async bilibili(url: string) {
logger.level = logLevel
if(!url.includes('bilibili.com')) {
// 获取最终重定向地址并处理
const finalUrl = await this.getFinalRedirectUrl(url)
if(finalUrl) {
return await this.getBilibiliPreView(finalUrl)
}
return null
}
return await this.getBilibiliPreView(url)
},

async getBilibiliPreView(url: string) {
const previewAPI = 'https://api.bilibili.com/x/web-interface/wbi/view?bvid='
const match = url.match(/bilibili.com\/video\/(BV[0-9a-zA-Z]+)/)
if (match) {
const bvid = match[1]
logger.info(`[linkView] 获取到 bilibili 链接:${bvid}`)
try {
const response = await axios.get(previewAPI + bvid)
const { data } = response
if (data.code === 0) {
logger.info(`[linkView] 预览 bilibili 链接成功:${data.data.title}`)
return {
type: 'bilibili',
sub_type: 'video',
data: {
title: data.data.title,
desc: data.data.desc,
pic: data.data.pic,
public: data.data.pubdate,
owner: data.data.owner,
stat: data.data.stat
}
}
}
} catch (error) {
logger.error('[linkView] 预览 bilibili 链接失败:', error)
}
}
return null
},

async getFinalRedirectUrl(initialUrl: string) {
try {
const url = new URL(initialUrl);
if (!['http:', 'https:'].includes(url.protocol)) {
return null;
}
if (initialUrl.length > 2000) {
return null;
}
const MAX_REDIRECTS = 10;
const response = await axios.get(url.toString(), {
maxRedirects: MAX_REDIRECTS,
validateStatus: (status) => status < 400
})
return response.request.res.responseUrl
} catch (error) {
return null
}
}
}
4 changes: 2 additions & 2 deletions src/mobile/android/app/app.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=3.0.1
versionCode=3000001
versionName=3.0.3
versionCode=3000003
4 changes: 2 additions & 2 deletions src/mobile/ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.1</string>
<string>3.0.3</string>
<key>CFBundleVersion</key>
<string>3.0.1</string>
<string>3.0.3</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
16 changes: 8 additions & 8 deletions src/mobile/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ EXTERNAL SOURCES:
:path: "../../../../node_modules/@untiny/capacitor-safe-area"

SPEC CHECKSUMS:
Capacitor: 1f3c7b9802d958cd8c4eb63895fff85dff2e1eea
CapacitorApp: 2a8c3a0b0814322e5e6e15fe595f02c3808f0f8b
Capacitor: 05d35014f4425b0740fc8776481f6a369ad071bf
CapacitorApp: e1e6b7d05e444d593ca16fd6d76f2b7c48b5aea7
CapacitorCordova: b33e7f4aa4ed105dd43283acdd940964374a87d9
CapacitorKeyboard: 460c6f9ec5e52c84f2742d5ce2e67bbc7ab0ebb0
CapacitorLocalNotifications: 113dcab0b40781e8463bfdbbd6b54c6116361644
CapacitorOnebotConnctor: 4b8b6ea764a19d57c4c14df6c9c628a803bb0131
CapacitorStatusBar: 3b9ac7d0684770522c532d1158a1434512ab1477
HugotomaziCapacitorNavigationBar: 57d7cd51c65ef5e40159bafb0095ee99fab432ba
UntinyCapacitorSafeArea: 6354c662c37e272d587bb2a224cba030d902b2bd
CapacitorKeyboard: e89189ad398b815b6ff7e52271f0fb4f911a0a0a
CapacitorLocalNotifications: cd2aca61d90f278562f3afe921964232046911b8
CapacitorOnebotConnctor: 6f9f82cae00c8fe1f1838456d079802613d5732b
CapacitorStatusBar: b16799a26320ffa52f6c8b01737d5a95bbb8f3eb
HugotomaziCapacitorNavigationBar: d56bded81461cc38cd071727126e7298002ff2b5
UntinyCapacitorSafeArea: bbfa1040710d042e8da47a45f3105f2364ac8681

PODFILE CHECKSUM: c65146071ed43150d5e23368cffe06dd48ed84df

Expand Down
2 changes: 1 addition & 1 deletion src/mobile/ios/App/Settings.bundle/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<key>Key</key>
<string>version</string>
<key>DefaultValue</key>
<string>3.0.1</string>
<string>3.0.3</string>
<key>IsSecure</key>
<false/>
<key>KeyboardType</key>
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,11 @@ export default defineComponent({
// =============================================================
// 初始化完成
// UM:加载 Umami 统计功能
if (!Option.get('close_ga') && this.dev) {
if (!Option.get('close_ga') && !this.dev) {
// 给页面添加一个来源域名方便在 electron 中获取
const config = {
baseUrl: import.meta.env.VITE_UMAMI_URL,
websiteId: import.meta.env.VITE_UMAMI_ID,
baseUrl: import.meta.env.VITE_APP_MU_ADDRESS,
websiteId: import.meta.env.VITE_APP_MU_ID,
} as any
if (runtimeData.tags.isElectron) {
config.hostName = 'electron.stapxs.cn'
Expand Down Expand Up @@ -476,7 +476,7 @@ export default defineComponent({
// UM:发送页面路由分析
if (
!Option.get('close_ga') &&
this.dev
!this.dev
) {
Umami.trackPageView('/' + view)
}
Expand Down
Loading

0 comments on commit 017b638

Please sign in to comment.