1.å¦ä¹ pythonï¼ç¨ä»ä¹è½¯ä»¶ï¼
2.åªäºå¨è¯åå to do
3.解读useEffectåuseLayouEffectåç
4.如何在网页中使用js录屏插件?源码
å¦ä¹ pythonï¼ç¨ä»ä¹è½¯ä»¶ï¼
Pythonå¼å软件å¯æ ¹æ®å ¶ç¨éä¸åå为两ç§ï¼ä¸ç§æ¯Python代ç ç¼è¾å¨ï¼ä¸ç§æ¯Pythonéæå¼åå·¥å ·ï¼ä¸¤è çé å使ç¨å¯ä»¥æ大çæé«Pythonå¼å人åçç¼ç¨æçï¼ä»¥ä¸æ¯å¸¸ç¨çå 款Python代ç ç¼è¾å¨åPythonéæå¼åå·¥å ·ã
ä¸ãPython代ç ç¼è¾å¨
1. Sublime Text
Sublime Textæ¯ä¸æ¬¾é常æµè¡ç代ç ç¼è¾å¨ï¼æ¯æPython代ç ç¼è¾ï¼åæ¶å ¼å®¹ææå¹³å°ï¼å¹¶ä¸ä¸°å¯çæ件æ©å±äºè¯æ³åç¼è¾åè½ï¼è¿ æ·å°å·§ï¼å ·æè¯å¥½çå ¼å®¹æ§ï¼å¾åç¼ç¨äººå£«çåç±ï¼
2. Vim
VimåViæ¯ä¸ç§æ¨¡åç¼è¾å¨ï¼å®å°ææ¬æ¥çä»ææ¬ç¼è¾ä¸å离ï¼VIMå¨åå§VIä¹ä¸åäºè¯¸å¤æ¹è¿ï¼å æ¬å¯æ©å±æ¨¡ååå°±å°ä»£ç æ建ï¼VIMScriptså¯ç¨äºåç§Pythonå¼åä»»å¡ï¼
3. Atom
Atom被称为âä¸çºªå¯ç ´è§£çææ¬ç¼è¾å¨âï¼å¯ä»¥å ¼å®¹ææå¹³å°ï¼æ¥ææ¶å°ççé¢ãæ件系ç»æµè§å¨åæ©å±æ件å¸åºï¼ä½¿ç¨Electronæ建ï¼å ¶è¿è¡æ¶å®è£ çæ©å±æ件å¯æ¯æPythonè¯è¨ï¼
4. GNU Emacs
GNU Emacsæ¯ä¸æ¬¾ç»èº«å è´¹ä¸å ¼å®¹ä»»ä½å¹³å°ç代ç ç¼è¾å¨ï¼ä½¿ç¨å¼ºå¤§çLispç¼ç¨è¯è¨è¿è¡å®å¶ï¼å¹¶ä¸ºPythonå¼åæä¾åç§å®å¶èæ¬ï¼æ¯ä¸æ¬¾å¯æ©å±ãå¯å®å¶ãèªå¨è®°å½ãå®æ¶æ¾ç¤ºçç¼è¾å¨ï¼ä¸ç´è¦ç»å¨UNIXå¨å´ã
5. Visual Studio Code
Visual Studio Codeæ¯ä¸æ¬¾å ¼å®¹LinuxãMac OS XåWindows å¹³å°çå ¨åè½ä»£ç ç¼è¾å¨ï¼å¯æ©å±å¹¶ä¸å¯ä»¥å¯¹å ä¹ææä»»å¡è¿è¡é ç½®ï¼å¯¹äºPythonçæ¯æå¯ä»¥å¨Visual Studio Codeä¸å®è£ æ件ï¼åªéå¿«éç¹å»æé®å³å¯æåå®è£ ï¼ä¸å¯èªå¨è¯å«Pythonå®è£ ååºã
äºãPythonéæå¼åç¯å¢
1. PyCharm
PyCharmæ¯å¯ä¸ä¸æ¬¾ä¸é¨é¢åPythonçå ¨åè½éæå¼åç¯å¢ï¼åæ ·æ¥æä»è´¹çåå è´¹å¼æºçï¼PyCharmä¸è®ºæ¯å¨Windowsã Mac OS Xç³»ç»ä¸ï¼è¿æ¯å¨Linuxç³»ç»ä¸é½æ¯æå¿«éå®è£ å使ç¨ã
PyCharmç´æ¥æ¯æPythonå¼åç¯å¢ï¼æå¼ä¸ä¸ªæ°çæ件ç¶åå°±å¯ä»¥å¼å§ç¼å代ç ï¼ä¹å¯ä»¥å¨PyCharmä¸ç´æ¥è¿è¡åè°è¯Pythonç¨åºï¼å®è¿æ¯ææºç 管çå项ç®ï¼å¹¶ä¸å ¶æ¥æä¼å¤ä¾¿å©åæ¯æ社åºï¼è½å¤å¿«éææ¡å¦ä¹ 使ç¨ï¼
2. Eclipse + PyDev
PyDevæ¯Eclipseéæå¼åç¯å¢çä¸ä¸ªæ件ï¼æ¯æPythonè°è¯ã代ç è¡¥å ¨å交äºå¼Pythonæ§å¶å°çï¼å¨Eclipseä¸å®è£ PyDevé常便æ·ï¼åªéä»Eclipseä¸éæ©âHelpâç¹å»âEclipse Marketplaceâç¶åæç´¢PyDevï¼ç¹å»å®è£ ï¼å¿ è¦çæ¶åéå¯Eclipseå³å¯ï¼å¯¹äºèµæ·±Eclipseå¼åè æ¥è¯´ï¼PyDevå¯ä»¥å¾è½»æ¾ä¸æï¼
3. Visual Studio
Visual Studioæ¯ä¸æ¬¾å ¨åè½éæå¼åå¹³å°ï¼æä¾äºå è´¹çåä»è´¹çï¼å¯ä»¥æ¯æåç§å¹³å°çå¼åï¼ä¸é带äºèªå·±çæ©å±æ件å¸åºãå¨Visual Studioä¸å¯è¿è¡Pythonç¼ç¨ï¼å¹¶ä¸æ¯æPythonæºè½æç¥ãè°è¯åå ¶ä»å·¥å ·ï¼å¼å¾æ³¨æçæ¯Visual Studioä¸æ¯æLinuxå¹³å°ï¼
4. Spyder
Spyderæ¯ä¸æ¬¾ä¸ºäºæ°æ®ç§å¦å·¥ä½æµåäºä¼åçå¼æºPythonéæå¼åç¯å¢ï¼å®æ¯éå¨Anaconda软件å 管çå¨åè¡çä¸çï¼Spyderæ¥æ大é¨åéæå¼åç¯å¢è¯¥å ·å¤çåè½ï¼å¦å¼ºå¤§è¯æ³é«äº®åè½ç代ç ç¼è¾å¨ãPython代ç è¡¥å ¨ä»¥åéææ件æµè§å¨ï¼å ¶è¿å ·æå ¶ä»Pythonç¼è¾ç¯å¢ä¸æä¸å ·å¤çåéæµè§å¨åè½ï¼ååéå使ç¨Pythonçæ°æ®ç§å¦å®¶ä»¬ã
5. Thonny
Thonnyæ¯é对æ°æçä¸æ¬¾éæå¼åç¯å¢ï¼éç¨äºå ¨é¨ä¸»æµå¹³å°ï¼é»è®¤æ åµä¸ï¼Thonnyä¼åèªå¸¦æç»çPythonçæ¬ä¸èµ·å®è£ ï¼ååæ¹ä¾¿æ°æ使ç¨ï¼
åªäºå¨è¯åå to do
1ãget to do sth. 设计åæäºYou get to do what you want.
ä½ å¯ä»¥åä»»ä½ä½ æ³åçäºã
2ãbe used to do sth. 被ç¨æ¥åæäº
If necessary X-rays and blood tests will also be used to aid diagnosis
å¦æå¿ è¦ï¼è¿è¦è¿è¡Xå æ£æ¥åéªè¡ä»¥å¸®å©è¯æã
3ãbe supposed to do sth. çåºåæäºï¼åºè¯¥åæäº
If you were a lemon, you would not be supposed to dwell on the sweetness of watermelon.
å¦æä½ æ¯ä¸åªæ 檬ï¼å°±ä¸è¯¥èæ¯ç¯ç西çççã
4ãallow to do sth. å 许æ人åæäº
Does not allow to do multiple semisynchronous notification query!
ä¸å 许å¤é¡¹ååæ¥éç¥æ¥è¯¢ï¼
5ãadd to do è¡¥å åæäº
Some of the items you attempted to add to source control do not exist on disk and could not be added.
ç£çä¸ä¸åå¨æ¨è¯å¾æ·»å å°æºä»£ç 管çä¸çæäºé¡¹ï¼æªè½æ·»å è¿äºé¡¹ã
解读useEffectåuseLayouEffectåç
èæ¯
åè¿ç¯æç« æ¯å 为工ä½ä¸ä¸æ¯é常ç¹å¿ï¼å¯ä»¥æ½ç©ºå¦ä¹ èªå·±å¸¸ç¨æ¡æ¶åç±»åºï¼æ·±å ¥ç解å®ä»¬ï¼å¨ææ¯ä¸å¸æææ´å¤§çè¿æ¥ï¼å¹å »å¦ä¹ å ´è¶£ï¼
useEffectåå ¶å®hooksä¸æ ·ï¼å è½½åæ´æ°æ§è¡ä¸ä¸æ ·çæ¹æ³(mountEffectåupdateEffect)ï¼
1.mountEffect页é¢å è½½æ¶ï¼æ§è¡mountEffectï¼
å建hook对象ï¼å å ¥ç»ä»¶çhookååé¾è¡¨ï¼
å¨ç»ä»¶çfiberçflagä¸å å ¥å¯ä½ç¨ç¸å ³çeffectTagï¼(å è½½æé´é»è®¤ælayoutEffectåeffectçå¯ä½ç¨)
å建effect对象ï¼ç»hook对象çmemoizedStateåå å ¥ç»ä»¶fiberçupdateQueueä¸å½¢æeffectç¯ç¶é¾è¡¨ï¼å¨æ¸²æå·¥ä½å®æåï¼ä¼å¾ªç¯è¿ä¸ªç¯ç¶é¾è¡¨ï¼æ§è¡æ¯ä¸ªeffect对象çdestoryåcreateï¼
consteffect={ tag,create,destroy,deps,next:null};tagæ¯effectçç±»åtag为9æ¯useEffect,5æ¯useLayoutEffectcreateæ¯useEffectæuseLayoutEffectçåè°å½æ°destroyæ¯createè¿åçåè°å½æ°depsæ¯useEffectæuseLayoutEffectçä¾èµæ°ç»nextæåä¸ä¸ªeffect对象ï¼1.1.effectç¯ç¶é¾è¡¨å¾functionpushEffect(tag,create,destroy,deps){ consteffect={ tag,create,destroy,deps,next:null};//æ°å建çeffect对象为æå为effecté¾è¡¨çä¸ä¸ªeffect对象ï¼componentUpdateQueue.lastEffectä¼æåæ°å建çeffect对象//æ°å建çeffect对象çnextä¼æå第ä¸ä¸ªeffct对象ï¼letcomponentUpdateQueue=(currentlyRenderingFiber.updateQueue);if(componentUpdateQueue===null){ //å½å没æupdateQueuecomponentUpdateQueue=createFunctionComponentUpdateQueue();//å建updateQueuecurrentlyRenderingFiber.updateQueue=componentUpdateQueue;//å½¢æä¸ä¸ªç¯ç¶é¾è¡¨componentUpdateQueue.lastEffect=effect.next=effect}else{ constlastEffect=componentUpdateQueue.lastEffect;if(lastEffect===null){ componentUpdateQueue.lastEffect=effect.next=effect;}else{ //第ä¸ä¸ªeffect对象为æå å建ççeffect对象constfirstEffect=lastEffect.next;//è·å第ä¸ä¸ªeffect对象lastEffect.next=effect;//æ§çæåä¸ä¸ªeffect对象çnextï¼æåæ°å建çeffecteffect.next=firstEffect;//æ°å建çeffect对象çnextæå第ä¸ä¸ªeffectcomponentUpdateQueue.lastEffect=effect;//updateQueueçlastEffectæåeffectï¼æ°å建çeffectå为æåä¸ä¸ªeffect对象}}returneffect;}2.updateEffect页é¢æ´æ°æ¶ï¼æ§è¡updateEffect;
æ ¹æ®hookååé¾è¡¨è·å对åºçæ´æ°æ¶çhook对象ï¼å建æ°çhook对象ï¼å å ¥hookååé¾è¡¨ï¼
å¦æeffectçdepsä¸ä¸ºnullï¼æè undefinedï¼ä¼ä»å½åhook对象æ¿å°ä¸ä¸æ¬¡effect对象ï¼åä»effect对象æ¿å°depsådestroyï¼ç¨æ°çdepsä¸ä¹æ¯è¾ï¼
å¦ææ°èdepsç¸çï¼pushä¸ä¸ªä¸å¸¦HookHasEffectçtagç»effect对象ï¼å å ¥updateQueueç¯ç¶é¾è¡¨ï¼è¿ä¸ªeffectä¸ä¼è¢«æ 记为æå¯ä½ç¨ï¼æ以ï¼effectçcreateådestroyä¸ä¼è¢«æ§è¡ï¼ï¼ä¸æ´æ°hook.memoizedStateï¼
å¦ææ°èdepsä¸ç¸çï¼æ´æ°effect对象ï¼å¨effectçtagä¸å å ¥HookHasEffectåä¸ä¸æ¬¡createæ§è¡çdestroyï¼æ´æ°hook.memoizedState;
3.useEffctçåè°å½æ°åéæ¯å½æ°çæ§è¡æ¶æºå¨renderæ¶ææ建effecté¾è¡¨ï¼å¨commitæ¶æ§è¡å æ§è¡ä¹å没ææ§è¡å®çuseEffectï¼ç¶åï¼å¨beforeMutationé¶æ®µæä½domåï¼ä»¥NormalPriority常è§ä¼å 级添å ä¸ä¸ªå¼æ¥ä»»å¡å°ä»»å¡éåï¼è¿ä¸ªå¼æ¥ä»»å¡æ¯ç¨æ¥æ§è¡useEffectçdestroyåcreateçï¼ï¼å¨layouté¶æ®µå®æï¼é¡µé¢å®æ渲æåï¼æ§è¡å¨beforeMutationé¶æ®µæ·»å çå¼æ¥ä»»å¡ï¼
3.1.commitå¼å§æ¶ä¸»è¦æ¯ä¸ºäºæ§è¡ä¹å没ææ§è¡çuseEffect
è¿å ¥commité¶æ®µï¼è¿åuseEffectå¼æ¥è°åº¦çç¹ç¹æå ³ï¼å®ä»¥ä¸è¬çä¼å 级被è°åº¦ï¼æå³çä¸æ¦ææ´é«ä¼å 级çä»»å¡è¿å ¥å°commité¶æ®µï¼ä¸ä¸æ¬¡ä»»å¡çuseEffectè¿æ²¡å¾å°æ§è¡ãæ以å¨æ¬æ¬¡æ´æ°å¼å§åï¼éè¦å å°ä¹åçuseEffecté½æ§è¡æï¼ä»¥ä¿è¯æ¬æ¬¡è°åº¦çuseEffecté½æ¯æ¬æ¬¡æ´æ°äº§ççã
functioncommitRootImpl(root,recoverableErrors,renderPriorityLevel){ do{ //`flushPassiveEffects`willcall`flushSyncUpdateQueue`attheend,which//means`flushPassiveEffects`willsometimesresultinadditional//passiveeffects.Soweneedtokeepflushinginaloopuntilthereare//nomorependingeffects.//TODO:Mightbebetterif`flushPassiveEffects`didnotautomatically//flushsynchronousworkattheend,toavoidfactoringhazardslikethis.flushPassiveEffects();}while(rootWithPendingPassiveEffects!==null);...çç¥ä»£ç }3.2.beforeMutationåªä¼åèµ·ä¸æ¬¡useEffectè°åº¦ï¼æ¯å¼æ¥è°åº¦ï¼ä»¥NormalPriority常è§ä¼å 级添å ä¸ä¸ªå¼æ¥ä»»å¡å¨ä»»å¡éåä¸ï¼push(timerQueue,newTask)ï¼ï¼å¨é¡µé¢æ¸²æå®ææ¶ï¼ä¼æ§è¡è¿ä¸ªå¼æ¥ä»»å¡
functioncommitRootImpl(root,recoverableErrors,renderPriorityLevel){ ...çç¥ä»£ç if((finishedWork.subtreeFlags&PassiveMask)!==NoFlags||(finishedWork.flags&PassiveMask)!==NoFlags){ if(!rootDoesHavePassiveEffects){ rootDoesHavePassiveEffects=true;scheduleCallback$1(NormalPriority,function(){ //æ·»å ä¸ä¸ªå¼æ¥ä»»å¡å°ä»»å¡éåflushPassiveEffects();//Thisrendertriggeredpassiveeffects:releasetherootcachepool//*after*passiveeffectsfiretoavoidfreeingacachepoolthatmay//bereferencedbyanodeinthetree(HostRoot,Cacheboundaryetc)returnnull;});}}...çç¥ä»£ç }3.3.layoutå è½½æ¶ï¼åªæ§è¡useEffectçcreateå½æ°å³å¯ï¼
å¦æpendingPassiveEffectsLanesæ¯åæ¥èµéï¼å°±å¨é¡µé¢æ¸²æå®ç´æ¥æ§è¡useEffectçcreateådestroyï¼å¨beforeMutationæ¶æ·»å çå¼æ¥ä»»å¡ï¼ä¸ä¼æ§è¡useEffectçcreateådestory
if(includesSomeLane(pendingPassiveEffectsLanes,SyncLane)&&root.tag!==LegacyRoot){ //å è½½æé´é»è®¤æ¯ä¸èµ°è¿éç//è¿éä¹æ¯æ§è¡useEffectçcreateï¼å¦æpendingPassiveEffectsLanesæ¯åæ¥èµéï¼//å°±å¨æ¸²æå®æåç´æ¥æ§è¡useEffectçcreateådestory//å¨beforeMutationæ¶æ·»å çå¼æ¥ä»»å¡æ§è¡æ¶ï¼ä¸ä¼æ§è¡useEffectçcreateådestoryflushPassiveEffects();}æ§è¡ä¸ä¸æ¬¡useEffectçcreateè¿åçdestroyï¼æ¿å°å½æ°ç»ä»¶fiberçupdateQueueï¼å¾ªç¯è¿ä¸ªeffectç¯ç¶é¾è¡¨ï¼æ¿å°effect对象çdestroyæ§è¡ï¼
functioncommitHookEffectListUnmount(flags,finishedWork,nearestMountedAncestor){ varupdateQueue=finishedWork.updateQueue;varlastEffect=updateQueue!==null?updateQueue.lastEffect:null;if(lastEffect!==null){ varfirstEffect=lastEffect.next;vareffect=firstEffect;do{ if((effect.tag&flags)===flags){ //Unmountvardestroy=effect.destroy;effect.destroy=undefined;if(destroy!==undefined){ { if((flags&Passive$1)!==NoFlags$1){ markComponentPassiveEffectUnmountStarted(finishedWork);}elseif((flags&Layout)!==NoFlags$1){ markComponentLayoutEffectUnmountStarted(finishedWork);}}safelyCallDestroy(finishedWork,nearestMountedAncestor,destroy);//æ§è¡destroy{ if((flags&Passive$1)!==NoFlags$1){ markComponentPassiveEffectUnmountStopped();}elseif((flags&Layout)!==NoFlags$1){ markComponentLayoutEffectUnmountStopped();}}}}effect=effect.next;}while(effect!==firstEffect);}}æ§è¡å®ææç»ä»¶çdestroyï¼åæ§è¡createï¼åçï¼ä¹æ¯æ¿å°å½æ°ç»ä»¶fiberçupdateQueueï¼å¾ªç¯è¿ä¸ªeffectç¯ç¶é¾è¡¨ï¼æ¿å°effect对象çcreateæ§è¡ï¼ç¶åæcreateè¿åçdestroyç»effect对象ï¼ççä¸çæ´æ°æ§è¡useEffectæ¶ç¨ï¼ï¼
functioncommitHookEffectListMount(flags,finishedWork){ varupdateQueue=finishedWork.updateQueue;varlastEffect=updateQueue!==null?updateQueue.lastEffect:null;if(lastEffect!==null){ varfirstEffect=lastEffect.next;vareffect=firstEffect;do{ if((effect.tag&flags)===flags){ { if((flags&Passive$1)!==NoFlags$1){ markComponentPassiveEffectMountStarted(finishedWork);}elseif((flags&Layout)!==NoFlags$1){ markComponentLayoutEffectMountStarted(finishedWork);}}//Mountvarcreate=effect.create;effect.destroy=create();{ if((flags&Passive$1)!==NoFlags$1){ markComponentPassiveEffectMountStopped();}elseif((flags&Layout)!==NoFlags$1){ markComponentLayoutEffectMountStopped();}}{ vardestroy=effect.destroy;if(destroy!==undefined&&typeofdestroy!=='function'){ varhookName=void0;if((effect.tag&Layout)!==NoFlags){ hookName='useLayoutEffect';}elseif((effect.tag&Insertion)!==NoFlags){ hookName='useInsertionEffect';}else{ hookName='useEffect';}varaddendum=void0;if(destroy===null){ addendum='Youreturnednull.Ifyoureffectdoesnotrequireclean'+'up,returnundefined(ornothing).';}elseif(typeofdestroy.then==='function'){ addendum='\n\nItlookslikeyouwrote'+hookName+'(async()=>...)orreturnedaPromise.'+'Instead,writetheasyncfunctioninsideyoureffect'+'andcallitimmediately:\n\n'+hookName+'(()=>{ \n'+'asyncfunctionfetchData(){ \n'+'//Youcanawaithere\n'+'constresponse=awaitMyAPI.getData(someId);\n'+'//...\n'+'}\n'+'fetchData();\n'+"},[someId]);//Or[]ifeffectdoesn'tneedpropsorstate\n\n"+'LearnmoreaboutdatafetchingwithHooks:/post/如何在网页中使用js录屏插件?
探索如何仅使用JavaScript创建网页录屏插件
实现录屏功能,我们首先需要理解`getDisplayMedia` API。源码此API允许网站在用户同意的源码情况下捕获屏幕或屏幕部分的媒体流,常用于实现屏幕共享、源码kate源码视频会议和直播。源码
基本使用步骤:
1. 调用`navigator.mediaDevices.getDisplayMedia()`方法。源码炫酷技术网源码该方法返回一个Promise,源码解析结果为包含屏幕捕获数据的源码MediaStream对象。
2. 通过脚手架快速生成插件框架。源码选择Chrome插件模板,源码使用脚手架快速创建项目。源码
3. 在浏览器右键菜单添加按钮,源码监听右键点击事件。源码在线项目源码打包apk选择百度首页作为触发录屏事件的源码中间页面。
4. 根据`isStartMediaRecorder`参数判断是源码否需要弹窗提示用户。
5. 开始录屏,c 透视自瞄源码监听结束事件,并通过a标签将录制视频下载至本地。
为了方便使用,钦差大臣源码指标提供插件下载地址:gitee.com/zheng_yongtao...
安装步骤:下载解压后,导入Chrome的`extensions/`目录,选择解压后的文件夹。
源码可访问:gitee.com/zheng_yongtao...
欢迎关注公众号『前端也能这么有趣』,获取更多有趣内容。
在此,感谢您的支持,我们下次再见。