Initial commit of akmon project

This commit is contained in:
2026-01-20 08:04:15 +08:00
commit 77a2bab985
1309 changed files with 343305 additions and 0 deletions

188
pages/test/supatest.uvue Normal file
View File

@@ -0,0 +1,188 @@
<template>
<view class="test-container">
<text class="title">AkSupa 功能测试</text>
<view class="section">
<text>邮箱></text>
<input v-model="email" placeholder="邮箱" />
</view>
<view class="section">
<text>密码></text>
<input v-model="password" placeholder="密码" />
</view>
<view class="section">
<button @click="testSignIn">signIn</button>
<button @click="testSignUp">signUp</button>
</view>
<view class="section">
<text>表名></text>
<input v-model="table" placeholder="表名" />
</view>
<view class="section">
<button @click="testSelect">select</button>
<button @click="testInsert">insert</button>
<button @click="testUpdate">update</button>
<button @click="testDelete">delete</button>
</view>
<view class="section">
<text>结果></text>
<text>{{ result }}</text>
</view>
</view>
</template>
<script lang="uts">
import { AkSupa, AkSupaSelectOptions } from '@/components/supadb/aksupa.uts';
import { SUPA_URL, SUPA_KEY } from '@/ak/config.uts';
import supa from '@/components/supadb/aksupainstance.uts'
export default {
data() {
return {
email: 'akoo@163.com',
password: 'Hf2152111',
table: 'member_user',
result: ''
};
},
methods: {
getSupa() {
return new AkSupa(SUPA_URL, SUPA_KEY);
},
async testSignIn() {
try {
const res = await this.getSupa().signIn(this.email, this.password);
this.result = JSON.stringify(res, null, 2);
} catch (e) {
this.result = 'signIn error: ' + JSON.stringify(e);
}
},
async testSignUp() {
try {
const res = await this.getSupa().signUp(this.email, this.password);
this.result = JSON.stringify(res, null, 2);
} catch (e) {
this.result = 'signUp error: ' + JSON.stringify(e);
}
},
async testSelect() {
try {
// 测试多种 filter 场景
// 1. id < 800
const filter1 = { id: { lt: 800 } } as UTSJSONObject;
// 2. name ilike '%foo%'
// const filter2 = { name: { ilike: '%foo%' } } as UTSJSONObject;
// 3. status = 'active' <20>?age >= 18 <20>?age <= 30
const filter3 = { status: 'active', age: { gte: 18, lte: 30 } } as UTSJSONObject;
// 4. id in [1,2,3]
const filter4 = { id: { in: [1,2,3] } } as UTSJSONObject;
// 5. is null
const filter5 = { deleted_at: { is: null } } as UTSJSONObject;
// 6. not equal
const filter6 = { status: { neq: 'inactive' } } as UTSJSONObject;
// 7. 组合
const filter7 = { id: { gte: 100, lte: 200 }, status: 'active' } as UTSJSONObject;
// 你可以切换不<E68DA2>?filter 测试
const filter = filter1;
const options: AkSupaSelectOptions = { limit: 10, order: '', columns: '*' };
// const res = await this.getSupa().select(this.table, filter, options);
const res = supa.from('system_dept').select('*',{count:'exact'}).or("name.like.%202%,email.like.%202%").limit(10).execute();
console.log(supa)
// this.result = JSON.stringify(res, null, 2);
} catch (e) {
this.result = 'select error: ' + JSON.stringify(e);
}
},
async testInsert() {
try {
// 插入一条测试数<E8AF95>?
const now = Math.floor(Date.now() / 1000);
const row = {
ztid: 1,
cid: 2,
classid: 3,
id: 10001,
newstime: now,
mid: 1,
isgood: 0,
changetime: new Date().toISOString(),
onclick: 0,
scnum: 0,
unzannum: 0,
zannum: 0,
plnum: 0,
totaldown: 0,
newspath: 'testpath',
filename: 'testfile',
userid: 123,
username: 'testuser',
firsttitle: 0,
ispic: false,
istop: false,
isqf: false,
ismember: false,
isurl: false,
truetime: now,
lastdotime: now,
havehtml: false,
groupid: 0,
userfen: 0,
titlefont: '',
titleurl: ''
} as UTSJSONObject;
const res = await this.getSupa().insert('ak_info', row);
this.result = 'insert ok: ' + JSON.stringify(res, null, 2);
} catch (e) {
this.result = 'insert error: ' + JSON.stringify(e);
}
},
async testUpdate() {
try {
// 更新 ak_info 表username = 'testuser' 的记录,修改 onclick 字段
const filter = { username: 'testuser' } as UTSJSONObject;
const values = { onclick: 999, zannum: 123, titleurl: 'updated-url', isgood: 1 } as UTSJSONObject;
const res = await this.getSupa().update('ak_info', filter, values);
this.result = 'update ok: ' + JSON.stringify(res, null, 2);
} catch (e) {
this.result = 'update error: ' + JSON.stringify(e);
}
},
async testDelete() {
try {
// 删除 username = 'testuser' 的记<E79A84>?
const filter = { username: 'testuser' } as UTSJSONObject;
const res = await this.getSupa().delete('ak_info', filter);
this.result = 'delete ok: ' + JSON.stringify(res, null, 2);
} catch (e) {
this.result = 'delete error: ' + JSON.stringify(e);
}
}
}
};
</script>
<style>
.test-container {
padding: 32rpx;
}
.title {
font-size: 36rpx;
font-weight: bold;
margin-bottom: 32rpx;
}
.section {
margin-bottom: 24rpx;
}
input {
border: 1px solid #ccc;
border-radius: 8rpx;
padding: 8rpx 16rpx;
margin-left: 12rpx;
}
button {
margin-right: 16rpx;
}
.result {
word-break: break-all;
color: #2196f3;
}
</style>