23種設計模式案例

一、創建型模式

1. 單例模式 (Singleton Pattern)

應用場景: 全局狀態管理、全局配置、共享資源訪問

// 全局狀態管理器
class Store {constructor() {if (Store.instance) return Store.instance;this.state = {};Store.instance = this;}getState(key) { return this.state[key]; }setState(key, value) { this.state[key] = value; }
}// 使用示例
const store1 = new Store();
const store2 = new Store();
console.log(store1 === store2); // truestore1.setState('user', { name: 'John' });
console.log(store2.getState('user')); // { name: 'John' }

2. 工廠方法模式 (Factory Pattern)

應用場景: 創建不同類型的UI組件、數據請求對象

class Button {render() { /* 基礎按鈕渲染 */ }
}class PrimaryButton extends Button {render() { /* 主要按鈕渲染 */ }
}class DangerButton extends Button {render() { /* 危險按鈕渲染 */ }
}class ButtonFactory {static createButton(type) {switch(type) {case 'primary': return new PrimaryButton();case 'danger': return new DangerButton();default: return new Button();}}
}// 使用示例
const primaryBtn = ButtonFactory.createButton('primary');
primaryBtn.render();

3. 抽象工廠模式 (Abstract Factory Pattern)

應用場景: 創建主題相關的UI組件族

// 抽象工廠
class ThemeFactory {createButton() {}createInput() {}
}// 具體工廠 - 亮色主題
class LightThemeFactory extends ThemeFactory {createButton() { return new LightButton(); }createInput() { return new LightInput(); }
}// 具體工廠 - 暗色主題  
class DarkThemeFactory extends ThemeFactory {createButton() { return new DarkButton(); }createInput() { return new DarkInput(); }
}// 使用示例
const theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? new DarkThemeFactory() : new LightThemeFactory();const button = theme.createButton();
const input = theme.createInput();

4. 建造者模式 (Builder Pattern)

應用場景: 構建復雜表單、配置復雜對象

class FormBuilder {constructor() {this.form = {fields: [],validations: [],onSubmit: null};}addField(type, name, placeholder = '') {this.form.fields.push({ type, name, placeholder });return this;}addValidation(fieldName, validator) {this.form.validations.push({ fieldName, validator });return this;}setSubmitHandler(handler) {this.form.onSubmit = handler;return this;}build() {return this.form;}
}// 使用示例
const loginForm = new FormBuilder().addField('text', 'username', '請輸入用戶名').addField('password', 'password', '請輸入密碼').addValidation('username', value => value.length >= 3).setSubmitHandler(data => console.log('提交數據:', data)).build();

5. 原型模式 (Prototype Pattern)

應用場景: 組件克隆、對象復制

// 基礎組件原型
const baseComponent = {render() { console.log('渲染組件'); },clone() { return Object.create(this); }
};// 使用示例
const component1 = baseComponent.clone();
const component2 = baseComponent.clone();component1.customMethod = function() { console.log('自定義方法'); };component1.render(); // 渲染組件
component2.render(); // 渲染組件
component1.customMethod(); // 自定義方法

二、結構型模式

6. 適配器模式 (Adapter Pattern)

應用場景: 統一不同數據源的接口格式

// 老版本API
class OldAPI {request() { return { data: { items: [] } }; }
}// 新版本API適配器
class APIAdapter {constructor(oldAPI) {this.oldAPI = oldAPI;}fetch() {const result = this.oldAPI.request();return { success: true, data: result.data.items };}
}// 使用示例
const oldAPI = new OldAPI();
const adapter = new APIAdapter(oldAPI);
const data = adapter.fetch(); // { success: true, data: [] }

7. 裝飾器模式 (Decorator Pattern)

應用場景: 增強組件功能、添加日志、權限控制

// 基礎組件
class Component {render() { console.log('渲染組件'); }
}// 裝飾器 - 添加日志
function withLogging(WrappedComponent) {return class extends WrappedComponent {render() {console.log('開始渲染');const result = super.render();console.log('渲染完成');return result;}};
}// 使用示例
const EnhancedComponent = withLogging(Component);
const component = new EnhancedComponent();
component.render();

8. 外觀模式 (Facade Pattern)

應用場景: 簡化復雜庫的API調用

// 復雜的三方圖表庫
class ComplexChartLib {init(config) { /* 復雜初始化 */ }setData(data) { /* 復雜數據設置 */ }render() { /* 復雜渲染邏輯 */ }destroy() { /* 復雜銷毀邏輯 */ }
}// 簡化外觀
class ChartFacade {constructor(container) {this.chart = new ComplexChartLib();this.container = container;}show(data, options = {}) {this.chart.init({ container: this.container, ...options });this.chart.setData(data);this.chart.render();}update(data) {this.chart.setData(data);}destroy() {this.chart.destroy();}
}// 使用示例
const chart = new ChartFacade('#chart-container');
chart.show([{ value: 10 }, { value: 20 }]);

9. 橋接模式 (Bridge Pattern)

應用場景: 分離UI組件樣式與行為

// 實現部分 - 渲染器
class Renderer {renderCircle(radius) {}
}class SVGRenderer extends Renderer {renderCircle(radius) {console.log(`繪制SVG圓形,半徑: ${radius}`);}
}class CanvasRenderer extends Renderer {renderCircle(radius) {console.log(`繪制Canvas圓形,半徑: ${radius}`);}
}// 抽象部分 - 形狀
class Shape {constructor(renderer) {this.renderer = renderer;}draw() {}
}class Circle extends Shape {constructor(renderer, radius) {super(renderer);this.radius = radius;}draw() {this.renderer.renderCircle(this.radius);}
}// 使用示例
const svgRenderer = new SVGRenderer();
const canvasRenderer = new CanvasRenderer();const circle1 = new Circle(svgRenderer, 5);
circle1.draw(); // 繪制SVG圓形,半徑: 5const circle2 = new Circle(canvasRenderer, 10);
circle2.draw(); // 繪制Canvas圓形,半徑: 10

10. 組合模式 (Composite Pattern)

應用場景: 構建樹形結構的UI組件

// 組件接口
class UIComponent {render() {}add(component) {}remove(component) {}
}// 葉子組件
class Button extends UIComponent {render() { console.log('渲染按鈕'); }add() { throw new Error('葉子組件不能添加子組件'); }remove() { throw new Error('葉子組件不能移除子組件'); }
}// 復合組件
class Panel extends UIComponent {constructor() {super();this.children = [];}add(component) { this.children.push(component); }remove(component) { this.children = this.children.filter(c => c !== component);}render() {console.log('開始渲染面板');this.children.forEach(child => child.render());console.log('完成渲染面板');}
}// 使用示例
const panel = new Panel();
panel.add(new Button());
panel.add(new Button());const subPanel = new Panel();
subPanel.add(new Button());
panel.add(subPanel);panel.render();

11. 享元模式 (Flyweight Pattern)

應用場景: 共享圖標、樣式等細粒度對象

class IconFactory {constructor() {this.icons = {};}getIcon(type) {if (!this.icons[type]) {this.icons[type] = this.createIcon(type);}return this.icons[type];}createIcon(type) {// 模擬創建圖標的昂貴操作console.log(`創建 ${type} 圖標`);return { render: () => console.log(`渲染 ${type} 圖標`) };}
}// 使用示例
const factory = new IconFactory();
const icon1 = factory.getIcon('delete');
const icon2 = factory.getIcon('delete'); // 不會重新創建icon1.render(); // 渲染 delete 圖標
icon2.render(); // 渲染 delete 圖標

12. 代理模式 (Proxy Pattern)

應用場景: 權限控制、緩存、懶加載

// 真實對象
class ImageLoader {load(url) {console.log(`加載圖片: ${url}`);return `圖片數據: ${url}`;}
}// 代理 - 添加緩存
class ImageLoaderProxy {constructor() {this.loader = new ImageLoader();this.cache = new Map();}load(url) {if (this.cache.has(url)) {console.log(`從緩存獲取圖片: ${url}`);return this.cache.get(url);}const data = this.loader.load(url);this.cache.set(url, data);return data;}
}// 使用示例
const proxy = new ImageLoaderProxy();
proxy.load('image1.jpg'); // 加載圖片: image1.jpg
proxy.load('image1.jpg'); // 從緩存獲取圖片: image1.jpg

三、行為型模式

13. 策略模式 (Strategy Pattern)

應用場景: 不同的數據驗證策略、排序策略

// 策略類
const validationStrategies = {required: (value) => !!value,email: (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value),minLength: (value, length) => value.length >= length
};// 上下文
class Validator {constructor() {this.strategies = [];}addStrategy(strategy, value, ...args) {this.strategies.push({ strategy, value, args });}validate() {return this.strategies.every(({ strategy, value, args }) => validationStrategies[strategy](value, ...args));}
}// 使用示例
const validator = new Validator();
validator.addStrategy('required', 'input value');
validator.addStrategy('minLength', 'hello', 3);console.log(validator.validate()); // true

14. 模板方法模式 (Template Method Pattern)

應用場景: 定義通用請求流程

// 抽象類
class DataFetcher {// 模板方法async fetchData() {this.showLoading();try {const data = await this.requestData();this.processData(data);this.hideLoading();return data;} catch (error) {this.handleError(error);this.hideLoading();throw error;}}// 抽象方法async requestData() { throw new Error('必須實現 requestData'); }// 具體方法showLoading() { console.log('顯示加載中...'); }hideLoading() { console.log('隱藏加載中'); }processData(data) { console.log('處理數據:', data); }handleError(error) { console.error('處理錯誤:', error.message); }
}// 具體實現
class UserDataFetcher extends DataFetcher {async requestData() {// 模擬API請求return await Promise.resolve([{ id: 1, name: 'John' }]);}
}// 使用示例
const fetcher = new UserDataFetcher();
fetcher.fetchData();

15. 觀察者模式 (Observer Pattern)

應用場景: 事件系統、數據響應式更新

class Observable {constructor() {this.observers = [];}subscribe(observer) {this.observers.push(observer);}unsubscribe(observer) {this.observers = this.observers.filter(obs => obs !== observer);}notify(data) {this.observers.forEach(observer => observer.update(data));}
}class Observer {update(data) {console.log('收到數據:', data);}
}// 使用示例
const observable = new Observable();
const observer1 = new Observer();
const observer2 = new Observer();observable.subscribe(observer1);
observable.subscribe(observer2);observable.notify('新數據'); // 兩個觀察者都會收到通知

16. 迭代器模式 (Iterator Pattern)

應用場景: 遍歷集合、自定義數據結構遍歷

class Collection {constructor() {this.items = [];}add(item) { this.items.push(item); }[Symbol.iterator]() {let index = 0;const items = this.items;return {next() {return index < items.length ? { value: items[index++], done: false }: { done: true };}};}
}// 使用示例
const collection = new Collection();
collection.add('item1');
collection.add('item2');
collection.add('item3');for (const item of collection) {console.log(item); // item1, item2, item3
}

17. 職責鏈模式 (Chain of Responsibility Pattern)

應用場景: 中間件管道、請求處理鏈

class Handler {constructor() {this.nextHandler = null;}setNext(handler) {this.nextHandler = handler;return handler;}handle(request) {if (this.nextHandler) {return this.nextHandler.handle(request);}return null;}
}class AuthHandler extends Handler {handle(request) {if (!request.user) {throw new Error('未認證');}console.log('認證通過');return super.handle(request);}
}class ValidationHandler extends Handler {handle(request) {if (!request.data) {throw new Error('數據無效');}console.log('驗證通過');return super.handle(request);}
}// 使用示例
const authHandler = new AuthHandler();
const validationHandler = new ValidationHandler();authHandler.setNext(validationHandler);try {authHandler.handle({ user: { id: 1 }, data: 'some data' });
} catch (error) {console.error(error.message);
}

18. 命令模式 (Command Pattern)

應用場景: 實現撤銷/重做功能

// 命令接口
class Command {execute() {}undo() {}
}// 具體命令
class AddItemCommand extends Command {constructor(list, item) {super();this.list = list;this.item = item;}execute() {this.list.add(this.item);}undo() {this.list.remove(this.item);}
}// 接收者
class ShoppingList {constructor() {this.items = [];}add(item) {this.items.push(item);console.log(`添加: ${item}`);}remove(item) {this.items = this.items.filter(i => i !== item);console.log(`移除: ${item}`);}
}// 調用者
class CommandManager {constructor() {this.history = [];this.redoStack = [];}execute(command) {command.execute();this.history.push(command);this.redoStack = [];}undo() {const command = this.history.pop();if (command) {command.undo();this.redoStack.push(command);}}redo() {const command = this.redoStack.pop();if (command) {command.execute();this.history.push(command);}}
}// 使用示例
const list = new ShoppingList();
const manager = new CommandManager();manager.execute(new AddItemCommand(list, '牛奶'));
manager.execute(new AddItemCommand(list, '面包'));
manager.undo(); // 移除: 面包
manager.redo(); // 添加: 面包

19. 備忘錄模式 (Memento Pattern)

應用場景: 保存和恢復表單狀態

class EditorMemento {constructor(content) {this.content = content;this.timestamp = Date.now();}
}class Editor {constructor() {this.content = '';this.history = [];}type(text) {this.content += text;}save() {const memento = new EditorMemento(this.content);this.history.push(memento);return memento;}restore(memento) {this.content = memento.content;}getHistory() {return this.history.map(m => ({content: m.content,timestamp: new Date(m.timestamp).toLocaleTimeString()}));}
}// 使用示例
const editor = new Editor();
editor.type('Hello');
const save1 = editor.save();editor.type(' World');
const save2 = editor.save();console.log(editor.content); // Hello Worldeditor.restore(save1);
console.log(editor.content); // Helloconsole.log(editor.getHistory());

20. 狀態模式 (State Pattern)

應用場景: 復雜的狀態管理

class TrafficLight {constructor() {this.states = {red: new RedState(this),yellow: new YellowState(this),green: new GreenState(this)};this.currentState = this.states.red;}changeState(state) {this.currentState = this.states[state];}request() {this.currentState.handle();}
}class LightState {constructor(light) {this.light = light;}handle() { throw new Error('必須實現handle方法'); }
}class RedState extends LightState {handle() {console.log('紅燈 - 停止');setTimeout(() => this.light.changeState('green'), 3000);}
}class GreenState extends LightState {handle() {console.log('綠燈 - 通行');setTimeout(() => this.light.changeState('yellow'), 3000);}
}class YellowState extends LightState {handle() {console.log('黃燈 - 準備');setTimeout(() => this.light.changeState('red'), 1000);}
}// 使用示例
const trafficLight = new TrafficLight();
trafficLight.request(); // 紅燈
setTimeout(() => trafficLight.request(), 3000); // 綠燈

21. 訪問者模式 (Visitor Pattern)

應用場景: 對DOM樹進行操作

// 元素接口
class DOMElement {accept(visitor) { throw new Error('必須實現accept方法'); }
}// 具體元素
class DivElement extends DOMElement {accept(visitor) {visitor.visitDiv(this);}
}class SpanElement extends DOMElement {accept(visitor) {visitor.visitSpan(this);}
}// 訪問者接口
class Visitor {visitDiv(element) {}visitSpan(element) {}
}// 具體訪問者
class RenderVisitor extends Visitor {visitDiv(element) {console.log('渲染div元素');}visitSpan(element) {console.log('渲染span元素');}
}class StyleVisitor extends Visitor {visitDiv(element) {console.log('為div添加樣式');}visitSpan(element) {console.log('為span添加樣式');}
}// 使用示例
const elements = [new DivElement(), new SpanElement()];
const renderVisitor = new RenderVisitor();
const styleVisitor = new StyleVisitor();elements.forEach(element => {element.accept(renderVisitor);element.accept(styleVisitor);
});

22. 中介者模式 (Mediator Pattern)

應用場景: 組件間通信

class Mediator {constructor() {this.components = {};}register(name, component) {this.components[name] = component;component.setMediator(this);}notify(sender, event, data) {if (event === 'buttonClick') {this.components.form.update(data);} else if (event === 'formSubmit') {this.components.list.addItem(data);}}
}class BaseComponent {setMediator(mediator) {this.mediator = mediator;}
}class Button extends BaseComponent {click() {this.mediator.notify(this, 'buttonClick', { action: 'click' });}
}class Form extends BaseComponent {update(data) {console.log('表單更新:', data);}submit(data) {this.mediator.notify(this, 'formSubmit', data);}
}class List extends BaseComponent {addItem(item) {console.log('列表添加項:', item);}
}// 使用示例
const mediator = new Mediator();
const button = new Button();
const form = new Form();
const list = new List();mediator.register('button', button);
mediator.register('form', form);
mediator.register('list', list);button.click(); // 表單更新: { action: 'click' }
form.submit({ name: '新項目' }); // 列表添加項: { name: '新項目' }

23. 解釋器模式 (Interpreter Pattern)

應用場景: 模板解析、查詢語言解析

// 上下文
class Context {constructor(input) {this.input = input;this.output = 0;}
}// 表達式接口
class Expression {interpret(context) { throw new Error('必須實現interpret方法'); }
}// 具體表達式
class NumberExpression extends Expression {interpret(context) {context.output = parseInt(context.input);}
}class AddExpression extends Expression {constructor(left, right) {super();this.left = left;this.right = right;}interpret(context) {this.left.interpret(context);const leftResult = context.output;this.right.interpret(context);const rightResult = context.output;context.output = leftResult + rightResult;}
}// 使用示例
const context = new Context('5 3');
const expression = new AddExpression(new NumberExpression(),new NumberExpression()
);expression.interpret(context);
console.log(context.output); // 8

總結

這些設計模式在前端開發中都有廣泛的應用場景:

  1. 創建型模式主要用于對象的創建和管理,幫助解耦對象的創建和使用
  2. 結構型模式關注類和對象的組合,形成更大的結構
  3. 行為型模式專注于對象之間的通信和職責分配

在實際開發中,這些模式經常組合使用,而不是孤立存在。理解這些模式的核心思想和適用場景,可以幫助我們設計出更加靈活、可維護的前端架構。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/97774.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/97774.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/97774.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

ctfshow_web13-----------文件上傳.user.ini

打開題目發現是一個文件上傳題掃描后發現存在upload.php.bak.bak是備份文件拿到源碼正則過濾了php&#xff0c;文件大小<24,文件名小于9經嘗試&#xff0c;改后綴php5,ptml均不行&#xff0c;使用.htaccess文件也不成功上傳上傳.user.ini&#xff0c;在文件中寫上auto_prepe…

圖像拼接案例,摳圖案例

目錄 一.圖像拼接案例 1.圖像拼接項目介紹 2.核心步驟 ①計算圖片特征點及描述符 ②匹配特征點&#xff0c;使用暴力匹配器 ③篩選有效匹配 ④計算透視變換矩陣 ⑤應用變換和拼接 二.摳圖案例 1.縮放旋轉處理 2.轉化為灰度圖并二值化 3.找出所有輪廓&#xff0c;并在…

【左程云算法筆記016】雙端隊列-雙鏈表和固定數組實現

目錄 1&#xff09;雙端隊列的介紹 2&#xff09;雙端隊列用雙鏈表的實現代碼演示 3&#xff09;雙端隊列用固定數組的實現 代碼演示 視頻 【算法講解016【入門】雙端隊列-雙鏈表和固定數組實現】 Leecode leecode641 設計循環雙端隊列 1&#xff09;雙端隊列的介紹 可以…

ffplay視頻輸出和尺寸變換

視頻輸出模塊 視頻輸出初始化的主要流程 我們開始分析視頻&#xff08;圖像&#xff09;的顯示。 因為使?了SDL&#xff0c;?video的顯示也依賴SDL的窗?顯示系統&#xff0c;所以先從main函數的SDL初始化看起&#xff08;節選&#xff09;&#xff1a; int main(int argc, c…

協議_https協議

http http協議是將數據以明文的形式在網絡上傳輸。若是傳輸的數據中包含一些敏感信息比如銀行卡信息等可能會被有心人攻擊造成信息泄露或被篡改。 總結&#xff1a;http協議進行數據傳輸難以保證數據的隱私性以及數據完整性&#xff0c;為了保證數據的準確定引入了https這一協…

阿里云 騰訊云 API 自動化查詢指南

文章目錄一、核心思路與架構建議二、經驗與核心建議三、技術方案選型建議四、API使用詳解4.1 阿里云4.2 騰訊云五、進階&#xff1a;與內部系統聯動免費個人運維知識庫&#xff0c;歡迎您的訂閱&#xff1a;literator_ray.flowus.cn 一、核心思路與架構建議 自動化流程可以概括…

【Unity 性能優化之路——概述(0)】

Unity性能優化概述性能優化不是某個環節的極致壓榨&#xff0c;而是所有模塊的協同共進。本文將為你建立完整的Unity性能優化知識體系。很多Unity開發者一提到性能優化&#xff0c;首先想到的就是Draw Call、Batches這些渲染指標。這沒錯&#xff0c;但它們只是性能優化中的一部…

靈碼產品演示:軟件工程架構分析

作者&#xff1a;了哥 演示目的演示靈碼對于整個復雜軟件工程項目的架構分析能力&#xff0c;輸出項目的軟件系統架構圖。演示文檔接口生成能力。演示準備 克隆工程地址到本地&#xff08;需提前安裝好 git 工具&#xff0c; 建議本地配置 brew&#xff09;&#xff1a; git cl…

銀河麒麟部署mysql8.0并連接應用

?客戶需在國產化銀河麒麟系統中部署軟件應用&#xff0c;使用mysql8.0數據庫。機器放置了兩三年&#xff0c;里面命令工具和依賴都不太全。而且客戶環境不聯網&#xff0c;只能采用離線部署的方式。部署過程中踩了很多坑&#xff0c;也用到很多資源&#xff0c;記錄一下。 過…

GitAgent-面壁智能聯合清華大學發布的大模型智能體應用框架

本文轉載自&#xff1a;https://www.hello123.com/gitagent ** 一、&#x1f50d; GitAgent 框架&#xff1a;大模型智能體的工具箱革命 GitAgent 是由面壁智能與清華大學自然語言處理實驗室聯合研發的創新型框架&#xff0c;旨在解決大模型智能體在復雜任務中的工具擴展瓶頸…

靈碼產品演示:Maven 示例工程生成

作者&#xff1a;輕眉 演示主題&#xff1a;由 AI 自動生成 0 到 1 的電商訂單 Java 項目 演示目的 面向 Java 零基礎的用戶&#xff0c;通過靈碼的產品能力&#xff08;如提示詞、編碼智能體、項目 Rules 和 SQLite MCP 服務、單元測試&#xff09;自動生成 0 到 1 的電商訂單…

AI編程從0-1開發一個小程序

小伙伴們&#xff0c;今天我們利用AI實現從0到1開發一個小程序&#xff01;需求交給AI&#xff1a; 我們只要說出自己的開發思路&#xff0c;具體需求交給AI完成&#xff01;輸入提示詞&#xff1a;個人開發的小程序 能開發哪些好備案&#xff0c;用戶喜歡使用的 AI給出…

DDoS高防IP是什么? DDoS攻擊會暴露IP嗎?

DDoS高防IP是什么&#xff1f;高防IP是指一種網絡安全服務&#xff0c;主要用于防御DDoS攻擊。隨著技術的發展&#xff0c;黑客進行網絡攻擊的強度也在加大&#xff0c;所以我們要做好網絡防護&#xff0c;及時預防DDoS攻擊。DDoS高防IP是什么&#xff1f;DDoS高防IP是指基于IP…

k8s事件驅動運維利器 shell operator

Shell-Operator 概述 Shell-Operator 是 Kubernetes 的一個工具&#xff0c;用于通過 shell 腳本擴展集群功能。它允許用戶編寫簡單的腳本&#xff08;Bash、Python 等&#xff09;來響應 Kubernetes 事件&#xff08;如資源變更、定時任務&#xff09;&#xff0c;無需編譯復…

(二)文件管理-文件權限-chmod命令的使用

文章目錄1. 命令格式2. 基本用法2.1 符號模式2.2 八進制數字模式3. 高級用法3.1 遞歸操作3.2 參考權限3.3 特殊權限位(Setuid, Setgid, Sticky Bit)3.4 X 特殊執行權限4. 注意事項4.1權限與所有權4.2 Root 權限4.3 安全風險4.4 -R 的風險4.5 目錄的執行權限1. 命令格式 chmod …

醫院預約掛號腳本

醫院預約掛號腳本 功能介紹 本腳本是一個用 Python 編寫的醫院預約掛號程序&#xff0c;支持以下功能&#xff1a; 自動預約&#xff1a;通過api交互選擇醫院、科室、醫生和時間段。自動監控&#xff1a;持續檢查指定醫生的號源狀態&#xff0c;發現可預約時段時自動嘗試預約。…

.NET駕馭Word之力:理解Word對象模型核心 (Application, Document, Range)

在使用MudTools.OfficeInterop.Word庫進行Word文檔自動化處理時&#xff0c;深入理解Word對象模型的核心組件是至關重要的。Word對象模型提供了一套層次化的結構&#xff0c;使開發者能夠通過編程方式控制Word應用程序、文檔以及文檔內容。本章將詳細介紹Word對象模型中最核心的…

Kotlin在醫療大健康域的應用實例探究與編程剖析(上)

一、引言 1.1 研究背景與意義 在當今數字化時代,醫療行業正經歷著深刻的變革。隨著信息技術的飛速發展,尤其是人工智能、大數據、物聯網等新興技術的廣泛應用,醫療行業數字化轉型已成為必然趨勢。這種轉型旨在提升醫療服務的效率和質量,優化醫療資源配置,為患者提供更加…

AI智能體的應用前景

AI智能體的應用前景正從技術探索邁向規模化落地的關鍵階段,其發展動力源于大模型能力的突破、行業需求的深化以及商業化模式的創新。以下是基于最新技術動態和行業實踐的深度解析: 一、技術突破:從「有腦無手」到「知行合一」 大模型的進化顯著提升了智能體的多模態交互與…

高系分四:網絡分布式

目錄一、我的導圖和思考二、大模型對我導圖的評價優點可優化之處三、大模型對這章節的建議一、網絡知識范疇&#xff08;一&#xff09;網絡基礎理論&#xff08;二&#xff09;局域網與廣域網&#xff08;三&#xff09;網絡安全&#xff08;四&#xff09;網絡性能優化&#…