Selaa lähdekoodia

feat(frontend): replace PERILL guides with image pages

Developer 1 viikko sitten
vanhempi
commit
7606b19c11

BIN
dist.zip


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 13 - 35
public/assets/html/PERILL团队发展动态评估系统介绍.html


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 12 - 90
public/assets/html/PERILL团队发展动态评估系统使用说明.html


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 49 - 150
public/assets/html/PERILL团队评估欢迎页.html


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 13 - 125
public/assets/html/PERILL常见问题与支持.html


BIN
public/assets/html/images/01_welcome.png


BIN
public/assets/html/images/02_intro.png


BIN
public/assets/html/images/03_manual.png


BIN
public/assets/html/images/04_faq.png


+ 50 - 0
public/assets/html/welcome-page-navigation.js

@@ -0,0 +1,50 @@
+(function (root, factory) {
+  var api = factory()
+  if (typeof module === 'object' && module.exports) module.exports = api
+  else root.WelcomePageNavigation = api
+}(typeof self !== 'undefined' ? self : this, function () {
+  function navigateToMiniProgramHome(miniProgram, onFailure) {
+    var fail = typeof onFailure === 'function' ? onFailure : function () {}
+    if (!miniProgram || typeof miniProgram.reLaunch !== 'function') {
+      fail()
+      return false
+    }
+
+    try {
+      miniProgram.reLaunch({
+        url: '/pages/home',
+        fail: fail
+      })
+      return true
+    } catch (error) {
+      fail(error)
+      return false
+    }
+  }
+
+  function bindWelcomeButton(button, getMiniProgram, onFailure) {
+    if (!button || typeof button.addEventListener !== 'function') return
+    var navigating = false
+
+    function unlockAndReport(error) {
+      navigating = false
+      button.removeAttribute('aria-busy')
+      if (typeof onFailure === 'function') onFailure(error)
+    }
+
+    button.addEventListener('click', function (event) {
+      if (event && typeof event.preventDefault === 'function') event.preventDefault()
+      if (navigating) return
+
+      navigating = true
+      button.setAttribute('aria-busy', 'true')
+      var miniProgram = typeof getMiniProgram === 'function' ? getMiniProgram() : null
+      navigateToMiniProgramHome(miniProgram, unlockAndReport)
+    })
+  }
+
+  return {
+    bindWelcomeButton: bindWelcomeButton,
+    navigateToMiniProgramHome: navigateToMiniProgramHome
+  }
+}))

+ 43 - 0
tests/unit/welcomePageNavigation.spec.js

@@ -0,0 +1,43 @@
+const {
+  bindWelcomeButton,
+  navigateToMiniProgramHome
+} = require('../../public/assets/html/welcome-page-navigation')
+
+describe('welcome page navigation', () => {
+  test('relaunches the mini program home page', () => {
+    const reLaunch = jest.fn()
+
+    const started = navigateToMiniProgramHome({ reLaunch })
+
+    expect(started).toBe(true)
+    expect(reLaunch).toHaveBeenCalledWith(expect.objectContaining({
+      url: '/pages/home'
+    }))
+  })
+
+  test('reports a failure when the page is opened outside the mini program', () => {
+    const onFailure = jest.fn()
+
+    const started = navigateToMiniProgramHome(null, onFailure)
+
+    expect(started).toBe(false)
+    expect(onFailure).toHaveBeenCalledTimes(1)
+  })
+
+  test('prevents repeated taps while navigation is in progress', () => {
+    const listeners = {}
+    const button = {
+      addEventListener: (event, listener) => { listeners[event] = listener },
+      setAttribute: jest.fn(),
+      removeAttribute: jest.fn()
+    }
+    const reLaunch = jest.fn()
+
+    bindWelcomeButton(button, () => ({ reLaunch }))
+    listeners.click({ preventDefault: jest.fn() })
+    listeners.click({ preventDefault: jest.fn() })
+
+    expect(reLaunch).toHaveBeenCalledTimes(1)
+    expect(button.setAttribute).toHaveBeenCalledWith('aria-busy', 'true')
+  })
+})