Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
lanrengm committed Jan 20, 2025
1 parent fbd0eeb commit 174da74
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 111 deletions.
18 changes: 18 additions & 0 deletions data/恭喜发财.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"title": "恭喜发财",
"content": "恭喜发财",
"ww": 314,
"wh": 80,
"wx": 0,
"wy": -460,
"direction": "horizontal",
"isShow": true,
"isOpen": true,
"frameType": "transparent",
"fcolor": "gold",
"bcolor": "red",
"fontSize": 105,
"fontFamily": "楷体",
"frontTransform": "",
"backTransform": ""
}
18 changes: 18 additions & 0 deletions data/福临宝地千秋盛.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"title": "福临宝地千秋盛",
"content": "福临宝地千秋盛",
"ww": 78,
"wh": 420,
"wx": 882,
"wy": 120,
"direction": "vertical",
"isShow": true,
"isOpen": true,
"frameType": "transparent",
"fcolor": "gold",
"bcolor": "red",
"fontSize": 105,
"fontFamily": "楷体",
"frontTransform": "",
"backTransform": ""
}
2 changes: 1 addition & 1 deletion data/福到了.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ww": 250,
"wh": 250,
"wx": 0,
"wy": 0,
"wy": 173,
"direction": "horizontal",
"isShow": true,
"isOpen": true,
Expand Down
18 changes: 18 additions & 0 deletions data/财进家门万事兴.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"title": "财进家门万事兴",
"content": "财进家门万事兴",
"ww": 78,
"wh": 420,
"wx": -882,
"wy": 120,
"direction": "vertical",
"isShow": true,
"isOpen": true,
"frameType": "transparent",
"fcolor": "gold",
"bcolor": "red",
"fontSize": 105,
"fontFamily": "楷体",
"frontTransform": "",
"backTransform": ""
}
1 change: 1 addition & 0 deletions src/cpts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ export class Foo extends Element {
name=""
min="0"
max={this.Ow * 2}
step="1"
state-value={this.fontSize}
/>
</td>
Expand Down
141 changes: 31 additions & 110 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import * as sys from "@sys";
import { encode, decode } from "@sciter";
import { decode } from "@sciter";

import { Foo } from "./cpts.jsx";

const dataPath = "data.json";

document.on("ready", async function () {
// 设置控制台窗口初始位置
const [screenW, screenH] = Window.this.screenBox("frame", "dimension");
const [x, y] = Window.this.box("position", "client", "monitor");
Window.this.move(screenW * 0.65, screenH * 0.05);
Window.this.state = Window.WINDOW_SHOWN;
try {
// 设置控制台窗口初始位置
const [screenW, screenH] = Window.this.screenBox("frame", "dimension");
Window.this.move(screenW * 0.65, screenH * 0.05);
Window.this.state = Window.WINDOW_SHOWN;
// 加载春联数据
document.body.append(<App />);
} catch (e) {
Window.this.modal(<alert caption="报错">{e}</alert>);
}

// 加载文件
try {
const file = await sys.fs.open(dataPath, "r", 0o666);
const data = JSON.parse(decode(await file.read(), "utf8"));
await file.close();
} catch (e) {
Window.this.modal(<alert caption="警告">第一次启动,没有配置文件</alert>);
Window.this.modal(<errir> index.js:document.on.ready: {e}</errir>);
}
});

Expand All @@ -33,6 +22,7 @@ class App extends Element {
handleShow() {
this.isShow.send(true);
}

handleHide() {
this.isShow.send(false);
}
Expand All @@ -44,55 +34,6 @@ class App extends Element {
handleShow={this.handleShow.bind(this)}
handleHide={this.handleHide.bind(this)}
/>
{/* <Foo
title="横批"
content="恭喜发财"
direction="horizontal"
ww={200}
wh={50}
wx={0}
wy={-450}
isShow={this.isShow.value}
isOpen={true}
/>
<Foo
title="上联"
content="福临宝地千秋盛"
direction="vertical"
ww={56}
wh={202}
wx={904}
wy={0}
isShow={this.isShow.value}
/>
<Foo
title="下联"
content="财进家门万事兴"
direction="vertical"
ww={56}
wh={202}
wx={-904}
wy={0}
isShow={this.isShow.value}
/> */}
{/* <Foo
title="福到了"
content="福"
direction="horizontal"
ww={250}
wh={250}
wx={0}
wy={0}
isShow={this.isShow.value}
isOpen={true}
fColor="gold"
bColor="red"
fontSize={306}
frameType="transparent"
frontTransform="rotate(45deg) translate(-5,10)"
backTransform="rotate(135deg) scale(0.7)"
fontFamily="楷体"
/> */}
</div>
);
}
Expand All @@ -110,21 +51,6 @@ class Bar extends Element {
this.handleHide = handleHide;
}

async saveConfig() {
// const config = {
// topText: document.$('input#top-text').value,
// rightText: document.$('input#right-text').value,
// leftText: document.$('input#left-text').value,
// };
// const json = JSON.stringify(config, null, 2);
// const file = await sys.fs.open(dataPath, "w+", 0o666);
// await file.write(json);
// await file.close();
Window.this.modal(
<alert caption="保存成功">配置文件已保存到 {dataPath}</alert>
);
}

async getConfigList() {
const dir = "./data/";
try {
Expand All @@ -145,38 +71,36 @@ class Bar extends Element {
const filePath = `./data/${fileName}`;
// Window.this.modal(<info>{filePath}</info>);
try {
// 加载春联数据
const file = await sys.fs.open(filePath, "r", 0o666);
const data = JSON.parse(decode(await file.read(), "utf8"));
await file.close();
// Window.this.modal(
// <alert caption="加载成功">配置文件 {data} 已加载</alert>
// );
} catch (e) {
Window.this.modal(<error>Bar.showConfig: {e}</error>);
}
try {
// 显示春联
Window.this.document
.$("#root")
.append(
<Foo
title={data.title}
content={data.content}
ww={data.ww}
wh={data.wh}
wx={data.wx}
wy={data.wy}
direction={data.direction}
isShow={data.isShow}
isOpen={data.isOpen}
frameType={data.frameType}
fColor={data.fColor}
bColor={data.bColor}
fontSize={data.fontSize}
frontTransform={data.frontTransform}
backTransform={data.backTransform}
fontFamily={data.fontFamily}
/>
);
.$("#root")
.append(
<Foo
title={data.title}
content={data.content}
ww={data.ww}
wh={data.wh}
wx={data.wx}
wy={data.wy}
direction={data.direction}
isShow={data.isShow}
isOpen={data.isOpen}
frameType={data.frameType}
fColor={data.fColor}
bColor={data.bColor}
fontSize={data.fontSize}
frontTransform={data.frontTransform}
backTransform={data.backTransform}
fontFamily={data.fontFamily}
/>
);
} catch (e) {
Window.this.modal(<error>Bar.showConfig: {e}</error>);
}
Expand All @@ -194,9 +118,6 @@ class Bar extends Element {
<td class="col-end right">
<button onclick={this.handleHide}>隐藏全部</button>
<button onclick={this.handleShow}>显示全部</button>
<button onclick={this.saveConfig.bind(this)}>
保存全部设置
</button>
</td>
</tr>
</table>
Expand Down

0 comments on commit 174da74

Please sign in to comment.