index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div class="rtsp-container">
  3. <div class="settings-section">
  4. <!-- Title -->
  5. <div class="section-header">
  6. <h3>RTSP Stream Media Access Configuration</h3>
  7. </div>
  8. <!-- Status and IP Information -->
  9. <div class="info-section">
  10. <div class="info-item">
  11. <div class="label-with-tooltip">
  12. <label>Password Verification Status</label>
  13. <span class="info-icon" title="This feature can be configured in System Settings > Password Management">
  14. ?
  15. </span>
  16. </div>
  17. <span class="status-badge" :class="{ enabled: passwordVerificationEnabled }">
  18. {{ passwordVerificationEnabled ? 'Enabled' : 'Disabled' }}
  19. </span>
  20. </div>
  21. <div class="info-item">
  22. <label>Camera IP Address</label>
  23. <span class="ip-address">{{ cameraIp }}</span>
  24. </div>
  25. </div>
  26. <!-- Access Examples -->
  27. <div class="examples-section">
  28. <h4>Access URL Examples</h4>
  29. <!-- No Password Example -->
  30. <div v-if="!passwordVerificationEnabled" class="example-box">
  31. <div class="example-title">Without Password Authentication</div>
  32. <div class="code-block">
  33. <code>rtsp://{{ cameraIp }}:554/video1</code>
  34. <el-button type="primary" @click="copyToClipboard(`rtsp://${cameraIp}:554/video1`)">
  35. Copy
  36. </el-button>
  37. </div>
  38. <div class="tip-text">
  39. Replace the IP address with your actual camera address. Ensure access from the same local network.
  40. </div>
  41. </div>
  42. <!-- Password Example -->
  43. <div v-else class="example-box password-example">
  44. <div class="example-title">With Password Authentication (Web Admin Credentials Required)</div>
  45. <div class="code-block">
  46. <code>rtsp://username:password@{{ cameraIp }}:554/video1</code>
  47. <el-button type="primary" @click="copyExample()">
  48. Copy
  49. </el-button>
  50. </div>
  51. <div class="tip-text warning">
  52. ⚠️ Replace <strong>username</strong> and <strong>password</strong> with your Web admin interface credentials.<br>
  53. Example: <code>rtsp://admin:password123@192.168.0.105:554/video1</code>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <!-- Copy Success Toast -->
  59. <Transition name="toast">
  60. <div v-if="showCopyToast" class="toast">
  61. ✓ Copied to clipboard
  62. </div>
  63. </Transition>
  64. </div>
  65. </template>
  66. <script setup lang="ts">
  67. import { ref, onMounted } from 'vue'
  68. import {getUserSettingApi} from '@/api/setting'
  69. import {getRtspPasswordApi} from '@/api/userManagement'
  70. const passwordVerificationEnabled = ref(false)
  71. const cameraIp = ref('localhost')
  72. const showCopyToast = ref(false)
  73. const NIC = 1
  74. // 获取本机的IP地址
  75. async function getIpAddress() {
  76. const response = await getUserSettingApi(NIC)
  77. if (response.data) {
  78. cameraIp.value = response.data.ipAddress
  79. }
  80. }
  81. // 获取rtsp password校验的状态
  82. async function getRtspPasswordStatus() {
  83. const response = await getRtspPasswordApi()
  84. if (response.data) {
  85. passwordVerificationEnabled.value = !!response.data.RtspPwdEn
  86. }
  87. }
  88. onMounted(async () => {
  89. await getIpAddress()
  90. await getRtspPasswordStatus()
  91. })
  92. // Copy to clipboard
  93. const copyToClipboard = async (text: string) => {
  94. try {
  95. await navigator.clipboard.writeText(text)
  96. showToast()
  97. } catch (error) {
  98. console.error('Failed to copy:', error)
  99. }
  100. }
  101. const copyExample = () => {
  102. const exampleText = `rtsp://username:password@${cameraIp.value}:554/video1`
  103. copyToClipboard(exampleText)
  104. }
  105. // Show toast notification
  106. const showToast = () => {
  107. showCopyToast.value = true
  108. setTimeout(() => {
  109. showCopyToast.value = false
  110. }, 2000)
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .rtsp-container {
  115. max-width: 800px;
  116. .settings-section {
  117. background: #ffffff;
  118. border-radius: 8px;
  119. padding: 24px;
  120. border: 1px solid #e0e0e0;
  121. .section-header {
  122. margin-bottom: 24px;
  123. padding-bottom: 12px;
  124. border-bottom: 1px solid #f0f0f0;
  125. h3 {
  126. font-size: 18px;
  127. font-weight: 600;
  128. color: #1f2937;
  129. margin: 0;
  130. letter-spacing: -0.3px;
  131. }
  132. }
  133. }
  134. }
  135. // Info Section
  136. .info-section {
  137. display: grid;
  138. grid-template-columns: 1fr 1fr;
  139. gap: 20px;
  140. margin-bottom: 28px;
  141. @media (max-width: 600px) {
  142. grid-template-columns: 1fr;
  143. gap: 16px;
  144. }
  145. .info-item {
  146. display: flex;
  147. flex-direction: column;
  148. gap: 8px;
  149. .label-with-tooltip {
  150. display: flex;
  151. align-items: center;
  152. gap: 6px;
  153. }
  154. label {
  155. font-size: 12px;
  156. color: #6b7280;
  157. text-transform: uppercase;
  158. letter-spacing: 0.8px;
  159. font-weight: 600;
  160. }
  161. .info-icon {
  162. display: inline-flex;
  163. align-items: center;
  164. justify-content: center;
  165. width: 18px;
  166. height: 18px;
  167. border-radius: 50%;
  168. background: #dbeafe;
  169. color: #1e40af;
  170. font-size: 12px;
  171. font-weight: 700;
  172. cursor: help;
  173. transition: all 0.3s ease;
  174. position: relative;
  175. &:hover {
  176. background: #bfdbfe;
  177. transform: scale(1.1);
  178. &::after {
  179. content: attr(title);
  180. position: absolute;
  181. bottom: 130%;
  182. left: 50%;
  183. transform: translateX(-50%);
  184. background: #1f2937;
  185. color: white;
  186. padding: 8px 12px;
  187. border-radius: 6px;
  188. font-size: 12px;
  189. font-weight: 400;
  190. white-space: nowrap;
  191. z-index: 1000;
  192. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  193. text-transform: none;
  194. letter-spacing: normal;
  195. }
  196. &::before {
  197. content: '';
  198. position: absolute;
  199. bottom: 120%;
  200. left: 50%;
  201. transform: translateX(-50%);
  202. border: 6px solid transparent;
  203. border-top-color: #1f2937;
  204. z-index: 1000;
  205. }
  206. }
  207. }
  208. .status-badge {
  209. padding: 8px 12px;
  210. border-radius: 4px;
  211. background: #f3f4f6;
  212. color: #6b7280;
  213. font-size: 13px;
  214. font-weight: 500;
  215. width: fit-content;
  216. transition: all 0.3s ease;
  217. &.enabled {
  218. background: #dbeafe;
  219. color: #1e40af;
  220. }
  221. }
  222. .ip-address {
  223. font-size: 14px;
  224. color: #1f2937;
  225. font-family: 'Monaco', 'Courier New', 'Menlo', monospace;
  226. font-weight: 500;
  227. letter-spacing: 0.3px;
  228. }
  229. }
  230. }
  231. // Examples Section
  232. .examples-section {
  233. h4 {
  234. font-size: 14px;
  235. font-weight: 600;
  236. color: #1f2937;
  237. margin: 0 0 14px 0;
  238. letter-spacing: -0.2px;
  239. }
  240. .example-box {
  241. background: #f9fafb;
  242. border: 1px solid #e5e7eb;
  243. border-radius: 6px;
  244. padding: 18px;
  245. margin-bottom: 14px;
  246. transition: all 0.3s ease;
  247. &:hover {
  248. background: #ffffff;
  249. border-color: #d1d5db;
  250. }
  251. &.password-example {
  252. background: #fffbf0;
  253. border-color: #fed7aa;
  254. &:hover {
  255. background: #fffbf0;
  256. border-color: #fdba74;
  257. }
  258. }
  259. .example-title {
  260. font-size: 13px;
  261. font-weight: 600;
  262. color: #1f2937;
  263. margin-bottom: 14px;
  264. letter-spacing: -0.2px;
  265. }
  266. .code-block {
  267. background: #ffffff;
  268. border: 1px solid #e5e7eb;
  269. border-radius: 6px;
  270. padding: 14px;
  271. display: flex;
  272. justify-content: space-between;
  273. align-items: center;
  274. gap: 12px;
  275. margin-bottom: 12px;
  276. code {
  277. font-size: 12px;
  278. color: #0ea5e9;
  279. font-family: 'Monaco', 'Courier New', 'Menlo', monospace;
  280. flex: 1;
  281. word-break: break-all;
  282. letter-spacing: 0.2px;
  283. }
  284. //.copy-btn {
  285. // background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  286. // color: white;
  287. // border: none;
  288. // border-radius: 6px;
  289. // padding: 7px 14px;
  290. // font-size: 12px;
  291. // font-weight: 600;
  292. // cursor: pointer;
  293. // white-space: nowrap;
  294. // flex-shrink: 0;
  295. // transition: all 0.3s ease;
  296. // box-shadow: 0 2px 4px rgba(6, 182, 212, 0.2);
  297. //
  298. // &:hover {
  299. // background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  300. // box-shadow: 0 4px 8px rgba(6, 182, 212, 0.3);
  301. // transform: translateY(-1px);
  302. // }
  303. //
  304. // &:active {
  305. // transform: scale(0.98);
  306. // }
  307. //}
  308. }
  309. .tip-text {
  310. font-size: 12px;
  311. color: #4b5563;
  312. line-height: 1.7;
  313. letter-spacing: 0.2px;
  314. &.warning {
  315. color: #b45309;
  316. background: rgba(180, 83, 9, 0.05);
  317. padding: 12px;
  318. border-radius: 4px;
  319. border-left: 3px solid #b45309;
  320. strong {
  321. color: #92400e;
  322. font-weight: 600;
  323. }
  324. code {
  325. background: rgba(180, 83, 9, 0.1);
  326. padding: 3px 7px;
  327. border-radius: 3px;
  328. font-family: 'Monaco', 'Courier New', 'Menlo', monospace;
  329. font-size: 11px;
  330. color: #b45309;
  331. }
  332. }
  333. code {
  334. background: #f0f1f3;
  335. padding: 3px 7px;
  336. border-radius: 3px;
  337. font-family: 'Monaco', 'Courier New', 'Menlo', monospace;
  338. font-size: 11px;
  339. color: #0284c7;
  340. }
  341. }
  342. }
  343. }
  344. // Toast Notification
  345. .toast {
  346. position: fixed;
  347. bottom: 24px;
  348. right: 24px;
  349. background-color: rgba(38, 38, 38, 0.95);
  350. //background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  351. color: white;
  352. padding: 12px 20px;
  353. border-radius: 6px;
  354. font-size: 13px;
  355. font-weight: 500;
  356. z-index: 1000;
  357. box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  358. animation: slideInUp 0.3s ease;
  359. }
  360. @keyframes slideInUp {
  361. from {
  362. opacity: 0;
  363. transform: translateY(20px);
  364. }
  365. to {
  366. opacity: 1;
  367. transform: translateY(0);
  368. }
  369. }
  370. .toast-enter-active,
  371. .toast-leave-active {
  372. transition: opacity 0.3s ease, transform 0.3s ease;
  373. }
  374. .toast-enter-from,
  375. .toast-leave-to {
  376. opacity: 0;
  377. transform: translateY(20px);
  378. }
  379. </style>