Skip to content

Commit

Permalink
Test4 (#44)
Browse files Browse the repository at this point in the history
* Compiled main.go and pushed changes

* test

* 适配了频道私聊,用bolt数据库取代ini

* 适配了nonebot2

* add license

* add a lot

* trss support

* add action

* add action

* add action

* fixbug

* add wss

* bugfix

* fix action

* fix action again

* fa

* fix

* add a lot

* add ws server token

* bugifx

* fixat

* bugfix

* bugfix

* test

* test2

* add url service

* add url service

* bugfix

* fix

* fix

* fix

* bug fix

* fix

* test

* add webui

* add image_compress

* bug fix

* fix cq code

* fixbug

* bugfix

* bugfix

* bugfix

* bugfix

* bugfix

* bugfix

* bugfix

* add new feature

* bugfix

* bugfix

* bugfix

* bugfix

* bugfix
  • Loading branch information
Hoshinonyaruko authored Nov 5, 2023
1 parent 1b2b233 commit 2d01c05
Show file tree
Hide file tree
Showing 124 changed files with 1,409 additions and 224 deletions.
2 changes: 1 addition & 1 deletion frontend/quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = configure(function (ctx) {
minify: true,

distDir: './dist',
targetDir: '../nonebot_plugin_gocqhttp/web/dist',
targetDir: 'D:\\文件共享\\网络太卡了\\快乐GO\\botgo\\gensokyo\\webui\\dist',

afterBuild(configs) {
copyFolderRecursively(
Expand Down
30 changes: 30 additions & 0 deletions frontend/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,36 @@ export interface VersionInfo {
*/
'sdk'?: number;
}
export interface GuildOrChannelInfo {
id: string;
name: string;
icon?: string;
owner_id: string;
owner: boolean;
member_count?: number;
max_members?: number;
description?: string;
joined_at?: string;
channels?: ChannelInfo[]; // 假设我们也定义了一个ChannelInfo接口
union_world_id?: string;
union_org_id?: string;
// ...其他字段
}

export interface ChannelInfo {
name?: string; // Using '?' to indicate that the property is optional
type?: number;
position?: number;
parentID?: string;
ownerID?: string;
subType?: number;
privateType?: number;
privateUserIDs?: string[];
speakPermission?: number;
applicationID?: string;
permissions?: string;
opUserID?: string;
}

/**
* ApiApi - axios parameter creator
Expand Down
156 changes: 156 additions & 0 deletions frontend/src/components/ChannelList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<template>
<q-table
:rows="dataList"
:columns="columns"
:rows-per-page-options="[20, 50, 100]"
row-key="id"
selection="multiple"
v-model:selected="selected"
:row-class="rowClass"
>
<template v-slot:top-right="props">
<q-btn
label="Select All"
color="primary"
@click="selectAll(props.rows)"
/>
</template>
</q-table>
</template>

<script setup lang="ts">
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { defineProps, ref, watch, computed, defineEmits } from 'vue';
const selected = ref<string[]>([]);
const emit = defineEmits<{
(event: 'select', value: unknown): void;
(event: 'selectAll', value: unknown[]): void;
}>();
interface Channel {
// 保留自原始接口的字段
description: string; // 假设这个字段是可选的,因为在提供的 JSON 中没有
icon: string; // 同上
id: string;
joined_at?: string; // 同上,也可能是 Date 类型
max_members?: number; // 同上
member_count?: number; // 同上
name: string;
owner: boolean; // 同上
owner_id: string;
union_org_id: string; // 假设这个字段是可选的
union_world_id: string; // 同上
// 根据提供的 JSON 数据添加的字段
application_id?: string; // 假设这个字段是可选的
op_user_id?: string; // 同上
parent_id: string; // 同上
permissions: string; // 同上
position: number; // 同上
private_type: number; // 同上
speak_permission: number; // 同上
sub_type: number; // 同上
type: number; // 同上
}
// 定义 props
const props = defineProps({
dataList: {
type: Array,
default: () => [],
},
});
// 观察 selected 引用的变化
watch(selected, (newValue) => {
if (newValue.length === 1) {
// 单项选择
emit('select', newValue[0]);
} else {
// 多项选择或者没有选择
emit('selectAll', newValue);
}
});
// 计算属性,返回一个函数,该函数将根据行是否被选中来返回相应的类名
// 明确声明 props 参数的类型,确保类型安全
const rowClass = computed(() => {
return (props: { row: Channel }) => {
// 现在 TypeScript 知道 props.row 是 RowData 类型,props.row.id 是 string
return selected.value.includes(props.row.id) ? 'highlighted' : '';
};
});
const selectAll = (rows: Channel[]) => {
if (selected.value.length === rows.length) {
selected.value = []; // 取消全选
} else {
// 全选,但只选择每个Channel的id
selected.value = rows.map((channel) => channel.id);
}
// 发出全选事件,传递当前选中项的id数组
emit('selectAll', selected.value);
};
const columns = ref([
// Name column
{
type: 'selection', // 这里指定列的类型为选择框
align: 'center',
sortable: false,
},
{
name: 'name',
required: true,
label: '子频道名称',
align: 'left',
field: 'name',
sortable: true,
},
{
name: 'id',
label: '子频道id',
align: 'left',
field: 'id',
sortable: true,
},
{
name: 'owner_id',
label: '创建者id',
align: 'right',
field: 'owner_id',
sortable: true,
},
{
name: 'permissions',
label: '权限等级',
align: 'right',
field: 'permissions',
sortable: true,
},
{
name: 'speak_permission',
label: '发言权限',
align: 'left',
field: 'speak_permission',
sortable: true,
},
{
name: 'private_type',
label: '可见性',
align: 'center',
field: 'private_type',
sortable: true,
},
]);
</script>

<style>
.table-icon {
width: 30px; /* Adjust as needed */
height: auto;
}
.highlighted {
background-color: #569be9; /* 你选择的高亮颜色 */
}
</style>
6 changes: 4 additions & 2 deletions frontend/src/components/ConfigFileEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ let instance: editor.IStandaloneCodeEditor;
let preventUpdate = false; // 初始化preventUpdate
onMounted(() => {
if (dom.value) { // 检查dom.value是否为null或undefined
if (dom.value) {
// 检查dom.value是否为null或undefined
instance = editor.create(dom.value, {
value: props.modelValue,
language: props.language,
Expand All @@ -50,7 +51,8 @@ onMounted(() => {
watch(
() => props.modelValue,
(newValue) => {
if (!preventUpdate) { // 仅在更新不是由用户输入触发时,才执行setValue
if (!preventUpdate) {
// 仅在更新不是由用户输入触发时,才执行setValue
instance.setValue(newValue);
}
}
Expand Down
174 changes: 174 additions & 0 deletions frontend/src/components/GroupList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<template>
<q-table
:rows="dataList"
:columns="columns"
:rows-per-page-options="[20, 50, 100]"
row-key="id"
selection="multiple"
v-model:selected="selected"
:row-class="rowClass"
>
<template v-slot:top-right="props">
<q-btn
label="Select All"
color="primary"
@click="selectAll(props.rows)"
/>
</template>

<!-- Custom cell template for icon -->
<template v-slot:body-cell-icon="props">
<q-td :props="props">
<img :src="props.row.icon" alt="Channel Icon" class="table-icon" />
</q-td>
</template>
</q-table>
</template>

<script setup lang="ts">
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { defineProps, ref, watch, computed, defineEmits } from 'vue';
const selected = ref<string[]>([]);
const emit = defineEmits<{
(event: 'select', value: unknown): void;
(event: 'selectAll', value: unknown[]): void;
}>();
interface Channel {
channels: null; // 或者更精确的类型,如果它通常有一个值
description: string;
icon: string;
id: string;
joined_at: string; // 如果您需要操作日期,可能会考虑使用 Date 类型
max_members: number;
member_count: number;
name: string;
owner: boolean;
owner_id: string;
union_org_id: string;
union_world_id: string;
}
// 定义 props
const props = defineProps({
dataList: {
type: Array,
default: () => [],
},
});
// 观察 selected 引用的变化
watch(selected, (newValue) => {
if (newValue.length === 1) {
// 单项选择
emit('select', newValue[0]);
} else {
// 多项选择或者没有选择
emit('selectAll', newValue);
}
});
// 计算属性,返回一个函数,该函数将根据行是否被选中来返回相应的类名
// 明确声明 props 参数的类型,确保类型安全
const rowClass = computed(() => {
return (props: { row: Channel }) => {
// 现在 TypeScript 知道 props.row 是 RowData 类型,props.row.id 是 string
return selected.value.includes(props.row.id) ? 'highlighted' : '';
};
});
const selectAll = (rows: Channel[]) => {
if (selected.value.length === rows.length) {
selected.value = []; // 取消全选
} else {
// 全选,但只选择每个Channel的id
selected.value = rows.map((channel) => channel.id);
}
// 发出全选事件,传递当前选中项的id数组
emit('selectAll', selected.value);
};
const columns = ref([
// Icon column
{
type: 'selection', // 这里指定列的类型为选择框
align: 'center',
sortable: false,
},
{
name: 'icon',
align: 'center',
label: '图标',
field: 'icon',
sortable: false,
type: 'selection',
},
// Name column
{
name: 'name',
required: true,
label: '频道名称',
align: 'left',
field: 'name',
sortable: true,
},
// Member count column
{
name: 'member_count',
label: '成员数',
align: 'right',
field: 'member_count',
sortable: true,
},
// Joined at column
{
name: 'joined_at',
label: '加入时间',
align: 'left',
field: 'joined_at',
sortable: true,
},
// Max members column
{
name: 'max_members',
label: '最大成员数',
align: 'right',
field: 'max_members',
sortable: true,
},
// Owner column
{
name: 'owner',
label: '所有者',
align: 'center',
field: 'owner',
sortable: true,
},
// ID column
{
name: 'id',
label: 'ID',
align: 'left',
field: 'id',
sortable: true,
},
// Description column
{
name: 'description',
label: '描述',
align: 'left',
field: 'description',
sortable: true,
},
]);
</script>

<style>
.table-icon {
width: 30px; /* Adjust as needed */
height: auto;
}
.highlighted {
background-color: #e0e0e0; /* 你选择的高亮颜色 */
}
</style>
Loading

0 comments on commit 2d01c05

Please sign in to comment.