仅对于JavaScript类似于“ How to detect if OS X is in dark mode in browsers?”。
如何在Safari / Chrome / Firefox中检测用户的系统是否处于新的macOS暗模式下,并以布尔值的形式获取结果?
答案 0 :(得分:2)
使用matchMedia函数来检查是否符合structure(list(dx = c("Dx015", "Dx019", "Dx023", "Dx027", "Dx04",
"Dx100", "Dx101", "Dx103", "Dx105", "Dx109", "Dx24", "Dx26",
"Dx27", "Dx280", "Dx29", "Dx33", "Dx36", "Dx37", "Dx380", "Dx40",
"Dx41", "Dx53", "Dx54", "Dx55", "Dx56", "Dx57", "Dx65", "Dx66",
"Dx67", "Dx68", "Dx69", "Dx70", "Dx71", "Dx72", "Dx79", "Dx",
"Dx011", "Dx012", "Dx016", "Dx02", "Dx021", "Dx03", "Dx05", "Dx06",
"Dx07", "Dx08", "Dx09", "Dx108", "Dx11", "Dx1111", "Dx118", "Dx12",
"Dx13", "Dx14", "Dx15", "Dx16", "Dx18", "Dx19", "Dx20", "Dx21",
"Dx22", "Dx28", "Dx30", "Dx31", "Dx32", "Dx325", "Dx34", "Dx35",
"Dx38", "Dx39", "Dx49", "Dx50", "Dx60", "Dx61", "Dx62", "Dx64",
"Dx75", "Dx80", "Dx81", "Dx82", "Dx85", "Dx86", "Dx87", "Dx90",
"Dx92", "Dx94", "Dx", "Dx010", "Dx0101", "Dx0102", "Dx0103",
"Dx0104", "Dx0105", "Dx0106", "Dx0107", "Dx011", "Dx0111", "Dx0112",
"Dx0113", "Dx0114", "Dx0115", "Dx0116", "Dx0117", "Dx0118", "Dx0119",
"Dx01120", "Dx01121", "Dx01122", "Dx012", "Dx013", "Dx014", "Dx016",
"Dx0161", "Dx0162", "Dx017", "Dx018", "Dx0181", "Dx02", "Dx021",
"Dx024", "Dx025", "Dx026", "Dx028", "Dx03", "Dx05", "Dx06", "Dx07",
"Dx08", "Dx09", "Dx10", "Dx106", "Dx108", "Dx11", "Dx110", "Dx111",
"Dx1111", "Dx112", "Dx113", "Dx114", "Dx115", "Dx116", "Dx117",
"Dx118 ", "Dx119", "Dx12\n", "Dx120", "Dx121", "Dx13", "Dx14",
"Dx15", "Dx16", "Dx17\n", "Dx18", "Dx19", "Dx20", "Dx21", "Dx22",
"Dx23", "Dx25", "Dx28", "Dx30", "Dx31", "Dx32", "Dx321", "Dx322",
"Dx323", "Dx324", "Dx325", "Dx326", "Dx327", "Dx328", "Dx329",
"Dx330", "Dx332", "Dx333", "Dx334", "Dx335", "Dx336", "Dx337",
"Dx34", "Dx35", "Dx38", "Dx39", "Dx42", "Dx43", "Dx45", "Dx46",
"Dx47", "Dx48", "Dx49", "Dx50", "Dx51", "Dx52", "Dx58", "Dx59",
"Dx60", "Dx63", "Dx64", "Dx73", "Dx74", "Dx75", "Dx76", "Dx77",
"Dx78", "Dx80", "Dx81", "Dx82", "Dx83", "Dx84", "Dx85", "Dx86",
"Dx87", "Dx88", "Dx89", "Dx91", "Dx92", "Dx93", "Dx94", "Dx95",
"Dx96", "DX97", "Dx98", "Dx0121", "Dx0122", "Dx0123", "Dx0125",
"Dx0126", "Dx0127", "Dx0128", "Dx400", "DX401", "DX402", "DX403",
"DX404", "DX405", "DX406", "DX407", "DX408", "DX409"), disposition = c("Priority Transport to Emergency Department ",
"Hazardous Area Response Team", "Assistance is being dispatched to arrive within 30 minutes",
"Assistance is being dispatched to arrive within 8 hours", "Go to the Emergency Department within 1 hour",
"Call Terminated Early", "Call Handler terminated the call",
"Refer To A Clinician From Our Service - Caller Unhappy With The Disposition",
"Service response is required", "Dispatch of other emergency services",
"Health Protection Emergency", "Contact Care Plan Provider within agreed timescales",
"Contact Poisons Centre", "Speak to a nurse from our service for home management advice",
"Contact Specialist Practitioner", "Speak to Clinician From our Service Within 10 Minutes",
"Refer to Health Information Advisor Immediately", "Contact Secondary Care Routine",
"Speak to a nurse from our service for home management advice",
"Refer to Health Information Advisor within 15 minutes", "Refer to Health Information Advisor next working day",
"Refer to Health Information Advisor Immediately", "Refer to Senior Colleague",
"The disposition is Locally Approved Disposition", "The disposition is Follow Admission Protocol",
"Specialist Advice – Contraception ", "Flu Line Dispositions",
"Flu Line Dispositions", "Flu Line Dispositions", "Flu Line Dispositions",
"Flu Line Dispositions", "Flu Line Dispositions", "Flu Line Dispositions",
"Direct referral to Primary Care practitioner for assessment",
"Failed Contraception", "NHS Pathways Disposition Terms ", "Emergency Department Priority 1",
"Emergency Department Priority 2", "Emergency Department Priority 4",
"Emergency Department Priority 3", "Emergency Department Priority 3",
"Emergency Department Priority 4", "Primary Care Priority 1",
"Primary Care Priority 2", "Primary Care Priority 2", "Primary Care Priority 3",
"Primary Care Priority 4", "No further triage indicated", "Primary Care Priority 1",
"Emergency Department Priority 4", "Emergency Department Priority 4",
"Primary Care Priority 1", "Primary Care Priority 2", "Primary Care Priority 2",
"Primary Care Priority 3", "Primary Care Priority 4", "Primary Care Dental Priority 2",
"Primary Care Dental Priority 2", "Primary Care Dental Priority 2",
"Primary Care Dental Priority 2", "Primary Care Dental Priority 4",
"Urgent Care Centre Pharmacist", "Primary Care Midwife Priority 1 ",
"Primary Care GUM ", "Primary Care Priority 1", "One of my clinical colleagues needs to see you - Toxic Ingestion/Inhalation ED Priority 3",
"Primary Care Priority 1", "Primary Care Priority 1", "Primary Care Priority 4",
"Primary Care Priority 4", "Emergency Department Priority 3",
"Midwife or Labour Suite immediately Priority 2", "Primary Care Centre Optician",
"Speak to the GP Practice within 20 minutes ", "999 For an Ambulance ",
"Primary Care Centre - Epidemic - Antiviral", "Primary Care Priority 4",
"Primary Care Centre Repeat Prescription within 6 hours", "Primary Care Centre Repeat Prescription within 12 hours",
"Primary Care Centre Medication Enquiry", "Primary Care Centre Repeat Prescription required within 2 hours",
"Primary Care Centre Repeat Prescription within 12 hours", "Urgent Care Centre Repeat Prescription within 24 hours",
"Repeat Prescription required ", "Emergency Department Mental Health Priority 3",
"Emergency Department Sexual Assault Assessment Priority 3",
"NHS Pathways Disposition Terms ", "\n\nEmergency Ambulance Response for Potential Cardiac Arrest \n\n",
"Emergency Ambulance Response for Potential Cardiac Arrest",
"Emergency Ambulance Response for Potential Cardiac Arrest Post Delivery ",
"Emergency Ambulance response for Fitting Now", "Emergency Ambulance Response for Major Blood Loss",
"Emergency Ambulance Response for Potential Shock ", "Emergency Ambulance Response for Respiratory Distress",
"Emergency Ambulance Response for Unconsciousness", "Emergency Ambulance Response ",
"Emergency Ambulance Response for Acute Abdomen Pregnant", "Emergency Ambulance Response for Acute Coronary Syndrome",
"Emergency Ambulance Response for Anaphylaxis", "Emergency Ambulance Response for Aortic Aneurysm Rupture/Dissection",
"Emergency Ambulance for Labour Complications", "Emergency Ambulance Response for Major Blood Loss",
"Emergency Ambulance Response for Possible Stroke Time Critical",
"Emergency Ambulance Response for Potential Shock", "Emergency Ambulance Response for Respiratory Distress Non-Trauma",
"Emergency Ambulance Response for Respiratory Distress Trauma",
"Emergency Ambulance Response for Septicaemia", "Emergency Ambulance for Unconsciousness",
"Emergency Ambulance Response (Category 3)", "Assistance needed at home due to inability to get off the floor ",
"Crew arrived before a disposition was reached ", "Non-emergency Ambulance Response ",
"Non-emergency Ambulance Response possible Viral Haemorrhagic Fever ",
"Transport to an Emergency Treatment Centre within 1 hour \n(Category 3)",
"Ambulance for Clinical Reasons", "Ambulance for Transport Reasons",
"Emergency Ambulance due to Clinical Reasons ", "Attend Emergency Treatment Centre within 1 Hour",
"Attend Emergency Treatment Centre within 1 hour possible Viral Haemorrhagic Fever",
"Assistance is being dispatched to arrive within 2 hours ", "Assistance is being dispatched to arrive within 4 hours",
"A Deferred Dispatch is being arranged ", "Assistance is being dispatched to arrive within 1 hour ",
"Attend Emergency Treatment Centre within 4 Hours ", "To contact a Primary Care Service within 2 Hours ",
"To contact a Primary Care Service within 6 Hours ", "To contact a Primary Care Service within 12 Hours ",
"To contact a Primary Care Service within 24 Hours ", "For persistent or recurrent symptoms: get in touch with the GP Practice for a Non-Urgent Appointment ",
"MUST contact own GP Practice for a Non-Urgent appointment ",
"A Clinician from our Service will call the individual back immediately to assess the problem ",
"The call is closed with no further action needed", "Speak to a Primary Care Service within 1 Hour",
"Community Nurse within 4 hours ", "Community Nurse within 24 hours ",
"Speak to a Primary Care Service within 1 hour possible Viral Haemorrhagic Fever ",
"Community Nurse next working day ", "Health Visitor next working day ",
"Community Midwife next working Day ", "Contact own GP Practice next working day for an appointment ",
"Speak to a Primary Care Service within 6 hours for Expected Death ",
"Speak to a Primary Care Service within 1 hour for Palliative Care ",
"Attend Emergency Dental Treatment Centre within 4 hours ", "Callback by Healthcare Professional within 2 hours",
"Speak to a Primary Care Service within 2 Hours ", "Callback by Healthcare Professional within 4 hours",
"Speak to a Clinician Immediately for Assessment of Symptoms",
"Speak to a Primary Care Service within 6 Hours ", "Speak to a Primary Care Service within 12 Hours ",
"Speak to a Primary Care Service within 24 Hours", "For persistent or recurrent symptoms: get in touch with the GP Practice within 3 working days ",
"To contact a Dental Service within 1 hour ", "To Contact a Dental Service within 2 hours ",
"To contact a Dental Service within 6 hours ", "To contact a Dental Service within 12 hours ",
"To contact a Dental Service within 24 hours ", "To contact a Dental Practice within 5 working days ",
"Contact Orthodontist next working day ", "Home Management ",
"Contact Pharmacist within 12 hours ", "Speak to Midwife within 1 hour ",
"Contact Genito-Urinary Clinic or other local service ", "Speak to a Clinician from our service Immediately ",
"Speak to a Clinician from our service Immediately – Refused Ambulance Disposition",
"Speak to a Clinician from our service Immediately – Refused Emergency Treatment Centre Disposition ",
"Speak to a Clinician from our service Immediately – Refused Primary Care Service Disposition ",
"Speak to a Clinician from our service Immediately – Refused Disposition ",
"Speak to a Clinician from our service immediately – Toxic Ingestion/Inhalation ",
"Speak to a Clinician from our service immediately – Frequent Caller ",
"Speak to a Clinician from our service immediately – Chemical Eye Splash (Green 3)",
"Speak to a Clinician from our service Immediately – Management of Dying Individual (Expected) (Green 3)",
"Speak to a Clinician from our service Immediately - Failed Contraception ",
"Speak to a Clinician from our Service Immediately - Burn Chemical",
"Speak to a Clinician from our service Immediately Management of Palliative Care",
"Speak to a Clinician from our service Immediately - Ambulance Validation",
"Speak to a Clinician from our service Immediately - Emergency Treatment Centre Validation",
"Speak to a Clinician from our service Immediately - Other Disposition Validation",
"Paramedic requesting callback from Healthcare Professional within 30mins",
"Speak to an Assessor Immediately for Assessment of Symptoms",
"Speak to Clinician from our service within 30 minutes ", "Speak to Clinician from our service within 2 hours ",
"Speak to Clinician from our service for home management advice ",
"Symptom Management Advice ", "Child protection Vulnerable Adult immediate referral ",
"Child protection / Vulnerable Adult non immediate referral",
"Provide Service Location Information ", "Refer to Health Information within 24 hours ",
"Refer to a Community Healthcare Professional ", "Refer to another Out-Of-Hours Service Provider ",
"999 for police (Green 4)", "Speak to Midwife or Labour Suite immediately ",
"Speak to Midwife within 2 hours ", "The call is closed with referral to the Police only ",
"No Service Clinician available refer for urgent (20 minutes ) Primary Care Clinical Assessment.",
"No Service Clinician available refer for urgent 60 minutes primary care clinical assessment",
"Contact Optician next routine appointment within 72 Hours (3 days from now) ",
"Refer to Flu line ", "Speak to the Primary Care Service within 2 hours for antiviral assessment ",
"Refer To Social Services Immediately ", "Refer To Social Services Routinely ",
"MUST contact own GP Practice within 3 working days ", "Call back by Healthcare Professional within 30 minutes ",
"Call back by Healthcare Professional within 60 minutes ", "Receive report of results or tests from laboratory ",
"Repeat Prescription required within 6 hours ", "Contact own GP Practice next working day for a repeat prescription ",
"Medication Enquiry ", "Clinician Home Management of Dying Individual (Expected) ",
"Refer to Another Agency ", "Repeat prescription required within 2 hours ",
"Repeat prescription required within 12 hours", "Repeat prescription required within 24 hours ",
"Speak to a Dental Service within 2 hours", "Attend Emergency Treatment Centre within 12 hours ",
"Unexpected death ", "Refer to Mental Health/Crisis Service within 4 hours",
"Speak to the GP Practice within 1 hour (3 calls within 4 days)",
"Attend Emergency Treatment Centre within 1 hour for Sexual Assault Assessment ",
"This call is closed with no further action required wrong service called ",
"Refer to Health Information within 12 hours ", "Emergency Contraception required within 2 hours ",
"Emergency Contraception required within 12 hours ", "Emergency Ambulance Response (Category 3)",
"Emergency Ambulance Response (Category 3)", "Emergency Ambulance Response (Category 3)",
"Emergency Ambulance Response (Category 3)", "Emergency Ambulance Response for Trauma Emergency (Category 3)",
"Emergency Ambulance Response for Pregnancy/Labour problem (Category 3)",
"Non-emergency Ambulance Response", "Speak to an Assessor Immediately for Assessment of Significant Blood Loss",
"Speak to an Assessor Immediately for Assessment of Breathing Difficulties ",
"Speak to an Assessor Immediately for Assessment of Potential Critical Illness",
"Speak to an Assessor Immediately for Assessment of Potential Life Threatening Shock",
"Speak to an Assessor Immediately for Symptomatic Assessment",
"Speak to an Assessor Immediately for Assessment of Chest Pain",
"Speak to an Assessor Immediately for Assessment of Major Trauma",
"Speak to an Assessor Immediately for Assessment of Head Injury",
" Speak to an Assessor Immediately for Assessment of Probable Stroke or Mini-Stroke",
"Speak to an Assessor Immediately for Assessment of Possible Allergic Reaction"
)), class = "data.frame", row.names = c(NA, -239L))
媒体规则:
prefers-color-scheme
打开/关闭黑暗模式时,您还会收到通知:
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
// or
const isLight = window.matchMedia('(prefers-color-scheme: light)').matches;