Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 添加内置gocq(新版) #245

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/api/im_connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,16 @@ export function postAddSatori(platform: string, host: string, port: string, toke
});
}

export function postAddLagrange(account: string, signServerUrl: string, signServerVersion: string) {
export function postAddLagrange(
account: string,
signServerUrl: string,
signServerVersion: string,
isGocq: boolean,
) {
return request<DiceConnection>(
'post',
'addLagrange',
{ account, signServerUrl, signServerVersion },
{ account, signServerUrl, signServerVersion, isGocq },
'json',
{
timeout: 65000,
Expand Down Expand Up @@ -278,7 +283,7 @@ interface AdapterQQ {
appID: number;
isReverse: boolean;
reverseAddr: string;
builtinMode: 'gocq' | 'lagrange';
builtinMode: 'gocq' | 'lagrange' | 'lagrange-gocq';
}
enum goCqHttpStateCode {
Init = 0,
Expand Down
84 changes: 65 additions & 19 deletions src/components/PageConnectInfoItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
v-if="
i.platform === 'QQ' &&
(i.protocolType === 'onebot' || i.protocolType === 'walle-q') &&
i.adapter.builtinMode !== 'lagrange'
i.adapter.builtinMode === 'gocq'
">
<!-- <el-form-item label="忽略好友请求">
<div>{{i.adapter?.ignoreFriendRequest ? '是' : '否'}}</div>
Expand Down Expand Up @@ -249,6 +249,32 @@
</el-form-item>
</template>

<template
v-if="
i.platform === 'QQ' &&
i.protocolType === 'onebot' &&
i.adapter.builtinMode === 'lagrange-gocq'
">
<el-form-item label="接入方式">
<div>内置gocq</div>
</el-form-item>
<el-form-item label="签名地址">
<el-tooltip
class="item"
effect="dark"
:content="i.enable ? '禁用账号后方可修改签名服务地址' : '单击修改签名服务地址'"
placement="bottom">
<el-button
:icon="Edit"
size="small"
circle
:disabled="i.enable"
style="margin-left: 0.5rem"
@click="showSetSignServerDialog(i)" />
</el-tooltip>
</el-form-item>
</template>

<template v-if="i.platform === 'QQ' && i.protocolType === 'red'">
<el-form-item label="协议">
<div>[已弃用]Red</div>
Expand All @@ -272,9 +298,7 @@

<template
v-if="
i.platform === 'QQ' &&
i.protocolType === 'onebot' &&
i.adapter.builtinMode !== 'lagrange'
i.platform === 'QQ' && i.protocolType === 'onebot' && i.adapter.builtinMode === 'gocq'
">
<el-form-item label="其他">
<el-tooltip content="导出gocq设置,用于转分离部署" placement="top-start">
Expand Down Expand Up @@ -774,6 +798,17 @@
class="mb-6">
当前为容器模式,内置客户端被禁用。
</el-alert>
<el-alert
v-if="
store.diceServers.length > 0 &&
store.diceServers[0].baseInfo.containerMode &&
(form.accountType === 16 || form.accountType === 0)
"
type="warning"
:closable="false"
class="mb-6">
当前为容器模式,内置 gocq 被禁用。
</el-alert>

<el-form :model="form">
<el-form-item label="账号类型" :label-width="formLabelWidth">
Expand All @@ -784,6 +819,12 @@
:disabled="
store.diceServers.length > 0 && store.diceServers[0].baseInfo.containerMode
"></el-option>
<el-option
label="QQ(内置gocq)"
:value="16"
:disabled="
store.diceServers.length > 0 && store.diceServers[0].baseInfo.containerMode
"></el-option>
<el-option label="QQ(onebot11正向WS)" :value="6"></el-option>
<el-option label="QQ(onebot11反向WS)" :value="11"></el-option>
<el-option label="QQ(官方机器人)" :value="10"></el-option>
Expand All @@ -796,12 +837,6 @@
<el-option label="Dodo语音" :value="5"></el-option>
<el-option label="钉钉" :value="8"></el-option>
<el-option label="Slack" :value="9"></el-option>
<el-option
label="[已弃用]QQ(内置gocq)"
:value="0"
:disabled="
store.diceServers.length > 0 && store.diceServers[0].baseInfo.containerMode
"></el-option>
<el-option label="[已弃用]QQ(red协议)" :value="7"></el-option>
</el-select>
</el-form-item>
Expand Down Expand Up @@ -854,14 +889,14 @@
</el-form-item> -->

<el-form-item
v-if="form.accountType === 15"
v-if="form.accountType === 15 || form.accountType === 16"
label="账号"
:label-width="formLabelWidth"
required>
<el-input v-model="form.account" type="number" autocomplete="off"></el-input>
</el-form-item>
<el-form-item
v-if="form.accountType === 15"
v-if="form.accountType === 15 || form.accountType === 16"
label="签名服务"
:label-width="formLabelWidth"
required>
Expand All @@ -872,14 +907,14 @@
</el-radio-group>
</el-form-item>
<el-form-item
v-if="form.accountType === 15 && form.signServerType === 2"
v-if="(form.accountType === 15 || form.accountType === 16) && form.signServerType === 2"
label="自定义签名地址"
:label-width="formLabelWidth"
required>
<el-input v-model="form.signServerUrl" type="text" autocomplete="off"></el-input>
</el-form-item>
<el-form-item
v-else-if="form.accountType === 15"
v-else-if="form.accountType === 15 || form.accountType === 16"
label="签名版本"
:label-width="formLabelWidth"
required>
Expand Down Expand Up @@ -1756,7 +1791,7 @@
(form.accountType === 9 && (form.botToken === '' || form.appToken === '')) ||
(form.accountType === 11 && (form.account === '' || form.reverseAddr === '')) ||
(form.accountType === 13 && (form.token === '' || form.url === '')) ||
(form.accountType === 15 &&
((form.accountType === 15 || form.accountType === 16) &&
(form.account === '' || (form.signServerType === 2 && form.signServerUrl === '')))
"
@click="goStepTwo">
Expand Down Expand Up @@ -2024,7 +2059,7 @@ const goStepTwo = async () => {
setRecentLogin();
duringRelogin.value = false;

if (form.accountType === 15) {
if (form.accountType === 15 || form.accountType === 16) {
switch (form.signServerType) {
case 0:
form.signServerUrl = 'sealdice';
Expand Down Expand Up @@ -2315,10 +2350,8 @@ const handleSignServerDelete = (url: string) => {

const supportedQQVersions = ref<string[]>([]);

const defaultAccountType: number =
store.diceServers.length > 0 && store.diceServers[0].baseInfo.containerMode ? 6 : 15;
const form = reactive({
accountType: defaultAccountType,
accountType: 15,
step: 1,
isEnd: false,
account: '',
Expand Down Expand Up @@ -2398,6 +2431,19 @@ onBeforeMount(async () => {
supportedQQVersions.value = ['', ...versionsRes.versions];
}

// form.accountType默认账号类型,在android与mac系统中,默认账号类型为内置gocq,其余系统为内置客户端
if (store.diceServers.length > 0) {
if (
store.diceServers[0].baseInfo.OS === 'android' ||
store.diceServers[0].baseInfo.OS === 'darwin'
) {
form.accountType = 16;
}
if (store.diceServers[0].baseInfo.containerMode) {
form.accountType = 6;
}
}

timerId = setInterval(async () => {
console.log('refresh');
await store.getImConnections();
Expand Down
13 changes: 11 additions & 2 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface AdapterQQ {
appID: number;
isReverse: boolean;
reverseAddr: string;
builtinMode: 'gocq' | 'lagrange';
builtinMode: 'gocq' | 'lagrange' | 'lagrange-gocq';
}

interface TalkLogItem {
Expand Down Expand Up @@ -361,7 +361,16 @@ export const useStore = defineStore('main', {
if (signServerUrl === 'sealdice' || signServerUrl === 'lagrange') {
version = signServerVersion;
}
info = await postAddLagrange(account, signServerUrl, version);
info = await postAddLagrange(account, signServerUrl, version, false);
}
break;
case 16:
{
let version = '';
if (signServerUrl === 'sealdice' || signServerUrl === 'lagrange') {
version = signServerVersion;
}
info = await postAddLagrange(account, signServerUrl, version, true);
}
break;
}
Expand Down
Loading