mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 13:07:17 +08:00
✨ 添加(table.ts, windows.ts, data.ts, SettingAction.ts, index.tsx, styles.module.scss, router/index.tsx):初始化config表,更新窗口配置,更新数据内容,添加SettingAction组件,更新设置页面布局和样式,更新路由配置。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Random } from "mockjs";
|
||||
import { db } from "./connect";
|
||||
import { findOne } from "./query";
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS categories (
|
||||
@@ -20,6 +21,28 @@ CREATE TABLE IF NOT EXISTS contents (
|
||||
);
|
||||
`)
|
||||
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS config (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT not null,
|
||||
content TEXT not null
|
||||
);
|
||||
`)
|
||||
|
||||
|
||||
function initData() {
|
||||
const initData = findOne('select * from config')
|
||||
if (initData) return
|
||||
db.exec(`insert into config (content) values('')`)
|
||||
|
||||
}
|
||||
|
||||
initData()
|
||||
// for (let i = 0; i < 20; i++) {
|
||||
// const name = Random.title(5, 10)
|
||||
// db.exec(`insert into config (content) values('${name}')`)
|
||||
// }
|
||||
|
||||
// for (let i = 0; i < 20; i++) {
|
||||
// const name = Random.title(5, 10)
|
||||
// db.exec(`insert into categories (name, created_at) values('${name}', datetime())`)
|
||||
|
||||
@@ -13,9 +13,10 @@ export const config = {
|
||||
options: {
|
||||
width: 1300,
|
||||
height: 600,
|
||||
openDevTools: true,
|
||||
frame: true,
|
||||
transparent: false,
|
||||
hash: '/#config/category/contentList'
|
||||
hash: '/#config'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,5 +43,6 @@ export const getWindowByEvent = (event: IpcMainEvent | IpcMainInvokeEvent) => {
|
||||
|
||||
|
||||
app.whenReady().then(() => {
|
||||
getWindowByName('search')
|
||||
// getWindowByName('search')
|
||||
getWindowByName('config')
|
||||
})
|
||||
@@ -2,7 +2,7 @@ $height: 32px;
|
||||
@mixin commonLink{
|
||||
@apply px-2 py-2 truncate cursor-pointer block mx-1 my-1 rounded-md;
|
||||
height: $height;
|
||||
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
// link 编译完是 a 标题
|
||||
.link{
|
||||
|
||||
@@ -3,8 +3,8 @@ export interface DataType {
|
||||
content: string
|
||||
}
|
||||
export const codes = [
|
||||
{id:1, content: "Hello, how are you?"},
|
||||
{id:2, content: "I am fine, thank you"},
|
||||
{id:1, content: "月报天才猫!"},
|
||||
{id:2, content: "新闻天才猫!"},
|
||||
{id:3, content: "How are you?"},
|
||||
{id:4, content: "I am fine, thank you"},
|
||||
{id:5, content: "How are you?"},
|
||||
|
||||
11
ui/autoMate/src/renderer/src/pages/Setting/SettingAction.ts
Normal file
11
ui/autoMate/src/renderer/src/pages/Setting/SettingAction.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export default async ({request})=>{
|
||||
const formData = await request.formData()
|
||||
const data = Object.fromEntries(formData)
|
||||
window.api.sql(`update config set content=@content where id = 1`,
|
||||
'update',
|
||||
{
|
||||
content: JSON.stringify(data)
|
||||
}
|
||||
)
|
||||
return {}
|
||||
}
|
||||
@@ -1,17 +1,27 @@
|
||||
import { Form, useSubmit } from 'react-router-dom'
|
||||
import styles from './styles.module.scss'
|
||||
|
||||
export const Setting = () => {
|
||||
const submit = useSubmit()
|
||||
return (
|
||||
<Form method="POST">
|
||||
<main className={styles.settingPage}>
|
||||
<h1>Setting</h1>
|
||||
<section>
|
||||
<h5>快捷键定义</h5>
|
||||
<input type="text"/>
|
||||
<input
|
||||
type="text"
|
||||
name="shortcut"
|
||||
onKeyUp={(e)=>{
|
||||
submit(e.currentTarget.form, {method: 'POST'})
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
<section>
|
||||
<h5>数据库</h5>
|
||||
<input type="text"/>
|
||||
<input type="text" name="databaseDirectory" defaultValue="abc"/>
|
||||
</section>
|
||||
</main>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
@@ -5,6 +5,12 @@
|
||||
}
|
||||
|
||||
section{
|
||||
h5 {
|
||||
@apply text-xs font-bold mb-2 text-slate-700 opacity-80;
|
||||
}
|
||||
@apply border p-3 rounded-md bg-white my-5;
|
||||
input {
|
||||
@apply border w-full outline-none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { Welcome } from "@renderer/pages/Welcome";
|
||||
import ContentListAction from "@renderer/pages/ContentList/ContentListAction";
|
||||
import CategoryAction from "@renderer/pages/Category/CategoryAction";
|
||||
import { Setting } from "@renderer/pages/Setting";
|
||||
import SettingAction from "@renderer/pages/Setting/SettingAction";
|
||||
|
||||
const router = createHashRouter([
|
||||
{
|
||||
@@ -24,6 +25,7 @@ const router = createHashRouter([
|
||||
children: [
|
||||
{
|
||||
index: true,
|
||||
action: SettingAction,
|
||||
element: <Setting/>
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user