
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
lc_ood_framework
Advanced tools
我比较喜欢传统的面向对象开发、也喜欢原生 dom 开发,希望写代码的思路是直来直往的,不喜欢被各种作用域限制,所以我写了这个框架,如果你的项目较小,可以试用下这个框架,如果你有更好的建议,欢迎提 issue。
当前版本为 beta 版本,可能存在 bug,请勿用于生产环境,如有问题请随时提 issue。
npm install lc_ood_framework
如果需要使用 TypeScript,需要在 tsconfig.json 中添加以下配置:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "lc_ood_framework"
// 其他配置...
}
}
当前只测试过 RollDown 配置,其他构建工具还没测试过,后面会更新。
// rolldown
{
"jsx": {
"mode": "automatic",
"jsxImportSource": "lc_ood_framework"
}
// 其他配置...
}
使用方法跟现流行框架并无区别:
import { Component } from 'lc_ood_framework';
class App extends Component {
render() {
return <div>Hello World</div>;
}
}
const app = new App();
app.mount('#app');
本框架很多参考了 React, Vue 的设计思想,以下是本框架的设计特性:
虽然跟 React, Vue 一样,本框架状态变量也是从上向下传递,但在修改状态变量时,你不需要在上层声明状态变量,然后用来控制下层组件,所有组件都是独立的,跟原生 dom 一样,你只需找到元素,然后修改元素即可。例如你创建了一个弹窗组件,然后想弹窗提示用户时,你只需找到该组件实例,然后调用其弹窗方法即可:
import {querOne} from 'lc_ood_framework';
function submit() {
const confirmModal = queryOne('#confirm-modal');
confirmModal.open('Are you sure?', fcuntion () {
// do something
});
}
弹窗组件里,所有的状态变量都封装在 class 里,不需要从别的地方传入:
import { Component } from 'lc_ood_framework';
class ConfirmModal extends Component {
state = {
visible: false,
};
open(content, callback) {
this.setState({
visible: true,
content,
callback,
});
}
render() {
const style = {
display: this.state.visible ? 'block' : 'none',
};
return <div style={style}>{content}</div>;
}
// 其他代码
}
在 immer 的帮助下,你不需要考虑状态变量的可变性,你只需直接修改,即可触发 DOM 元素的变化。
import { Component } from 'lc_ood_framework';
class App extends Component {
constructor() {
super();
setTimeout(() => {
this.updateState((draft) => {
draft.todoList[1].done = true;
});
}, 1000);
}
state = {
todoList: [
{
id: 1,
content: 'todo 1',
done: false,
},
{
id: 2,
content: 'todo 2',
done: false,
},
],
};
render() {
return (
<ul>
{this.state.todoList.map((todo) => (
<li>
[{todo.done ? 'done' : ''}]:
{todo.content}
</li>
))}
</ul>
);
}
// 其他代理
}
以下是本框架的代码单词语义:
Component:组件State:状态变量Props:属性node: AST 节点element: DOM 元素由于框架设计特性本身或进度的原因,目前框架存在以下问题:
query方法找到该组件实例。我们非常欢迎您为本项目贡献代码。
本人当前失业中,如不介意本人年龄较大(40),可以联系本人:elantion@gmail.com,18666133756(微信同号) 曾在魅族、华为大公司工作过,有管理小团队的经验,web/nodejs 双料全栈开发,会基本的linux运维,热爱开源,喜欢折腾。
MIT
FAQs
A framework for Object-Oriented Design (OOD) in JavaScript.
We found that lc_ood_framework demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.