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

Test4 #44

Merged
merged 71 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
fad0d50
Compiled main.go and pushed changes
Hoshinonyaruko Oct 23, 2023
fda2572
test
Hoshinonyaruko Oct 23, 2023
34cfac1
适配了频道私聊,用bolt数据库取代ini
Hoshinonyaruko Oct 23, 2023
7fc1f10
适配了nonebot2
Hoshinonyaruko Oct 24, 2023
28f9a73
Merge branch 'main' of https://github.com/Hoshinonyaruko/Gensokyo
Hoshinonyaruko Oct 24, 2023
9fadda4
适配私域
Hoshinonyaruko Oct 24, 2023
1336c6a
add license
Hoshinonyaruko Oct 24, 2023
b094949
add a lot
Hoshinonyaruko Oct 25, 2023
f4787f5
Resolved merge conflicts
Hoshinonyaruko Oct 25, 2023
86698c6
trss support
Hoshinonyaruko Oct 26, 2023
045f3e9
fix
Hoshinonyaruko Oct 26, 2023
618561c
add action
Hoshinonyaruko Oct 26, 2023
7e803aa
add action
Hoshinonyaruko Oct 26, 2023
ece4cef
add action
Hoshinonyaruko Oct 26, 2023
f864a50
fixbug
Hoshinonyaruko Oct 26, 2023
4564731
add wss
Hoshinonyaruko Oct 26, 2023
070e4df
merge
Hoshinonyaruko Oct 26, 2023
84e8fe9
bugfix
Hoshinonyaruko Oct 26, 2023
0e4fd50
fix action
Hoshinonyaruko Oct 26, 2023
fe2234a
fix action again
Hoshinonyaruko Oct 26, 2023
cf67a11
fix action againnn
Hoshinonyaruko Oct 26, 2023
0875837
fa
Hoshinonyaruko Oct 26, 2023
3a3c33f
fix
Hoshinonyaruko Oct 26, 2023
8789fa8
add a lot
Hoshinonyaruko Oct 27, 2023
7943466
add ws server token
Hoshinonyaruko Oct 28, 2023
4660983
merge
Hoshinonyaruko Oct 28, 2023
2a1026a
bugifx
Hoshinonyaruko Oct 28, 2023
4186970
fix
Hoshinonyaruko Oct 28, 2023
2f26828
fixat
Hoshinonyaruko Oct 28, 2023
007e1af
bugfix
Hoshinonyaruko Oct 28, 2023
c41fd77
bugfix
Hoshinonyaruko Oct 28, 2023
d8354b7
test
Hoshinonyaruko Oct 28, 2023
6e3c63c
test
Hoshinonyaruko Oct 28, 2023
f08d9d7
test2
Hoshinonyaruko Oct 28, 2023
4dd6e15
add url service
Hoshinonyaruko Oct 31, 2023
1f8c174
add url service
Hoshinonyaruko Oct 31, 2023
240f569
add url service
Hoshinonyaruko Oct 31, 2023
b191cb7
bugfix
Hoshinonyaruko Oct 31, 2023
42daab3
merge
Hoshinonyaruko Oct 31, 2023
8fec03f
fix
Hoshinonyaruko Oct 31, 2023
cca528b
fix
Hoshinonyaruko Oct 31, 2023
463a182
fix
Hoshinonyaruko Oct 31, 2023
e9187a1
bug fix
Hoshinonyaruko Nov 1, 2023
5ba2815
fix
Hoshinonyaruko Nov 1, 2023
c16e1af
fix
Hoshinonyaruko Nov 1, 2023
ec7863d
test
Hoshinonyaruko Nov 2, 2023
e8a7e73
ok
Hoshinonyaruko Nov 2, 2023
122d17d
add webui
Hoshinonyaruko Nov 2, 2023
4e9c209
merge
Hoshinonyaruko Nov 2, 2023
b502d61
add image_compress
Hoshinonyaruko Nov 3, 2023
3519e3e
merge
Hoshinonyaruko Nov 3, 2023
530ff96
bug fix
Hoshinonyaruko Nov 3, 2023
155a701
fix cq code
Hoshinonyaruko Nov 3, 2023
2f5ee4a
fixbug
Hoshinonyaruko Nov 3, 2023
afa03e3
bugfix
Hoshinonyaruko Nov 3, 2023
fdd1a73
merge
Hoshinonyaruko Nov 3, 2023
fe39cd2
bugfix
Hoshinonyaruko Nov 3, 2023
be08cbe
bugfix
Hoshinonyaruko Nov 3, 2023
931dfef
merge
Hoshinonyaruko Nov 3, 2023
73819c8
bugfix
Hoshinonyaruko Nov 3, 2023
b27f062
bugfix
Hoshinonyaruko Nov 3, 2023
1a94197
bugfix
Hoshinonyaruko Nov 3, 2023
745b28e
bugfix
Hoshinonyaruko Nov 3, 2023
1212c9a
bugfix
Hoshinonyaruko Nov 4, 2023
44d8669
bugfix
Hoshinonyaruko Nov 4, 2023
564aba5
add new feature
Hoshinonyaruko Nov 5, 2023
d7345c1
bugfix
Hoshinonyaruko Nov 5, 2023
472a224
bugfix
Hoshinonyaruko Nov 5, 2023
e22b58b
bugfix
Hoshinonyaruko Nov 5, 2023
22cb473
bugfix
Hoshinonyaruko Nov 5, 2023
e563929
bugfix
Hoshinonyaruko Nov 5, 2023
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
16 changes: 13 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ type Settings struct {

// LoadConfig 从文件中加载配置并初始化单例配置
func LoadConfig(path string) (*Config, error) {
mu.Lock()
defer mu.Unlock()

// 如果单例已经被初始化了,直接返回
if instance != nil {
return instance, nil
}

configData, err := os.ReadFile(path)
if err != nil {
return nil, err
Expand All @@ -71,7 +79,9 @@ func LoadConfig(path string) (*Config, error) {
return nil, err
}

return conf, nil
// 设置单例实例
instance = conf
return instance, nil
}

// 确保配置完整性
Expand Down Expand Up @@ -149,8 +159,8 @@ func getMissingSettingsByReflection(currentConfig, defaultConfig *Config) (map[s
for i := 0; i < currentVal.NumField(); i++ {
field := currentVal.Type().Field(i)
yamlTag := field.Tag.Get("yaml")
if yamlTag == "" {
continue
if yamlTag == "" || field.Type.Kind() == reflect.Int || field.Type.Kind() == reflect.Bool {
continue // 跳过没有yaml标签的字段,或者字段类型为int或bool
}
yamlKeyName := strings.SplitN(yamlTag, ",", 2)[0]
if isZeroOfUnderlyingType(currentVal.Field(i).Interface()) && !isZeroOfUnderlyingType(defaultVal.Field(i).Interface()) {
Expand Down
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
Loading
Loading