Merge branch 'feat/llvm-obf-m3' into main

This commit is contained in:
shenlei
2026-11-24 12:10:44 +09:00
23 changed files with 3340 additions and 359 deletions
+33 -1
View File
@@ -50,6 +50,9 @@ describe('BuildView.vue', () => {
expect(wrapper.text()).toContain('打包类型')
expect(wrapper.text()).toContain('代码分支')
expect(wrapper.text()).toContain('代码混淆')
expect(wrapper.text()).toContain('build_policy.json')
expect(wrapper.find('#obfuscation').exists()).toBe(true)
expect(wrapper.find('#obfuscation').element.checked).toBe(true)
})
it('加载 apps 和 schemes', async () => {
@@ -118,7 +121,7 @@ describe('BuildView.vue', () => {
await flushPromises()
expect(wrapper.vm.form.build_type).toBe('')
expect(wrapper.vm.form.obfuscation).toBe(false)
expect(wrapper.vm.form.obfuscation).toBe(true)
expect(wrapper.vm.form.branch).toBe('main')
})
@@ -154,12 +157,41 @@ describe('BuildView.vue', () => {
expect(fetch).toHaveBeenCalledWith('/api/tasks', expect.objectContaining({
method: 'POST',
}))
const post = fetch.mock.calls.find(([url, opts]) => url === '/api/tasks' && opts?.method === 'POST')
expect(JSON.parse(post[1].body).obfuscation).toBe(true)
expect(wrapper.text()).toContain('打包任务已创建,正在排队,请勿重复点击。')
expect(wrapper.vm.form.app_id).toBe('')
expect(wrapper.vm.form.build_type).toBe('')
expect(wrapper.vm.form.scheme_id).toBe('')
})
it('取消勾选混淆时提交 obfuscation=false(旧分支按勾选执行)', async () => {
fetch.mockImplementation((url, opts) => {
if (url === '/api/tasks' && opts?.method === 'POST') {
return Promise.resolve({ ok: true, json: () => Promise.resolve({ id: 'test-id', status: 'pending' }) })
}
const responses = {
'/api/apps': { '1': { name: '测试App', server: '测试环境', certificates: { Ad_Hoc: {} } } },
'/api/schemes': { '1': { name: 'testScheme' } },
'/api/branches': ['main', 'dev'],
'/api/tasks': [],
}
return Promise.resolve({ json: () => Promise.resolve(responses[url] || {}) })
})
const wrapper = mountBuildView()
await flushPromises()
wrapper.vm.selectedServer = '测试环境'
await wrapper.vm.$nextTick()
wrapper.vm.form.app_id = '1'
await wrapper.find('#obfuscation').setValue(false)
await wrapper.find('.btn-primary').trigger('click')
await flushPromises()
const post = fetch.mock.calls.find(([url, opts]) => url === '/api/tasks' && opts?.method === 'POST')
expect(JSON.parse(post[1].body).obfuscation).toBe(false)
})
it('未选择 App 时提示', async () => {
window.alert = vi.fn()
const wrapper = mountBuildView()
+5 -3
View File
@@ -63,6 +63,7 @@
<input type="checkbox" id="obfuscation" v-model="form.obfuscation">
<label for="obfuscation">启用混淆</label>
</div>
<div class="obfuscation-hint">分支声明强制混淆(AutoPacking/build_policy.json)时始终启用,此勾选仅对旧分支/旧 Tag 生效</div>
</div>
<p v-if="submitNotice" class="submit-notice" role="status" aria-live="polite">{{ submitNotice }}</p>
<button class="btn btn-primary" @click="submitTask" :disabled="submitting">
@@ -210,7 +211,7 @@ const form = ref({
build_type: '',
scheme_id: '',
exclude_symbols: false,
obfuscation: false,
obfuscation: true,
branch: 'main',
})
const submitting = ref(false)
@@ -387,7 +388,7 @@ const submitTask = async () => {
const res = await authFetch('/api/tasks', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ...form.value, obfuscation: supportsObfuscation.value && form.value.obfuscation }),
body: JSON.stringify({ ...form.value, obfuscation: Boolean(supportsObfuscation.value && form.value.obfuscation) }),
})
if (res.ok) {
const task = await res.json()
@@ -400,7 +401,7 @@ const submitTask = async () => {
build_type: '',
scheme_id: '',
exclude_symbols: false,
obfuscation: false,
obfuscation: Boolean(supportsObfuscation.value),
branch: branches.value[0] || 'main',
}
} else {
@@ -480,6 +481,7 @@ const errorCategoryHint = (cat) => {
.form-group select:focus { outline: none; border-color: #1890ff; }
.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; }
.obfuscation-hint { margin-top: 6px; color: #999; font-size: 12px; line-height: 1.4; }
.btn { padding: 10px 20px; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; width: 100%; }
.btn-primary { background: #1890ff; color: white; }
.btn-primary:hover { background: #40a9ff; }